public abstract class NdfHandler extends java.lang.Object implements SimpleLogSupport, NdfParseControl, NdfConstants
NdfHandler
is notified by the NdfParser
about all structures and
properties found during parsing. All callback methods are implemented but do nothing.
Subclasses may override the according methods in order to interpret or collect the data
as needed.allowedInNames, blockCommentChar, booleanFalseChar, booleanFalseLiteral, booleanTrueChar, booleanTrueLiteral, currentNdfDocVersion, defaultTextEndChar, defaultTextParagraphChar, lineCommentChar, ndfDocAuthorKey, ndfDocCreatedKey, ndfDocEncodingKey, ndfDocTypeKey, ndfDocVersionKey, nullLiteral, quotingBreakCodes, standardBreakCodes, structureChar, textValueBreakCodes, validTextBreakSymbols
Constructor and Description |
---|
NdfHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptDocumentVersion(java.lang.String documentVersion)
Allows for breaking parsing if document-version and
parser-version do not match.
|
protected void |
checkDocumentType(java.lang.String expectedDocType)
Checks whether the document has got the expected document type (ndfDocType property).
|
void |
doneArray(NdfStructure struct)
Called when an array structure is done.
|
void |
doneDocument(NdfStructure struct)
Called when document parsing has finished.
|
void |
doneList(NdfStructure struct)
Called when a list structure is done.
|
void |
doneObject(NdfStructure struct)
Called when an object structure is done.
|
void |
doneTable(NdfStructure struct)
Called when a table structure is done.
|
void |
doneText(NdfStructure struct)
Called when a TEXT structure is done.
|
void |
foundArrayValue(NdfStructure struct,
int dimension,
int index,
AsciiWord data)
Called when an array value was found within an array structure.
|
void |
foundArrayValue(NdfStructure struct,
int dimension,
int index,
java.lang.String value)
Called when an array value was found within an array structure.
|
void |
foundListValue(NdfStructure struct,
AsciiWord data)
Called when a list value was found within a list structure.
|
void |
foundListValue(NdfStructure struct,
java.lang.String value)
Called when a list value was found within a list structure.
|
void |
foundProperties(NdfStructure struct,
NdfProperties props)
Called when properties are found on top level.
|
void |
foundTableCell(NdfStructure struct,
int rowIndex,
int columnIndex,
AsciiWord data)
Called when a table cell value was found within a table structure.
|
void |
foundTableRow(NdfStructure struct,
int rowIndex,
NdfProperties props)
Called when a table row was found within a table structure.
|
void |
foundTableRow(NdfStructure struct,
int rowIndex,
java.lang.String[] data)
Called when a table row was found within a table structure.
|
void |
foundText(NdfStructure struct,
int paragraphIndex,
java.util.List<java.lang.String> lines)
Notifies about text-lines found within a TEXT structure.
|
void |
foundText(NdfStructure struct,
java.lang.String text)
Notifies about the text found within a TEXT structure.
|
int |
getCurrentNestingLevel()
Returns the current nesting level.
|
NdfStructure |
getCurrentStructure()
Returns the
NdfStructure which is currently being parsed. |
java.lang.String |
getDocAuthor() |
java.sql.Timestamp |
getDocCreated() |
java.lang.String |
getDocEncoding() |
java.lang.String |
getDocType() |
java.lang.String |
getDocVersion() |
FileInfo |
getFileInfo() |
int |
getLineNumber() |
LogChannel |
getLogChannel() |
int |
getMaxNestingLevel()
Returns the maximum nesting level reached during parsing.
|
boolean |
isLogDebug() |
boolean |
isLogVerbose() |
void |
logDebug(java.lang.String message) |
void |
logDump(java.lang.String message) |
void |
logError(java.lang.String message) |
void |
logError(java.lang.String message,
java.lang.Exception e) |
void |
logFatal(java.lang.String message,
java.lang.Exception e) |
void |
logInfo(java.lang.String message) |
void |
logVerbose(java.lang.String message) |
void |
logWarning(java.lang.String message) |
void |
setLogChannel(LogChannel logCh) |
NotifyArrayValue |
startArray(NdfStructure struct,
NdfProperties props,
int[] dimensions)
Called when an array structure was found.
|
void |
startDocument(NdfStructure struct,
NdfProperties headerProps)
Called when document parsing is started.
|
NotifyListValue |
startList(NdfStructure struct,
NdfProperties props)
Called when a list structure was found.
|
void |
startObject(NdfStructure struct,
NdfProperties props)
Called when an object structure was detected.
|
NotifyTableValue |
startTable(NdfStructure struct,
NdfProperties props,
java.lang.String[] columns)
Called when a table structure was found.
|
NotifyText |
startText(NdfStructure struct,
NdfProperties props)
Called when a TEXT structure was found.
|
public java.lang.String getDocVersion()
public java.lang.String getDocEncoding()
public java.lang.String getDocAuthor()
public java.lang.String getDocType()
public java.sql.Timestamp getDocCreated() throws java.text.ParseException
java.text.ParseException
public void startDocument(NdfStructure struct, NdfProperties headerProps) throws java.lang.Exception
headerProps
- the header properties found in the documentjava.lang.Exception
public void doneDocument(NdfStructure struct) throws java.lang.Exception
java.lang.Exception
public void foundProperties(NdfStructure struct, NdfProperties props) throws java.lang.Exception
java.lang.Exception
public void startObject(NdfStructure struct, NdfProperties props) throws java.lang.Exception
java.lang.Exception
public void doneObject(NdfStructure struct) throws java.lang.Exception
java.lang.Exception
public NotifyText startText(NdfStructure struct, NdfProperties props) throws java.lang.Exception
java.lang.Exception
public void foundText(NdfStructure struct, int paragraphIndex, java.util.List<java.lang.String> lines) throws java.lang.Exception
java.lang.Exception
public void foundText(NdfStructure struct, java.lang.String text) throws java.lang.Exception
java.lang.Exception
public void doneText(NdfStructure struct) throws java.lang.Exception
java.lang.Exception
public NotifyTableValue startTable(NdfStructure struct, NdfProperties props, java.lang.String[] columns) throws java.lang.Exception
NotifyTableValue.AS_PROPERTIES
foundTableRow(NdfStructure, int, NdfProperties)
NotifyTableValue.AS_STRING_ARRAY
foundTableRow(NdfStructure, int, String[])
NotifyTableValue.AS_BUFFERED_WORD
foundTableCell(NdfStructure, int, int, AsciiWord)
java.lang.Exception
public void foundTableRow(NdfStructure struct, int rowIndex, java.lang.String[] data) throws java.lang.Exception
NotifyTableValue.AS_STRING_ARRAY
notification mode.
It is quite expensive because it parses values the same way as property values.java.lang.Exception
public void foundTableRow(NdfStructure struct, int rowIndex, NdfProperties props) throws java.lang.Exception
NotifyTableValue.AS_PROPERTIES
notification mode.
It is quite expensive because it parses values the same way as property values.
But it provides the convenience to extract values readily converted to the desired data type.java.lang.Exception
public void foundTableCell(NdfStructure struct, int rowIndex, int columnIndex, AsciiWord data) throws java.lang.Exception
NotifyTableValue.AS_BUFFERED_WORD
notification mode.
It is very fast but does no interpretation on the read words at all.
It does also NOT support quoting of values and thus can only be used for numeric values.
For fast data conversion use data.asDouble(), data.asInt() etc.
Note that this method is called for each cell value in a table row.java.lang.Exception
public void doneTable(NdfStructure struct) throws java.lang.Exception
java.lang.Exception
public NotifyListValue startList(NdfStructure struct, NdfProperties props) throws java.lang.Exception
NotifyListValue.AS_STRING
foundListValue(NdfStructure, String)
NotifyListValue.AS_BUFFERED_WORD
foundListValue(NdfStructure, AsciiWord)
java.lang.Exception
public void foundListValue(NdfStructure struct, java.lang.String value) throws java.lang.Exception
NotifyListValue.AS_STRING
notification mode.
It is quite expensive because it parses values the same way as property values.java.lang.Exception
public void foundListValue(NdfStructure struct, AsciiWord data) throws java.lang.Exception
NotifyListValue.AS_BUFFERED_WORD
notification mode.
It is very fast but does no interpretation on the read words at all.
For fast data conversion use data.asDouble(), data.asInt() etc.java.lang.Exception
public void doneList(NdfStructure struct) throws java.lang.Exception
java.lang.Exception
public NotifyArrayValue startArray(NdfStructure struct, NdfProperties props, int[] dimensions) throws java.lang.Exception
NotifyArrayValue.AS_STRING
foundArrayValue(NdfStructure, int, int, String)
NotifyArrayValue.AS_BUFFERED_WORD
foundArrayValue(NdfStructure, int, int, AsciiWord)
java.lang.Exception
public void foundArrayValue(NdfStructure struct, int dimension, int index, java.lang.String value) throws java.lang.Exception
NotifyArrayValue.AS_STRING
notification mode.
It is quite expensive because it parses values the same way as property values.java.lang.Exception
public void foundArrayValue(NdfStructure struct, int dimension, int index, AsciiWord data) throws java.lang.Exception
NotifyArrayValue.AS_BUFFERED_WORD
notification mode.
It is very fast but does no interpretation on the read words at all.
For fast data conversion use data.asDouble(), data.asInt() etc.java.lang.Exception
public void doneArray(NdfStructure struct) throws java.lang.Exception
java.lang.Exception
protected final void checkDocumentType(java.lang.String expectedDocType) throws java.lang.Exception
java.lang.Exception
public boolean acceptDocumentVersion(java.lang.String documentVersion)
public final NdfStructure getCurrentStructure()
NdfStructure
which is currently being parsed.getCurrentStructure
in interface NdfParseControl
public final int getCurrentNestingLevel()
NdfParseControl
getCurrentNestingLevel
in interface NdfParseControl
public final int getMaxNestingLevel()
getMaxNestingLevel
in interface NdfParseControl
public final FileInfo getFileInfo()
public final int getLineNumber()
public final LogChannel getLogChannel()
getLogChannel
in interface SimpleLogSupport
public final void setLogChannel(LogChannel logCh)
setLogChannel
in interface SimpleLogSupport
public final boolean isLogDebug()
isLogDebug
in interface SimpleLogSupport
public final boolean isLogVerbose()
isLogVerbose
in interface SimpleLogSupport
public final void logDebug(java.lang.String message)
logDebug
in interface SimpleLogSupport
public final void logDump(java.lang.String message)
logDump
in interface SimpleLogSupport
public final void logError(java.lang.String message, java.lang.Exception e)
logError
in interface SimpleLogSupport
public final void logError(java.lang.String message)
logError
in interface SimpleLogSupport
public final void logFatal(java.lang.String message, java.lang.Exception e)
logFatal
in interface SimpleLogSupport
public final void logInfo(java.lang.String message)
logInfo
in interface SimpleLogSupport
public final void logVerbose(java.lang.String message)
logVerbose
in interface SimpleLogSupport
public final void logWarning(java.lang.String message)
logWarning
in interface SimpleLogSupport
Copyright © 2014 EsprIT-Systems. All Rights Reserved.