edu.nrao.sss.model.source.parser
Class AbstractSourceCatalogWriter

java.lang.Object
  extended by edu.nrao.sss.model.source.parser.AbstractSourceCatalogWriter
All Implemented Interfaces:
SourceCatalogWriter
Direct Known Subclasses:
PstSourceCatalogWriter, XmlSourceCatalogWriter

public abstract class AbstractSourceCatalogWriter
extends Object
implements SourceCatalogWriter

A base class that implements the most common methods of the SourceCatalogWriter

Version Info:

$Revision: 714 $
$Date: 2007-06-13 10:36:05 -0600 (Wed, 13 Jun 2007) $
$Author: btruitt $


Field Summary
protected  List<edu.nrao.sss.model.source.parser.ParseError> errors
           
protected  boolean writeWasSuccessful
           
 
Constructor Summary
AbstractSourceCatalogWriter()
           
 
Method Summary
 String getError(int index)
          Returns the indexth error found during the most recent write.
 int getErrorCount()
          Returns the number of errors found during the most recent write.
 StringBuilder getErrors()
          Returns the combined text of all errors found during the most recent write.
 boolean getSuccess()
          Returns true if the most recently read data caused no parsing errors.
protected  void putError(int lineNum, String message)
          Adds a new error to our list.
protected  void putError(String message)
          Adds a new error to our list.
 boolean write(SourceCatalog cat, OutputStream out)
          Delegates to write(SourceCatalog, OutputStream, FileCompressionFormat) passing a format of UNCOMPRESSED
 boolean write(SourceCatalog cat, OutputStream out, FileCompressionFormat format)
          Wraps the output stream in a ZipOutputStream or GZIPOutputStream as appropriate depending on format.
 boolean write(SourceCatalog cat, String fileName)
          Delegates to write(SourceCatalog, Writer).
abstract  boolean write(SourceCatalog cat, Writer out)
          Must be overridden to perform the actual writing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writeWasSuccessful

protected boolean writeWasSuccessful

errors

protected List<edu.nrao.sss.model.source.parser.ParseError> errors
Constructor Detail

AbstractSourceCatalogWriter

public AbstractSourceCatalogWriter()
Method Detail

write

public abstract boolean write(SourceCatalog cat,
                              Writer out)
Must be overridden to perform the actual writing. All other write methods delegate to this one.

Specified by:
write in interface SourceCatalogWriter
Parameters:
cat - the catalog of sources to output
out - the destination of the text representation.
Returns:
true if nothing unexpected occurred while reading data.
Throws:
NullPointerException - if cat is NULL.
See Also:
SourceCatalogWriter.write(SourceCatalog, Writer)

write

public boolean write(SourceCatalog cat,
                     String fileName)
Delegates to write(SourceCatalog, Writer).

Specified by:
write in interface SourceCatalogWriter
Parameters:
cat - the catalog of sources to output
fileName - the name of a file.
Returns:
true if nothing unexpected occurred while writing data.
See Also:
SourceCatalogWriter.write(SourceCatalog, String)

write

public boolean write(SourceCatalog cat,
                     OutputStream out)
Delegates to write(SourceCatalog, OutputStream, FileCompressionFormat) passing a format of UNCOMPRESSED

Specified by:
write in interface SourceCatalogWriter
Parameters:
cat - the catalog of sources to output
out - the destination of the text representation.
Returns:
true if nothing unexpected occurred while reading data.
See Also:
SourceCatalogWriter.write(SourceCatalog, OutputStream)

write

public boolean write(SourceCatalog cat,
                     OutputStream out,
                     FileCompressionFormat format)
Wraps the output stream in a ZipOutputStream or GZIPOutputStream as appropriate depending on format. If a ZipOutputStream is created, a single ZipEntry is added to it with a name of XXX oops, this won't work at all...What extension do I use?!

Specified by:
write in interface SourceCatalogWriter
Parameters:
cat - the source of sources that can be written out in a text format.
out - the OutputStream to which the sources should be written.
format - determines what kind of compression, if any, that should be used.
Returns:
true if nothing unexpected occurred while reading data.
See Also:
SourceCatalogWriter.getErrors()

getErrors

public StringBuilder getErrors()
Description copied from interface: SourceCatalogWriter
Returns the combined text of all errors found during the most recent write.

Note that an "error" is anything unexpected encountered while writing. Not all errors are harmful. The text of each error includes the line number where it occurred and an explanation of what was wrong.

Specified by:
getErrors in interface SourceCatalogWriter
Returns:
the combined text of all errors found during the most recent write.
See Also:
SourceCatalogWriter.getErrors()

getError

public String getError(int index)
Description copied from interface: SourceCatalogWriter
Returns the indexth error found during the most recent write.

Specified by:
getError in interface SourceCatalogWriter
Parameters:
index - a positional value >= zero and < SourceCatalogWriter.getErrorCount().
Returns:
the indexth error found during the most recent write.
See Also:
SourceCatalogWriter.getError(int)

getErrorCount

public int getErrorCount()
Description copied from interface: SourceCatalogWriter
Returns the number of errors found during the most recent write.

Specified by:
getErrorCount in interface SourceCatalogWriter
Returns:
the number of errors found during the most recent write.
See Also:
SourceCatalogWriter.getErrorCount()

getSuccess

public boolean getSuccess()
Description copied from interface: SourceCatalogWriter
Returns true if the most recently read data caused no parsing errors. Note that the SourceCatalog created by this reader may be perfectly fine even if this method returns false.

Specified by:
getSuccess in interface SourceCatalogWriter
Returns:
true if there were no incidents during the most recent read.
See Also:
SourceCatalogWriter.getSuccess()

putError

protected void putError(String message)
Adds a new error to our list.


putError

protected void putError(int lineNum,
                        String message)
Adds a new error to our list.



Copyright © 2009. All Rights Reserved.