|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.io.AbstractIterableInput<Naming<java.lang.Object>>
com.partnersoft.io.DataRecordSource
com.partnersoft.formats.text.LineTextDataRecordSource
public abstract class LineTextDataRecordSource
An abstract DataRecordSource for data formatted as a text file with line feeds and/or carriage returns separating the data records. Examples include fixed-width text formats, comma-separated, tab-separated, etc.
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.partnersoft.io.IterableInput |
|---|
IterableInput.Status |
| Field Summary | |
|---|---|
java.lang.String |
currentLine
|
int |
currentLineNumber
|
| Fields inherited from class com.partnersoft.io.DataRecordSource |
|---|
currentValues, fieldNames, verbose |
| Constructor Summary | |
|---|---|
LineTextDataRecordSource()
|
|
LineTextDataRecordSource(Cog state)
|
|
LineTextDataRecordSource(VfsFile file)
|
|
LineTextDataRecordSource(VfsFile file,
java.util.List<java.lang.String> fieldNames)
|
|
LineTextDataRecordSource(VfsFile file,
java.lang.String... fieldNames)
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class com.partnersoft.io.DataRecordSource |
|---|
copy, fetch, getCurrentValues, getFetched, getFieldNames, isVerbose, setVerbose, toCog |
| Methods inherited from class com.partnersoft.io.AbstractIterableInput |
|---|
close, getException, getStatus, isFetchValid, iterator |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public transient int currentLineNumber
public transient java.lang.String currentLine
| Constructor Detail |
|---|
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)
| Method Detail |
|---|
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.Exception
public 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.Exception
public 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.Exception
public 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||