public abstract class DataParser<C extends ApplicationContext> extends AbstractAsyncExecutable<C> implements java.io.Closeable
AsyncExecutable
it may run asynchronously within an
AsyncTask
. In async mode it fires 100 progress events per file read.childTaskRef, isTestMode, monitorController, resultRef, stateFlag
Constructor and Description |
---|
DataParser(C ctx,
java.io.File file) |
DataParser(C ctx,
FileInfo fileInfo) |
DataParser(C ctx,
java.io.File file,
int buffSize) |
DataParser(C ctx,
java.io.InputStream inStream,
FileInfo fileInfo) |
DataParser(C ctx,
LogChannel logCh,
java.io.File file) |
DataParser(C ctx,
LogChannel logCh,
FileInfo fileInfo) |
DataParser(C ctx,
LogChannel logCh,
FileInfo fileInfo,
int buffSize) |
DataParser(C ctx,
LogChannel logCh,
java.io.File file,
int buffSize) |
DataParser(C ctx,
LogChannel logCh,
java.io.InputStream inStream,
FileInfo fileInfo) |
DataParser(C ctx,
LogChannel logCh,
ProgressReader reader) |
DataParser(C ctx,
LogChannel logCh,
ResourceInfo resourceInfo) |
DataParser(C ctx,
LogChannel logCh,
ResourceInfo resourceInfo,
int buffSize) |
DataParser(C ctx,
ProgressReader reader) |
DataParser(C ctx,
ResourceInfo resourceInfo) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected FastStringIterator |
createWordIterator() |
protected void |
doOnFileClosed(FileInfo fileInfo)
Is called after the file has been closed
|
protected void |
doOnFileOpening(FileInfo fileInfo)
Is called when the file is being opened
|
void |
executeAsync()
Contains the code to be executed asynchronously.
|
double |
getAndSkipDouble() |
int |
getAndSkipInt() |
java.lang.String |
getAndSkipToken() |
char |
getBlockCommentChar() |
double |
getCurrentDouble() |
int |
getCurrentInt() |
java.lang.String |
getCurrentKeyword(java.lang.String... keywords)
Returns the current keyword and throws an Exception if it is not one of the given keywords.
|
java.lang.String |
getCurrentLine() |
int |
getCurrentLineIndex() |
long |
getCurrentLong() |
java.lang.String |
getCurrentToken() |
java.lang.String |
getCurrentToRestOfLine() |
FileInfo |
getFileInfo()
May be null if we are reading a system resource
|
long |
getFileSize() |
char |
getLineCommentChar() |
int |
getLineNumber() |
double |
getNextDouble() |
int |
getNextInt() |
java.lang.String |
getNextKeyword(java.lang.String... keywords)
Searches for the next keyword which must be one in the given keywords.
|
long |
getNextLong() |
java.lang.String |
getNextToken() |
java.lang.String |
getNextToRestOfLine() |
int |
getReadPercentage() |
int |
getReadTokenCount() |
java.lang.String |
getRestOfLine() |
boolean |
hasNext() |
protected ProgressReader |
openStream() |
protected abstract void |
performRead() |
java.lang.String |
readLine() |
void |
setBlockCommentChar(char blockCommentChar) |
void |
setLineCommentChar(char lineCommentChar) |
void |
setSkipCommentBlocks(boolean isSkipCommentBlocks) |
void |
setSkipCommentLines(boolean isSkip) |
void |
setSkipEmptyLines(boolean isSkip) |
void |
skipAll()
Stops any further parsing of input data.
|
void |
skipCheckedMatchingCurrentToken(java.lang.String token)
Forwards to the next token if the current token matches the given token.
|
void |
skipLine()
Moves one line forward
|
void |
skipLines(long numLines)
Moves numLines forward
|
boolean |
skipMatchingCurrentToken(java.lang.String token)
Forwards to the next token if the current token matches the given token.
|
void |
skipRestOfLine()
Moves to the end of line and resets the currentToken to null.
|
void |
skipToken() |
void |
skipTokens(long wordCnt) |
void |
skipToKeyword(java.lang.String keyword)
Moves to the next word that matches the given keyword.
|
addMonitor, checkCancelled, checkForErrorAndRethrow, clearMonitors, createRunStateFlag, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, handleFinish, handleStart, handleSuccess, hasError, hasMonitor, isCancellable, notifyProceeded, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getApplicationContext
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
public DataParser(C ctx, java.io.File file)
public DataParser(C ctx, java.io.File file, int buffSize)
public DataParser(C ctx, LogChannel logCh, java.io.File file)
public DataParser(C ctx, LogChannel logCh, java.io.File file, int buffSize)
public DataParser(C ctx, LogChannel logCh, FileInfo fileInfo)
public DataParser(C ctx, LogChannel logCh, FileInfo fileInfo, int buffSize)
public DataParser(C ctx, LogChannel logCh, java.io.InputStream inStream, FileInfo fileInfo)
public DataParser(C ctx, ProgressReader reader)
public DataParser(C ctx, LogChannel logCh, ProgressReader reader)
public DataParser(C ctx, ResourceInfo resourceInfo)
public DataParser(C ctx, LogChannel logCh, ResourceInfo resourceInfo)
public DataParser(C ctx, LogChannel logCh, ResourceInfo resourceInfo, int buffSize)
public int getLineNumber()
protected ProgressReader openStream() throws java.lang.Exception
java.lang.Exception
public final void executeAsync() throws java.lang.Exception
AsyncExecutable
Runnable.run()
for async execution.executeAsync
in interface AsyncExecutable<C extends ApplicationContext>
executeAsync
in class AbstractAsyncExecutable<C extends ApplicationContext>
java.lang.Exception
for synchronous execution
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
protected void doOnFileClosed(FileInfo fileInfo)
protected void doOnFileOpening(FileInfo fileInfo)
protected abstract void performRead() throws java.lang.Exception
java.lang.Exception
protected FastStringIterator createWordIterator()
public void setSkipCommentBlocks(boolean isSkipCommentBlocks)
public char getBlockCommentChar()
public void setBlockCommentChar(char blockCommentChar)
public char getLineCommentChar()
public void setLineCommentChar(char lineCommentChar)
public long getFileSize()
public FileInfo getFileInfo()
public void skipAll()
public boolean skipMatchingCurrentToken(java.lang.String token) throws java.lang.Exception
getNextToken()
call has
been done.java.lang.Exception
public void skipCheckedMatchingCurrentToken(java.lang.String token) throws java.lang.Exception
java.lang.Exception
- if the current token did not match the given tokenpublic void skipRestOfLine()
public void skipLine() throws java.lang.Exception
java.lang.Exception
public void skipLines(long numLines) throws java.lang.Exception
java.lang.Exception
public void skipToken() throws java.lang.Exception
java.lang.Exception
public void skipTokens(long wordCnt) throws java.lang.Exception
java.lang.Exception
public void skipToKeyword(java.lang.String keyword) throws java.lang.Exception
java.lang.Exception
public final java.lang.String readLine() throws java.io.IOException
java.io.IOException
public int getCurrentLineIndex()
public void setSkipCommentLines(boolean isSkip)
public void setSkipEmptyLines(boolean isSkip)
public java.lang.String getNextKeyword(java.lang.String... keywords) throws java.lang.Exception
UnexpectedKeywordException
- if the next word is not one of the expected keywordsjava.lang.Exception
public java.lang.String getCurrentKeyword(java.lang.String... keywords) throws java.lang.Exception
UnexpectedKeywordException
- if the next word is not one of the expected keywordsjava.lang.Exception
public java.lang.String getCurrentLine()
public java.lang.String getCurrentToken() throws java.lang.Exception
java.lang.Exception
public java.lang.String getAndSkipToken() throws java.lang.Exception
java.lang.Exception
public java.lang.String getNextToken() throws java.lang.Exception
java.lang.Exception
public int getReadTokenCount()
public int getReadPercentage()
public int getCurrentInt() throws java.lang.Exception
java.lang.Exception
public long getCurrentLong() throws java.lang.Exception
java.lang.Exception
public int getAndSkipInt() throws java.lang.Exception
java.lang.Exception
public int getNextInt() throws java.lang.Exception
java.lang.Exception
public long getNextLong() throws java.lang.Exception
java.lang.Exception
public double getCurrentDouble() throws java.lang.Exception
java.lang.Exception
public double getAndSkipDouble() throws java.lang.Exception
java.lang.Exception
public double getNextDouble() throws java.lang.Exception
java.lang.Exception
public boolean hasNext() throws java.lang.Exception
java.lang.Exception
public java.lang.String getRestOfLine() throws java.lang.Exception
java.lang.Exception
public java.lang.String getNextToRestOfLine() throws java.lang.Exception
java.lang.Exception
public java.lang.String getCurrentToRestOfLine() throws java.lang.Exception
java.lang.Exception
Copyright © 2014 EsprIT-Systems. All Rights Reserved.