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 int
ASCII_FIXED_FORMAT_CODE
private java.io.BufferedReader
bufferedReader
protected java.lang.String
columnDefinition
protected java.lang.String[]
columnTypes
private int[]
columnWidths
protected ControlInfo
controlFileReader
private char[]
currentToken
private int
currentTokenMaxSize
protected java.lang.String
dataCodeset
(package private) static int
DEFAULT_FORMAT_CODE
protected char[]
fieldSeparator
private char
fieldSeparatorChar0
protected int
fieldSeparatorLength
private boolean
fieldSepStartNotWhite
protected char[]
fieldStartDelimiter
(package private) int
fieldStartDelimiterIndex
protected int
fieldStartDelimiterLength
protected char[]
fieldStopDelimiter
(package private) int
fieldStopDelimiterIndex
protected int
fieldStopDelimiterLength
protected java.lang.String
format
private int
formatCode
(package private) boolean
foundStartAndStopDelimiters
(package private) boolean
foundStartDelimiter
private boolean
hasColumnDefinition
protected boolean
hasDelimiterAtEnd
private boolean
haveSep
private java.lang.String
inputFileName
(package private) int
lineNumber
private ImportLobFile[]
lobFileHandles
private java.lang.String
lobFileName
private int
lobLength
private long
lobOffset
protected java.lang.String
nullString
private int
numberOfCharsReadSoFar
protected int
numberOfColumns
(package private) int
positionOfNonWhiteSpaceCharInBack
(package private) int
positionOfNonWhiteSpaceCharInFront
protected char[]
recordSeparator
private char
recordSeparatorChar0
protected int
recordSeparatorLength
private boolean
recordSepStartNotWhite
private int
rowWidth
private short
skipLines
private static int
START_SIZE
(package private) int
stopDelimiterPosition
(package private) boolean
streamOpenForReading
private char[]
tempString
(package private) int
totalCharsSoFar
-
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 void
checkForWhiteSpaceInBack()
private void
checkForWhiteSpaceInFront()
(package private) void
closeStream()
close the input data file(package private) int
findNumberOfColumnsInARow()
(package private) java.sql.Blob
getBlobColumnFromExtFile(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.Clob
getClobColumnFromExtFile(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.String
getClobColumnFromExtFileAsString(java.lang.String lobLocationStr, int colIndex)
Returns a clob columnn data stored at the specified location.(package private) int
getCurrentRowNumber()
returns the number of the current row(package private) int
getNumberOfColumns()
protected void
ignoreFirstRow()
if columndefinition is true, ignore first row.protected void
ignoreHeaderLines()
if skipHeaderLines is greater than 0, ignore skipHeaderLines number of lines.private void
initExternalLobFile(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 boolean
isFieldSep(char[] chrArray)
protected void
loadColumnTypes()
load the column types from the meta data line to be analyzed later in the constructor of the ImportResultSetMetaData.private void
loadMetaData()
private void
loadPropertiesInfo()
private int
lookForPassedSeparator(char[] delimiter, int delimiterIndex, int delimiterLength, int nextChar, boolean lookForRecordSeperator)
private void
omitLineFeed()
private void
openFile()
private boolean
readNextDelimitedRow(java.lang.String[] returnStringArray)
private boolean
readNextFixedRow(java.lang.String[] returnStringArray)
(package private) boolean
readNextRow(java.lang.String[] returnStringArray)
the way we read the next row from input file depends on it's format(package private) boolean
readNextToken(char[] delimiter, int delimiterIndex, int delimiterLength, boolean isRecordSeperator)
(package private) boolean
readTokensUntilEndOfRecord()
private void
realOpenFile()
private int
reCheckRestOfTheCharacters(int startFrom, char[] delimiter, int delimiterLength)
java.lang.Object
run()
private boolean
skipDoubleDelimiters(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.Exception
if 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.Exception
if 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.Exception
load 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:
run
in 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.Exception
close 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.Exception
the 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.SQLException
Returns 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.SQLException
Returns 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.SQLException
Returns 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.SQLException
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.- Parameters:
lobLocationStr
- location of the clob data.colIndex
- number of the column. starts at 1.- Throws:
java.sql.SQLException
- on any errors.
-
-