package normalize;

/**
*
* @author Gordon S. Linoff (gordon@data-miners.com)
* December 2009
*/

import java.util.HashMap;

public class GenericRecordMetadata extends HashMap<String, Integer> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public String metadataName;
	public int numColumns = 0;
	private String [] columnNames;
	
	public GenericRecordMetadata () 
	{
	}  // GenericRecordMetadata()

	public GenericRecordMetadata (String name, String [] colnames) {
		this.metadataName = name;
		numColumns = colnames.length;
		columnNames = new String[numColumns];
		for (int i = 0; i < colnames.length; i++) {
			this.put(colnames[i], i);
			columnNames[i] = colnames[i];
		}
	}  // GenericRecordMetadata
	
	public int getOffset (String name) throws ArrayIndexOutOfBoundsException {
		return this.get(name);
	}  // getOffset()
	
	public String getName (int offset) throws ArrayIndexOutOfBoundsException {
		return columnNames[offset];
	}  // getName()
	
	public String [] getColumnNames () {
		return columnNames;
	} // getColumnNames()
	
}  // GenericRecordMetadata

