net.sf.farrago.namespace.flatfile
Class FlatFileBcpFile

java.lang.Object
  extended by net.sf.farrago.namespace.flatfile.FlatFileBcpFile

 class FlatFileBcpFile
extends Object

FlatFileBCPFile provides a way to read/write from/to control (bcp) files

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/namespace/flatfile/FlatFileBcpFile.java#2 $
Author:
Sunny Choi

Nested Class Summary
static class FlatFileBcpFile.BcpType
           
 
Field Summary
(package private)  String[] colDataLength
           
(package private)  String[] colDataType
           
(package private)  String[] colNames
           
(package private)  File ctrlFile
           
(package private)  FileWriter ctrlWriter
           
private static Pattern DoublePattern
           
private static String EmptyLinePattern
           
(package private)  String fileName
           
private static Pattern IntegerPattern
           
private static String NEWLINE
           
private static String QUOTE
           
private static String TAB
           
(package private)  FarragoTypeFactory typeFactory
           
(package private)  RelDataType[] types
           
 
Constructor Summary
FlatFileBcpFile(String filePath, FarragoTypeFactory typeFactory)
           
 
Method Summary
private  boolean changeLength(String origVal, String newVal)
           
private  boolean changeType(String origType, String newType)
           
static SqlTypeName convertBCPSqlToSqlType(String datatype)
          Converts a BCP SQL type to one of SqlTypeName
 boolean create()
          Starts a new bcp file, writes just the version number
private  String escape(char in)
          Assumes from FlatFileParams that the only escaped delimiter strings are \n and \t
 boolean exists()
          Checks if this file exists
private  boolean expandRowsAndWrite(String[] row, FlatFileParams params)
           
static RelDataType forceSingleByte(RelDataTypeFactory typeFactory, RelDataType type)
           
private  String getType(String in)
          Guess type of String to be one of VARCHAR, FLOAT, BIGINT, INTEGER
private  String getTypeLength(String in)
           
private  EigenbaseException newParseError(int line)
           
 boolean parse()
          Parses a control file for the datatypes and column names
 void update(String[] row, boolean isHeader)
          Updates, if necessary, the control file's host file data types and lengths, given a table row of information
 boolean write(String[] row, FlatFileParams params)
          Writes the main body of the control file, given a table row
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEWLINE

private static final String NEWLINE
See Also:
Constant Field Values

QUOTE

private static final String QUOTE
See Also:
Constant Field Values

TAB

private static final String TAB
See Also:
Constant Field Values

IntegerPattern

private static final Pattern IntegerPattern

DoublePattern

private static final Pattern DoublePattern

EmptyLinePattern

private static final String EmptyLinePattern
See Also:
Constant Field Values

ctrlWriter

FileWriter ctrlWriter

types

RelDataType[] types

typeFactory

FarragoTypeFactory typeFactory

ctrlFile

File ctrlFile

fileName

String fileName

colDataType

String[] colDataType

colDataLength

String[] colDataLength

colNames

String[] colNames
Constructor Detail

FlatFileBcpFile

FlatFileBcpFile(String filePath,
                FarragoTypeFactory typeFactory)
Method Detail

exists

public boolean exists()
Checks if this file exists


create

public boolean create()
Starts a new bcp file, writes just the version number


write

public boolean write(String[] row,
                     FlatFileParams params)
Writes the main body of the control file, given a table row


update

public void update(String[] row,
                   boolean isHeader)
Updates, if necessary, the control file's host file data types and lengths, given a table row of information


changeType

private boolean changeType(String origType,
                           String newType)

changeLength

private boolean changeLength(String origVal,
                             String newVal)

expandRowsAndWrite

private boolean expandRowsAndWrite(String[] row,
                                   FlatFileParams params)

escape

private String escape(char in)
Assumes from FlatFileParams that the only escaped delimiter strings are \n and \t


getType

private String getType(String in)
Guess type of String to be one of VARCHAR, FLOAT, BIGINT, INTEGER


getTypeLength

private String getTypeLength(String in)

parse

public boolean parse()
Parses a control file for the datatypes and column names


forceSingleByte

public static RelDataType forceSingleByte(RelDataTypeFactory typeFactory,
                                          RelDataType type)

newParseError

private EigenbaseException newParseError(int line)

convertBCPSqlToSqlType

public static SqlTypeName convertBCPSqlToSqlType(String datatype)
Converts a BCP SQL type to one of SqlTypeName