Package adams.data.io.input
Class DefaultFlowReader
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,EncodingSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,FlowReader
,NestedFlowReader
,Serializable
public class DefaultFlowReader extends AbstractNestedFlowReader implements EncodingSupporter
Reads flows in the default format (nested).- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.data.io.input.AbstractFlowReader
AbstractFlowReader.InputType
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseCharset
m_Encoding
the encoding to use.-
Fields inherited from class adams.data.io.input.AbstractFlowReader
m_Errors, m_Quiet, m_Warnings
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description DefaultFlowReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected Actor
doReadActor(File file)
Performs the actual reading.protected Actor
doReadActor(InputStream in)
Performs the actual reading.protected Actor
doReadActor(Reader r)
Performs the actual reading.protected List
doReadNested(File file)
Performs the actual reading.protected List
doReadNested(InputStream in)
Performs the actual reading.protected List
doReadNested(Reader r)
Performs the actual reading.String
encodingTipText()
Returns the tip text for this property.FlowWriter
getCorrespondingWriter()
Returns the corresponding writer, if available.BaseCharset
getEncoding()
Returns the encoding to use.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.protected AbstractFlowReader.InputType
getInputType()
Returns the extension(s) of the format.String
globalInfo()
Returns a string describing the object.protected boolean
isCompact(File file, List<String> data)
Determines whether the file is in compact format or not.protected boolean
isCompact(List<String> lines)
Determines whether the lines represent compact format or not.protected List
nonCompactToNested(List<String> lines)
Turns the non-compact format into nested format.protected Actor
readActor(List<String> lines)
Performs the actual reading.protected List
readNested(List<String> lines)
Performs the actual reading.protected Actor
readNonCompact(List<String> lines)
Reads the actor from the non-compact format.void
setEncoding(BaseCharset value)
Sets the encoding to use.-
Methods inherited from class adams.data.io.input.AbstractNestedFlowReader
readNested, readNested, readNested, readNested
-
Methods inherited from class adams.data.io.input.AbstractFlowReader
addError, addError, addWarning, addWarning, check, getDefaultFormatExtension, getErrors, getReaders, getWarnings, initialize, isQuiet, readActor, readActor, readActor, readActor, setQuiet
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.io.FileFormatHandler
getDefaultFormatExtension
-
Methods inherited from interface adams.data.io.input.FlowReader
getErrors, getWarnings, readActor, readActor, readActor, readActor
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_Encoding
protected BaseCharset m_Encoding
the encoding to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Specified by:
getFormatDescription
in classAbstractFlowReader
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Specified by:
getFormatExtensions
in classAbstractFlowReader
- Returns:
- the extension (without the dot!)
-
getInputType
protected AbstractFlowReader.InputType getInputType()
Returns the extension(s) of the format.- Specified by:
getInputType
in classAbstractFlowReader
- Returns:
- the extension (without the dot!)
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setEncoding
public void setEncoding(BaseCharset value)
Sets the encoding to use.- Specified by:
setEncoding
in interfaceEncodingSupporter
- Parameters:
value
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
getEncoding
public BaseCharset getEncoding()
Returns the encoding to use.- Specified by:
getEncoding
in interfaceEncodingSupporter
- Returns:
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
encodingTipText
public String encodingTipText()
Returns the tip text for this property.- Specified by:
encodingTipText
in interfaceEncodingSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
isCompact
protected boolean isCompact(File file, List<String> data)
Determines whether the file is in compact format or not.- Parameters:
file
- the file to checkdata
- for transferring the data- Returns:
- true if in compact format
-
isCompact
protected boolean isCompact(List<String> lines)
Determines whether the lines represent compact format or not.- Parameters:
lines
- the flow- Returns:
- true if in compact format
-
readNonCompact
protected Actor readNonCompact(List<String> lines)
Reads the actor from the non-compact format.- Parameters:
lines
- the lines to read the actor from- Returns:
- the actor, null if failed to read
-
nonCompactToNested
protected List nonCompactToNested(List<String> lines)
Turns the non-compact format into nested format.- Parameters:
lines
- the non-compact lines- Returns:
- the nested format
-
readNested
protected List readNested(List<String> lines)
Performs the actual reading.- Parameters:
lines
- the flow data- Returns:
- the flow or null in case of an error
-
doReadNested
protected List doReadNested(File file)
Performs the actual reading.- Overrides:
doReadNested
in classAbstractNestedFlowReader
- Parameters:
file
- the file to read from- Returns:
- the flow or null in case of an error
- See Also:
AbstractFlowReader.getInputType()
-
doReadNested
protected List doReadNested(Reader r)
Performs the actual reading.- Overrides:
doReadNested
in classAbstractNestedFlowReader
- Parameters:
r
- the reader to read from- Returns:
- the flow or null in case of an error
- See Also:
getInputType()
-
doReadNested
protected List doReadNested(InputStream in)
Performs the actual reading.- Overrides:
doReadNested
in classAbstractNestedFlowReader
- Parameters:
in
- the input stream to read from- Returns:
- the flow or null in case of an error
- See Also:
getInputType()
-
readActor
protected Actor readActor(List<String> lines)
Performs the actual reading.- Parameters:
lines
- the flow data- Returns:
- the flow or null in case of an error
-
doReadActor
protected Actor doReadActor(Reader r)
Performs the actual reading.- Overrides:
doReadActor
in classAbstractFlowReader
- Parameters:
r
- the reader to read from- Returns:
- the flow or null in case of an error
- See Also:
getInputType()
-
doReadActor
protected Actor doReadActor(InputStream in)
Performs the actual reading.- Overrides:
doReadActor
in classAbstractFlowReader
- Parameters:
in
- the input stream to read from- Returns:
- the flow or null in case of an error
- See Also:
getInputType()
-
doReadActor
protected Actor doReadActor(File file)
Performs the actual reading.- Overrides:
doReadActor
in classAbstractFlowReader
- Parameters:
file
- the file to read from- Returns:
- the flow or null in case of an error
- See Also:
AbstractFlowReader.getInputType()
-
getCorrespondingWriter
public FlowWriter getCorrespondingWriter()
Returns the corresponding writer, if available.- Specified by:
getCorrespondingWriter
in interfaceFlowReader
- Returns:
- the writer, null if none available
-
-