|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.model.source.parser.AbstractSourceCatalogReader
public abstract class AbstractSourceCatalogReader
An abstract implementation of the common methods in the SourceCatalogReader interface.
CVS Info:
$Revision: 630 $ |
$Date: 2007-05-18 14:12:55 -0600 (Fri, 18 May 2007) $ |
$Author: dharland $ |
Field Summary | |
---|---|
protected SourceCatalog |
catalog
|
protected List<edu.nrao.sss.model.source.parser.ParseError> |
errors
|
protected String |
histRecPrefix
|
protected boolean |
readWasSuccessful
|
protected String |
sourceInfoOrigin
|
Constructor Summary | |
---|---|
AbstractSourceCatalogReader()
|
Method Summary | |
---|---|
SourceCatalog |
getCatalog()
Returns the catalog most recently created by this reader. |
String |
getError(int index)
Returns the index th error found during the most
recent read. |
int |
getErrorCount()
Returns the number of errors found during the most recent read. |
StringBuilder |
getErrors()
Returns the combined text of all errors found during the most recent read. |
String |
getOriginOfSourceInformation()
|
String |
getPrefixForHistoricalRecords()
|
boolean |
getSuccess()
Returns true if the most recently read data caused no parsing errors. |
protected void |
putError(int lineNum,
String message)
Adds a new parsing error to our list. |
boolean |
read(InputStream in)
A default implementation of SourceCatalogReader.read(InputStream) . |
boolean |
read(InputStream in,
FileCompressionFormat format)
A default implementation of SourceCatalogReader.read(InputStream, FileCompressionFormat) . |
boolean |
read(InputStream in,
SourceCatalog destination)
A default implementation of SourceCatalogReader.read(InputStream, SourceCatalog) . |
boolean |
read(InputStream in,
SourceCatalog destination,
FileCompressionFormat format)
This method prepares the input stream in to be passed as an
InputStreamReader to read(Reader, SourceCatalog) . |
boolean |
read(Reader in)
A default implementation of SourceCatalogReader.read(Reader) . |
abstract boolean |
read(Reader in,
SourceCatalog destination)
An abstract method that must be implemented by subclasses. |
boolean |
read(String fileName)
A default implementation of SourceCatalogReader.read(String) . |
boolean |
read(String fileName,
SourceCatalog destination)
A default implementation of SourceCatalogReader.read(String, SourceCatalog) . |
void |
setOriginOfSourceInformation(String origin)
Sets text that will be used as the source of information for each source read by this reader. |
void |
setPrefixForHistoricalRecords(String prefix)
Sets text that will be used as a prefix for any historical source records generated by this reader. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SourceCatalog catalog
protected boolean readWasSuccessful
protected List<edu.nrao.sss.model.source.parser.ParseError> errors
protected String sourceInfoOrigin
protected String histRecPrefix
Constructor Detail |
---|
public AbstractSourceCatalogReader()
Method Detail |
---|
public boolean read(String fileName) throws FileNotFoundException
SourceCatalogReader.read(String)
. This
calls read(String, SourceCatalog)
with a null catalog.
read
in interface SourceCatalogReader
fileName
- the name of a data file.
FileNotFoundException
- if the data file could not be found.SourceCatalogReader.read(Reader, SourceCatalog)
public boolean read(String fileName, SourceCatalog destination) throws FileNotFoundException
SourceCatalogReader.read(String, SourceCatalog)
. This
calls read(Reader, SourceCatalog)
, wrapping fileName
with a FileReader.
read
in interface SourceCatalogReader
fileName
- the name of a data file.destination
- the catalog to which the sources should be
added. If this parameter is null,
a new catalog will be created.
FileNotFoundException
- if the data file could not be found.SourceCatalogReader.read(Reader, SourceCatalog)
public boolean read(Reader in)
SourceCatalogReader.read(Reader)
. This
calls read(Reader, SourceCatalog)
with a null catalog.
read
in interface SourceCatalogReader
in
- the source of text that can be read and turned into
Source
objects.
SourceCatalogReader.read(Reader, SourceCatalog)
public boolean read(InputStream in)
SourceCatalogReader.read(InputStream)
.
This calls read(InputStream, SourceCatalog, FileCompressionFormat)
with a null catalog and a UNCOMPRESSED format.
read
in interface SourceCatalogReader
in
- the source of text that can be read and turned into
Source
objects.
SourceCatalogReader.read(InputStream, SourceCatalog)
public boolean read(InputStream in, SourceCatalog destination)
SourceCatalogReader.read(InputStream, SourceCatalog)
.
This calls read(InputStream, SourceCatalog, FileCompressionFormat)
with a UNCOMPRESSED format.
read
in interface SourceCatalogReader
in
- the source of text that can be read and turned into
Source
objects.destination
- the catalog to which the sources should be
added. If this parameter is null,
a new catalog will be created.
SourceCatalogReader.getCatalog()
,
SourceCatalogReader.getErrors()
public boolean read(InputStream in, FileCompressionFormat format)
SourceCatalogReader.read(InputStream, FileCompressionFormat)
.
This calls read(InputStream, SourceCatalog, FileCompressionFormat)
with a null catalog.
read
in interface SourceCatalogReader
in
- the source of text that can be read and turned into
Source
objects.
SourceCatalogReader.getCatalog()
,
SourceCatalogReader.getErrors()
public boolean read(InputStream in, SourceCatalog destination, FileCompressionFormat format)
in
to be passed as an
InputStreamReader to read(Reader, SourceCatalog)
. If format
is ZIP or GZ, the InputStream is wrapped in a ZipInputStream or
GZIPInputStream respectively before being wrapped in an InputStreamReader.
This allows the primary read method (which is abstract in this class) to
be unaware that the input was compressed. If format
is null or
UNCOMPRESSED, in
is passed directly into the InputStreamReader
constructor.
read
in interface SourceCatalogReader
in
- the source of text that can be read and turned into
Source
objects.destination
- the catalog to which the sources should be
added. If this parameter is null,
a new catalog will be created.
SourceCatalogReader.getCatalog()
,
SourceCatalogReader.getErrors()
public abstract boolean read(Reader in, SourceCatalog destination)
read
in interface SourceCatalogReader
in
- the source of text that can be read and turned into
Source
objects.destination
- the catalog to which the sources should be
added. If this parameter is null,
a new catalog will be created.
read(Reader, SourceCatalog)
public StringBuilder getErrors()
SourceCatalogReader
Note that an "error" is anything unexpected encountered while reading. Not all errors are harmful. The text of each error includes the line number where it occurred and an explanation of what was wrong.
getErrors
in interface SourceCatalogReader
SourceCatalogReader.getErrors()
public String getError(int index)
SourceCatalogReader
index
th error found during the most
recent read.
getError
in interface SourceCatalogReader
index
- a positional value >= zero and < SourceCatalogReader.getErrorCount()
.
index
th error found during the most
recent read.SourceCatalogReader.getError(int)
public int getErrorCount()
SourceCatalogReader
getErrorCount
in interface SourceCatalogReader
SourceCatalogReader.getErrorCount()
public SourceCatalog getCatalog()
SourceCatalogReader
If this reader had trouble parsing the catalog data, the returned catalog may be partially or completely unfilled. If the read method has never been called, a new catalog will be returned.
getCatalog
in interface SourceCatalogReader
SourceCatalogReader.getCatalog()
public boolean getSuccess()
SourceCatalogReader
SourceCatalog
created
by this reader may be perfectly fine even if this method
returns false.
getSuccess
in interface SourceCatalogReader
SourceCatalogReader.getSuccess()
public void setOriginOfSourceInformation(String origin)
SourceCatalogReader
setOriginOfSourceInformation
in interface SourceCatalogReader
origin
- text that will be used as the source of information for each
source read by this reader. A value of null will be
interpreted as a single not to set the source's origin of
information.SourceCatalogReader.setOriginOfSourceInformation(String)
public String getOriginOfSourceInformation()
public void setPrefixForHistoricalRecords(String prefix)
SourceCatalogReader
setPrefixForHistoricalRecords
in interface SourceCatalogReader
prefix
- text that will be used as a prefix for any historical source
records generated by this reader.SourceCatalogReader.setPrefixForHistoricalRecords(String)
public String getPrefixForHistoricalRecords()
protected void putError(int lineNum, String message)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |