Package adams.data.io.output
Class DefaultFlowWriter
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,EncodingSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,FlowWriter
,NestedFlowWriter
,Serializable
public class DefaultFlowWriter extends AbstractNestedFlowWriter implements EncodingSupporter
Writes flows in the default format (nested).- Version:
- $Revision$
- 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.output.AbstractFlowWriter
AbstractFlowWriter.OutputType
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseCharset
m_Encoding
the encoding to use.protected boolean
m_UseCompact
whether to use compact format.-
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 DefaultFlowWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected boolean
doWrite(Actor content, File file)
Writes the given content to the specified file.protected boolean
doWrite(Actor content, OutputStream out)
Performs the actual writing.protected boolean
doWrite(Actor content, Writer writer)
Performs the actual writing.protected boolean
doWrite(List content, File file)
Writes the given content to the specified file.protected boolean
doWrite(List content, OutputStream out)
Performs the actual writing.protected boolean
doWrite(List content, Writer writer)
Performs the actual writing.String
encodingTipText()
Returns the tip text for this property.FlowReader
getCorrespondingReader()
Returns the corresponding reader, if available.protected boolean
getDefaultUseCompact()
Returns the default missing value.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 AbstractFlowWriter.OutputType
getOutputType()
Returns how to write the data, from a file, stream or writer.boolean
getUseCompact()
Returns whether to use compact format.String
globalInfo()
Returns a string describing the object.void
setEncoding(BaseCharset value)
Sets the encoding to use.void
setUseCompact(boolean value)
Sets whether to use compact format.protected String
toCompactString(Actor actor)
Turns the actor into a compact string.protected String
toCompactString(List nested)
Turns the nested format into a string.protected String
toNestedString(List nested)
Turns the nested format into a string.String
useCompactTipText()
Returns the tip text for this property.-
Methods inherited from class adams.data.io.output.AbstractNestedFlowWriter
write, write, write, write
-
Methods inherited from class adams.data.io.output.AbstractFlowWriter
getDefaultFormatExtension, getWriters, write, write, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, 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.output.FlowWriter
write, write, write, write
-
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.
-
m_UseCompact
protected boolean m_UseCompact
whether to use compact format.
-
-
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 classAbstractFlowWriter
- 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 classAbstractFlowWriter
- Returns:
- the extension (without the dot!)
-
getOutputType
protected AbstractFlowWriter.OutputType getOutputType()
Returns how to write the data, from a file, stream or writer.- Specified by:
getOutputType
in classAbstractFlowWriter
- Returns:
- how to write the data
-
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.
-
getDefaultUseCompact
protected boolean getDefaultUseCompact()
Returns the default missing value.- Returns:
- the default for missing values
-
setUseCompact
public void setUseCompact(boolean value)
Sets whether to use compact format.- Parameters:
value
- true if to use compact format
-
getUseCompact
public boolean getUseCompact()
Returns whether to use compact format.- Returns:
- true if compact format used
-
useCompactTipText
public String useCompactTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
toCompactString
protected String toCompactString(List nested)
Turns the nested format into a string.- Parameters:
nested
- the nested format to convert- Returns:
- the generated string
-
toNestedString
protected String toNestedString(List nested)
Turns the nested format into a string.- Parameters:
nested
- the nested format to convert- Returns:
- the generated string
-
doWrite
protected boolean doWrite(List content, File file)
Writes the given content to the specified file.- Overrides:
doWrite
in classAbstractNestedFlowWriter
- Parameters:
content
- the content to writefile
- the file to write to- Returns:
- true if successfully written
-
doWrite
protected boolean doWrite(List content, Writer writer)
Performs the actual writing. The caller must ensure that the writer gets closed.- Overrides:
doWrite
in classAbstractNestedFlowWriter
- Parameters:
content
- the content to writewriter
- the writer to write the content to- Returns:
- true if successfully written
-
doWrite
protected boolean doWrite(List content, OutputStream out)
Performs the actual writing. The caller must ensure that the output stream gets closed.- Overrides:
doWrite
in classAbstractNestedFlowWriter
- Parameters:
content
- the content to writeout
- the output stream to write the content to- Returns:
- true if successfully written
-
toCompactString
protected String toCompactString(Actor actor)
Turns the actor into a compact string.- Parameters:
actor
- the actor to convert- Returns:
- the
-
doWrite
protected boolean doWrite(Actor content, File file)
Writes the given content to the specified file.- Overrides:
doWrite
in classAbstractFlowWriter
- Parameters:
content
- the content to writefile
- the file to write to- Returns:
- true if successfully written
-
doWrite
protected boolean doWrite(Actor content, Writer writer)
Performs the actual writing. The caller must ensure that the writer gets closed.- Overrides:
doWrite
in classAbstractFlowWriter
- Parameters:
content
- the content to writewriter
- the writer to write the content to- Returns:
- true if successfully written
-
doWrite
protected boolean doWrite(Actor content, OutputStream out)
Performs the actual writing. The caller must ensure that the output stream gets closed.- Overrides:
doWrite
in classAbstractFlowWriter
- Parameters:
content
- the content to writeout
- the output stream to write the content to- Returns:
- true if successfully written
-
getCorrespondingReader
public FlowReader getCorrespondingReader()
Returns the corresponding reader, if available.- Specified by:
getCorrespondingReader
in interfaceFlowWriter
- Returns:
- the reader, null if none available
-
-