org.tridas.io
Class AbstractDendroFileReader

java.lang.Object
  extended by org.tridas.io.AbstractDendroFileReader
Direct Known Subclasses:
BelfastAppleReader, BelfastArchiveReader, BesanconReader, CatrasReader, CorinaReader, CSVMatrixReader, DendroDBReader, ExcelMatrixReader, HeidelbergReader, NottinghamReader, ODFMatrixReader, OOXMLReader, OxfordReader, Past4Reader, SheffieldReader, TophamReader, TridasReader, TrimsReader, TucsonCompactReader, TucsonReader, VFormatReader, WinDendroReader

public abstract class AbstractDendroFileReader
extends Object


Constructor Summary
AbstractDendroFileReader(Class<? extends IMetadataFieldSet> argDefaultFieldsClass)
           
 
Method Summary
protected  void addWarning(ConversionWarning warning)
          Add a warning to the list.
protected  void clearWarnings()
          Clears the conversion warnings.
 IMetadataFieldSet constructDefaultMetadata()
          Constructs a new metadata defaults.
abstract  int getCurrentLineNumber()
          Gets the current line number of the reader.
 Class<? extends IMetadataFieldSet> getDefaultFieldsClass()
           
abstract  IMetadataFieldSet getDefaults()
          Get the default values for this reader that were given in loading the file.
abstract  DendroFileFilter getDendroFileFilter()
           
abstract  String getDescription()
          Get the description of the format
abstract  String[] getFileExtensions()
          Returns a list of the file extensions for this file
abstract  String getFullName()
          Get the full name of the format
 String getOriginalFilename()
           
abstract  org.tridas.schema.TridasProject[] getProjects()
          Gets the parsed projects after they are loaded.
abstract  String getShortName()
          Get the short name of the format
abstract  org.tridas.schema.TridasTridas getTridasContainer()
           
 ConversionWarning[] getWarnings()
          The warnings generated by loading a file
 void loadFile(String argFilename)
          Loads a file from the given filename or url, using the default metadata.
 void loadFile(String[] argFileStrings)
          Loads a file just from the strings, using the default metadata
 void loadFile(String[] argFileStrings, IMetadataFieldSet argDefaults)
          Loads a file from the file strings
 void loadFile(String argFilename, IMetadataFieldSet argDefaultFields)
          Load a file from the given filename or url, and the given defaults.
 void loadFile(String argPath, String argFilename)
          Loads a file from the path and filename, using the default metadata.
 void loadFile(String argPath, String argFilename, IMetadataFieldSet argDefaultFields)
          Loads a file from the given path, filename, and defaults.
protected abstract  void parseFile(String[] argFileString, IMetadataFieldSet argDefaultFields)
          Parse the file from the given metadata and strings
 void reset()
          Resets the reader to load another file.
protected abstract  void resetReader()
          Reset the reader
protected  void setOriginalFilename(String origFilename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDendroFileReader

public AbstractDendroFileReader(Class<? extends IMetadataFieldSet> argDefaultFieldsClass)
Parameters:
argDefaultFieldsClass - the default field set class used for metadata.
Throws:
RuntimeException - if argDefaultFieldsClass is null or doesn't have an empty constructor
Method Detail

getDefaultFieldsClass

public Class<? extends IMetadataFieldSet> getDefaultFieldsClass()
Returns:
the class of the default fields

getWarnings

public ConversionWarning[] getWarnings()
The warnings generated by loading a file

Returns:

addWarning

protected void addWarning(ConversionWarning warning)
Add a warning to the list.

Parameters:
warning -

clearWarnings

protected void clearWarnings()
Clears the conversion warnings.


reset

public void reset()
Resets the reader to load another file.


constructDefaultMetadata

public IMetadataFieldSet constructDefaultMetadata()
Constructs a new metadata defaults.

Returns:

loadFile

public void loadFile(String argFilename,
                     IMetadataFieldSet argDefaultFields)
              throws IOException,
                     IncorrectDefaultFieldsException,
                     InvalidDendroFileException
Load a file from the given filename or url, and the given defaults. Override this method and loadFile(String, String, IMetadataFieldSet) to load files that aren't strings.

Parameters:
argFilename -
argDefaultFields -
Throws:
IOException - if the file could not be loaded
IncorrectDefaultFieldsException
InvalidDendroFileException

loadFile

public void loadFile(String argFilename)
              throws IOException,
                     InvalidDendroFileException
Loads a file from the given filename or url, using the default metadata.

Parameters:
argFilename -
Throws:
IOException
InvalidDendroFileException

loadFile

public void loadFile(String argPath,
                     String argFilename,
                     IMetadataFieldSet argDefaultFields)
              throws IOException,
                     IncorrectDefaultFieldsException,
                     InvalidDendroFileException
Loads a file from the given path, filename, and defaults. Override this method and loadFile(String, IMetadataFieldSet) to load files that aren't strings.

Parameters:
argPath -
argFilename -
argDefaultFields -
Throws:
IOException
IncorrectDefaultFieldsException
InvalidDendroFileException

loadFile

public void loadFile(String argPath,
                     String argFilename)
              throws IOException,
                     InvalidDendroFileException
Loads a file from the path and filename, using the default metadata.

Parameters:
argPath -
argFilename -
Throws:
IOException
InvalidDendroFileException

loadFile

public void loadFile(String[] argFileStrings,
                     IMetadataFieldSet argDefaults)
              throws IncorrectDefaultFieldsException,
                     InvalidDendroFileException
Loads a file from the file strings

Parameters:
argFileStrings -
argDefaults -
Throws:
IncorrectDefaultFieldsException
InvalidDendroFileException

loadFile

public void loadFile(String[] argFileStrings)
              throws InvalidDendroFileException
Loads a file just from the strings, using the default metadata

Parameters:
argFileStrings -
Throws:
InvalidDendroFileException

setOriginalFilename

protected void setOriginalFilename(String origFilename)
Parameters:
origFilename - the origFilename to set

getOriginalFilename

public String getOriginalFilename()
Returns:
the original filename, or null if never specified

parseFile

protected abstract void parseFile(String[] argFileString,
                                  IMetadataFieldSet argDefaultFields)
                           throws InvalidDendroFileException
Parse the file from the given metadata and strings

Parameters:
argFileString -
argDefaultFields -
Throws:
InvalidDendroFileException

resetReader

protected abstract void resetReader()
Reset the reader


getCurrentLineNumber

public abstract int getCurrentLineNumber()
Gets the current line number of the reader. If errors occurred, this could help point towards the cause.

Returns:
the current line number

getFileExtensions

public abstract String[] getFileExtensions()
Returns a list of the file extensions for this file

Returns:

getShortName

public abstract String getShortName()
Get the short name of the format

Returns:

getFullName

public abstract String getFullName()
Get the full name of the format

Returns:

getDescription

public abstract String getDescription()
Get the description of the format

Returns:

getDefaults

public abstract IMetadataFieldSet getDefaults()
Get the default values for this reader that were given in loading the file. If the loadFile method was never called, then this returns null.

Returns:

getProjects

public abstract org.tridas.schema.TridasProject[] getProjects()
Gets the parsed projects after they are loaded.


getTridasContainer

public abstract org.tridas.schema.TridasTridas getTridasContainer()

getDendroFileFilter

public abstract DendroFileFilter getDendroFileFilter()


Copyright © 2011. All Rights Reserved.