Package org.apache.derby.impl.load
Class ImportReadData
- java.lang.Object
-
- org.apache.derby.impl.load.ImportReadData
-
- All Implemented Interfaces:
java.security.PrivilegedExceptionAction<java.lang.Object>
final class ImportReadData extends java.lang.Object implements java.security.PrivilegedExceptionAction<java.lang.Object>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intASCII_FIXED_FORMAT_CODEprivate java.io.BufferedReaderbufferedReaderprotected java.lang.StringcolumnDefinitionprotected java.lang.String[]columnTypesprivate int[]columnWidthsprotected ControlInfocontrolFileReaderprivate char[]currentTokenprivate intcurrentTokenMaxSizeprotected java.lang.StringdataCodeset(package private) static intDEFAULT_FORMAT_CODEprotected char[]fieldSeparatorprivate charfieldSeparatorChar0protected intfieldSeparatorLengthprivate booleanfieldSepStartNotWhiteprotected char[]fieldStartDelimiter(package private) intfieldStartDelimiterIndexprotected intfieldStartDelimiterLengthprotected char[]fieldStopDelimiter(package private) intfieldStopDelimiterIndexprotected intfieldStopDelimiterLengthprotected java.lang.Stringformatprivate intformatCode(package private) booleanfoundStartAndStopDelimiters(package private) booleanfoundStartDelimiterprivate booleanhasColumnDefinitionprotected booleanhasDelimiterAtEndprivate booleanhaveSepprivate java.lang.StringinputFileName(package private) intlineNumberprivate ImportLobFile[]lobFileHandlesprivate java.lang.StringlobFileNameprivate intlobLengthprivate longlobOffsetprotected java.lang.StringnullStringprivate intnumberOfCharsReadSoFarprotected intnumberOfColumns(package private) intpositionOfNonWhiteSpaceCharInBack(package private) intpositionOfNonWhiteSpaceCharInFrontprotected char[]recordSeparatorprivate charrecordSeparatorChar0protected intrecordSeparatorLengthprivate booleanrecordSepStartNotWhiteprivate introwWidthprivate shortskipLinesprivate static intSTART_SIZE(package private) intstopDelimiterPosition(package private) booleanstreamOpenForReadingprivate char[]tempString(package private) inttotalCharsSoFar
-
Constructor Summary
Constructors Constructor Description ImportReadData(java.lang.String inputFileName, ControlInfo controlFileReader, short skipLines)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckForWhiteSpaceInBack()private voidcheckForWhiteSpaceInFront()(package private) voidcloseStream()close the input data file(package private) intfindNumberOfColumnsInARow()(package private) java.sql.BlobgetBlobColumnFromExtFile(java.lang.String lobLocationStr, int colIndex)Returns a blob columnn data stored at the specified location as a java.sql.Blob object.(package private) java.sql.ClobgetClobColumnFromExtFile(java.lang.String lobLocationStr, int colIndex)Returns a clob columnn data stored at the specified location as a java.sql.Clob object.(package private) java.lang.StringgetClobColumnFromExtFileAsString(java.lang.String lobLocationStr, int colIndex)Returns a clob columnn data stored at the specified location.(package private) intgetCurrentRowNumber()returns the number of the current row(package private) intgetNumberOfColumns()protected voidignoreFirstRow()if columndefinition is true, ignore first row.protected voidignoreHeaderLines()if skipHeaderLines is greater than 0, ignore skipHeaderLines number of lines.private voidinitExternalLobFile(java.lang.String lobLocationStr, int colIndex)Extract the file name, offset and length from the given lob location and setup the file resources to read the data from the file on first invocaton.private booleanisFieldSep(char[] chrArray)protected voidloadColumnTypes()load the column types from the meta data line to be analyzed later in the constructor of the ImportResultSetMetaData.private voidloadMetaData()private voidloadPropertiesInfo()private intlookForPassedSeparator(char[] delimiter, int delimiterIndex, int delimiterLength, int nextChar, boolean lookForRecordSeperator)private voidomitLineFeed()private voidopenFile()private booleanreadNextDelimitedRow(java.lang.String[] returnStringArray)private booleanreadNextFixedRow(java.lang.String[] returnStringArray)(package private) booleanreadNextRow(java.lang.String[] returnStringArray)the way we read the next row from input file depends on it's format(package private) booleanreadNextToken(char[] delimiter, int delimiterIndex, int delimiterLength, boolean isRecordSeperator)(package private) booleanreadTokensUntilEndOfRecord()private voidrealOpenFile()private intreCheckRestOfTheCharacters(int startFrom, char[] delimiter, int delimiterLength)java.lang.Objectrun()private booleanskipDoubleDelimiters(char[] characterDelimiter)
-
-
-
Field Detail
-
inputFileName
private java.lang.String inputFileName
-
skipLines
private short skipLines
-
columnWidths
private int[] columnWidths
-
rowWidth
private int rowWidth
-
tempString
private char[] tempString
-
numberOfCharsReadSoFar
private int numberOfCharsReadSoFar
-
bufferedReader
private java.io.BufferedReader bufferedReader
-
START_SIZE
private static final int START_SIZE
- See Also:
- Constant Field Values
-
currentToken
private char[] currentToken
-
currentTokenMaxSize
private int currentTokenMaxSize
-
foundStartDelimiter
boolean foundStartDelimiter
-
totalCharsSoFar
int totalCharsSoFar
-
positionOfNonWhiteSpaceCharInFront
int positionOfNonWhiteSpaceCharInFront
-
positionOfNonWhiteSpaceCharInBack
int positionOfNonWhiteSpaceCharInBack
-
lineNumber
int lineNumber
-
fieldStartDelimiterIndex
int fieldStartDelimiterIndex
-
fieldStopDelimiterIndex
int fieldStopDelimiterIndex
-
stopDelimiterPosition
int stopDelimiterPosition
-
foundStartAndStopDelimiters
boolean foundStartAndStopDelimiters
-
streamOpenForReading
boolean streamOpenForReading
-
DEFAULT_FORMAT_CODE
static final int DEFAULT_FORMAT_CODE
- See Also:
- Constant Field Values
-
ASCII_FIXED_FORMAT_CODE
static final int ASCII_FIXED_FORMAT_CODE
- See Also:
- Constant Field Values
-
formatCode
private int formatCode
-
hasColumnDefinition
private boolean hasColumnDefinition
-
recordSeparatorChar0
private char recordSeparatorChar0
-
fieldSeparatorChar0
private char fieldSeparatorChar0
-
recordSepStartNotWhite
private boolean recordSepStartNotWhite
-
fieldSepStartNotWhite
private boolean fieldSepStartNotWhite
-
controlFileReader
protected ControlInfo controlFileReader
-
numberOfColumns
protected int numberOfColumns
-
columnTypes
protected java.lang.String[] columnTypes
-
fieldSeparator
protected char[] fieldSeparator
-
fieldSeparatorLength
protected int fieldSeparatorLength
-
recordSeparator
protected char[] recordSeparator
-
recordSeparatorLength
protected int recordSeparatorLength
-
nullString
protected java.lang.String nullString
-
columnDefinition
protected java.lang.String columnDefinition
-
format
protected java.lang.String format
-
dataCodeset
protected java.lang.String dataCodeset
-
fieldStartDelimiter
protected char[] fieldStartDelimiter
-
fieldStartDelimiterLength
protected int fieldStartDelimiterLength
-
fieldStopDelimiter
protected char[] fieldStopDelimiter
-
fieldStopDelimiterLength
protected int fieldStopDelimiterLength
-
hasDelimiterAtEnd
protected boolean hasDelimiterAtEnd
-
lobFileHandles
private ImportLobFile[] lobFileHandles
-
lobFileName
private java.lang.String lobFileName
-
lobOffset
private long lobOffset
-
lobLength
private int lobLength
-
haveSep
private boolean haveSep
-
-
Constructor Detail
-
ImportReadData
ImportReadData(java.lang.String inputFileName, ControlInfo controlFileReader, short skipLines) throws java.lang.Exception- Throws:
java.lang.Exception
-
-
Method Detail
-
loadPropertiesInfo
private void loadPropertiesInfo() throws java.lang.Exception- Throws:
java.lang.Exception
-
getNumberOfColumns
int getNumberOfColumns()
-
ignoreFirstRow
protected void ignoreFirstRow() throws java.lang.Exceptionif columndefinition is true, ignore first row. The way to do that is to just look for the record separator- Throws:
java.lang.Exception- if there is an error
-
ignoreHeaderLines
protected void ignoreHeaderLines() throws java.lang.Exceptionif skipHeaderLines is greater than 0, ignore skipHeaderLines number of lines. The way to do that is to just look for the record separator- Throws:
java.lang.Exception- if there is an error
-
loadColumnTypes
protected void loadColumnTypes() throws java.lang.Exceptionload the column types from the meta data line to be analyzed later in the constructor of the ImportResultSetMetaData.- Throws:
java.lang.Exception
-
openFile
private void openFile() throws java.lang.Exception- Throws:
java.lang.Exception
-
run
public final java.lang.Object run() throws java.lang.Exception- Specified by:
runin interfacejava.security.PrivilegedExceptionAction<java.lang.Object>- Throws:
java.lang.Exception
-
realOpenFile
private void realOpenFile() throws java.lang.Exception- Throws:
java.lang.Exception
-
loadMetaData
private void loadMetaData() throws java.lang.Exception- Throws:
java.lang.Exception
-
closeStream
void closeStream() throws java.lang.Exceptionclose the input data file- Throws:
java.lang.Exception- if there is an error
-
findNumberOfColumnsInARow
int findNumberOfColumnsInARow() throws java.lang.Exception- Throws:
java.lang.Exception
-
checkForWhiteSpaceInFront
private void checkForWhiteSpaceInFront()
-
checkForWhiteSpaceInBack
private void checkForWhiteSpaceInBack()
-
readTokensUntilEndOfRecord
boolean readTokensUntilEndOfRecord() throws java.lang.Exception- Throws:
java.lang.Exception
-
lookForPassedSeparator
private int lookForPassedSeparator(char[] delimiter, int delimiterIndex, int delimiterLength, int nextChar, boolean lookForRecordSeperator) throws java.io.IOException- Throws:
java.io.IOException
-
reCheckRestOfTheCharacters
private int reCheckRestOfTheCharacters(int startFrom, char[] delimiter, int delimiterLength)
-
skipDoubleDelimiters
private boolean skipDoubleDelimiters(char[] characterDelimiter) throws java.io.IOException- Throws:
java.io.IOException
-
omitLineFeed
private void omitLineFeed() throws java.io.IOException- Throws:
java.io.IOException
-
getCurrentRowNumber
int getCurrentRowNumber()
returns the number of the current row
-
readNextRow
boolean readNextRow(java.lang.String[] returnStringArray) throws java.lang.Exceptionthe way we read the next row from input file depends on it's format- Throws:
java.lang.Exception- if there is an error
-
readNextFixedRow
private boolean readNextFixedRow(java.lang.String[] returnStringArray) throws java.lang.Exception- Throws:
java.lang.Exception
-
readNextDelimitedRow
private boolean readNextDelimitedRow(java.lang.String[] returnStringArray) throws java.lang.Exception- Throws:
java.lang.Exception
-
isFieldSep
private boolean isFieldSep(char[] chrArray)
-
readNextToken
boolean readNextToken(char[] delimiter, int delimiterIndex, int delimiterLength, boolean isRecordSeperator) throws java.lang.Exception- Throws:
java.lang.Exception
-
getClobColumnFromExtFileAsString
java.lang.String getClobColumnFromExtFileAsString(java.lang.String lobLocationStr, int colIndex) throws java.sql.SQLExceptionReturns a clob columnn data stored at the specified location.- Parameters:
lobLocationStr- location of the clob data.colIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- on any errors.
-
getClobColumnFromExtFile
java.sql.Clob getClobColumnFromExtFile(java.lang.String lobLocationStr, int colIndex) throws java.sql.SQLExceptionReturns a clob columnn data stored at the specified location as a java.sql.Clob object.- Parameters:
lobLocationStr- location of the clob data.colIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- on any errors.
-
getBlobColumnFromExtFile
java.sql.Blob getBlobColumnFromExtFile(java.lang.String lobLocationStr, int colIndex) throws java.sql.SQLExceptionReturns a blob columnn data stored at the specified location as a java.sql.Blob object.- Parameters:
lobLocationStr- location of the clob data.colIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- on any errors.
-
initExternalLobFile
private void initExternalLobFile(java.lang.String lobLocationStr, int colIndex) throws java.sql.SQLExceptionExtract the file name, offset and length from the given lob location and setup the file resources to read the data from the file on first invocaton.- Parameters:
lobLocationStr- location of the clob data.colIndex- number of the column. starts at 1.- Throws:
java.sql.SQLException- on any errors.
-
-