public abstract class LineTextDataRecordSource extends DataRecordSource
Subclasses must provide the code for parsing field values from each line.
This is done by implementing the parseLine(String) method.
This class takes care of opening and closing the file, tracking line numbers, etc.
Copyright 2006-2007 Partner Software, Inc.
IterableInput.Status| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
currentLine |
int |
currentLineNumber |
currentValues, fieldNames, verbose| Constructor and Description |
|---|
LineTextDataRecordSource() |
LineTextDataRecordSource(Cog state) |
LineTextDataRecordSource(VfsFile file) |
LineTextDataRecordSource(VfsFile file,
java.util.List<java.lang.String> fieldNames) |
LineTextDataRecordSource(VfsFile file,
java.lang.String... fieldNames) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeImp()
Subclass implementation of guts of close() method.
|
boolean |
fetchImp()
Subclass implementation of guts of fetch() method.
|
VfsFile |
getFile() |
void |
open()
Initialize the input, opening the underlying file or other resource.
|
void |
openImp()
Subclass implementation of guts of open() method.
|
abstract boolean |
parseLine(java.lang.String line)
Subclasses must implement this.
|
protected java.lang.String |
readLine()
Reads a line and returns the result.
|
copy, fetch, getCurrentValues, getFetched, getFieldNames, isVerbose, setVerbose, toCogclose, getException, getStatus, isFetchValid, iteratorpublic transient int currentLineNumber
public transient java.lang.String currentLine
public LineTextDataRecordSource()
public LineTextDataRecordSource(VfsFile file)
public LineTextDataRecordSource(VfsFile file, java.util.List<java.lang.String> fieldNames)
public LineTextDataRecordSource(VfsFile file, java.lang.String... fieldNames)
public LineTextDataRecordSource(Cog state)
public void open()
IterableInputThis method can only be called if the current status is CLOSED. Calling it in any other state will result in an IllegalStateException.
If the input is opened successfully, the status is changed to OPENED.
If an exception occurs during the open, the exception is made available via getException(), and the status is changed to END_OF_INPUT. This means close() should still be called.
open in interface IterableInput<Naming<java.lang.Object>>open in class AbstractIterableInput<Naming<java.lang.Object>>public void openImp()
throws java.lang.Exception
AbstractIterableInputSubclasses must implement this to do the actual work required by open(). Feel free to throw exceptions; these are caught inside the open() itself and applied to the exception variable. Thus, you can focus on the actual task instead of paperwork.
openImp in class AbstractIterableInput<Naming<java.lang.Object>>java.lang.Exceptionpublic boolean fetchImp()
throws java.lang.Exception
AbstractIterableInputSubclasses must implement this to do the actual work required by fetch(). Feel free to throw exceptions; these are caught inside the fetch() itself and applied to the exception variable. Thus, you can focus on the actual task instead of paperwork.
fetchImp in class AbstractIterableInput<Naming<java.lang.Object>>java.lang.Exceptionpublic void closeImp()
throws java.lang.Exception
AbstractIterableInputSubclasses must implement this to do the actual work required by close(). Feel free to throw exceptions; these are caught inside the close() itself and applied to the exception variable. Thus, you can focus on the actual task instead of paperwork.
closeImp in class AbstractIterableInput<Naming<java.lang.Object>>java.lang.Exceptionpublic abstract boolean parseLine(java.lang.String line)
throws java.lang.Exception
line - java.lang.Exceptionpublic VfsFile getFile()
protected java.lang.String readLine()
throws java.lang.Exception
java.lang.Exception