package com.ricebridge.csvman;
import org.jostraca.util.Internal;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
public class CsvResultSetMetaData implements ResultSetMetaData {
protected int iColumnCount = 0;
protected String[] iColumnName = null;
protected HashMap iColumnMap = new HashMap();
public CsvResultSetMetaData( String[] pHeaders ) {
String[] headers = (String[]) Internal.null_arg(pHeaders);
iColumnCount = headers.length;
iColumnName = new String[ iColumnCount + 1 ];
for( int cI = 1; cI <= iColumnCount; cI++ ) {
iColumnName[cI] = headers[cI-1];
if( null == iColumnName[cI] || "".equals( iColumnName[cI] ) ) {
iColumnName[cI] = "Column "+cI;
}
iColumnMap.put( iColumnName[cI], new Integer(cI) );
}
}
public int findColumn( String pColumnName ) {
if( iColumnMap.containsKey( pColumnName ) ) {
return ((Integer) iColumnMap.get(pColumnName)).intValue();
}
else {
throw new CsvManagerException( CsvManagerException.CODE_unknown_column, pColumnName );
}
}
public int getColumnCount() throws SQLException {
return iColumnCount;
}
public String getColumnLabel( int pColumn ) throws SQLException {
return getColumnName( pColumn );
}
public String getColumnName( int pColumn ) throws SQLException {
return iColumnName[pColumn];
}
public boolean
isAutoIncrement( int pColumn ) throws SQLException { return true; }
public boolean
isCaseSensitive(int pColumn) throws SQLException { return true; }
public boolean
isSearchable(int pColumn) throws SQLException { return false; }
public boolean
isCurrency(int pColumn) throws SQLException { return false; }
public int
isNullable(int pColumn) throws SQLException { return columnNoNulls; }
public boolean
isSigned(int pColumn) throws SQLException { return true; }
public int
getColumnDisplaySize(int pColumn) throws SQLException { return 255; }
public String
getSchemaName(int pColumn) throws SQLException { return ""; }
public int
getPrecision(int pColumn) throws SQLException { return 0; }
public int
getScale(int pColumn) throws SQLException { return 0; }
public String
getTableName(int pColumn) throws SQLException { return ""; }
public String
getCatalogName(int pColumn) throws SQLException { return ""; }
public int
getColumnType(int pColumn) throws SQLException { return Types.VARCHAR; }
public String
getColumnTypeName(int pColumn) throws SQLException { return "VARCHAR"; }
public boolean
isReadOnly(int pColumn) throws SQLException { return true; }
public boolean
isWritable(int pColumn) throws SQLException { return false; }
public boolean
isDefinitelyWritable(int pColumn) throws SQLException { return false; }
public String
getColumnClassName(int pColumn) throws SQLException { return "java.lang.String"; }
}