Package adams.data.io.output
Class AbstractFlowWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractFlowWriter
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,FlowWriter
,Serializable
- Direct Known Subclasses:
AbstractNestedFlowWriter
,JsonFlowWriter
public abstract class AbstractFlowWriter extends AbstractOptionHandler implements FlowWriter
Ancestor for classes that can write flow objects.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractFlowWriter.OutputType
How to read the data.
-
Field Summary
-
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 AbstractFlowWriter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
doWrite(Actor content, File file)
Performs the actual writing.protected boolean
doWrite(Actor content, OutputStream out)
Performs the actual writing.protected boolean
doWrite(Actor content, Writer writer)
Performs the actual writing.String
getDefaultFormatExtension()
Returns the default extension of the format.abstract String
getFormatDescription()
Returns a string describing the format (used in the file chooser).abstract String[]
getFormatExtensions()
Returns the extension(s) of the format.protected abstract AbstractFlowWriter.OutputType
getOutputType()
Returns how to write the data, from a file, stream or writer.static String[]
getWriters()
Returns a list with classnames of writers.boolean
write(Actor content, File file)
Writes the given content to the specified file.boolean
write(Actor content, OutputStream stream)
Writes the content to the given output stream.boolean
write(Actor content, Writer writer)
Writes the content to the given writer.boolean
write(Actor content, String filename)
Writes the content to the given file.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, 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.data.io.output.FlowWriter
getCorrespondingReader
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, defineOptions, getOptionManager, toCommandLine
-
-
-
-
Method Detail
-
getFormatDescription
public abstract String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public abstract String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Returns:
- the extension (without the dot!)
-
getDefaultFormatExtension
public String getDefaultFormatExtension()
Returns the default extension of the format.- Specified by:
getDefaultFormatExtension
in interfaceFileFormatHandler
- Returns:
- the default extension (without the dot!)
-
getOutputType
protected abstract AbstractFlowWriter.OutputType getOutputType()
Returns how to write the data, from a file, stream or writer.- Returns:
- how to write the data
-
write
public boolean write(Actor content, File file)
Writes the given content to the specified file.- Specified by:
write
in interfaceFlowWriter
- Parameters:
content
- the content to writefile
- the file to write to- Returns:
- true if successfully written
-
write
public boolean write(Actor content, String filename)
Writes the content to the given file.- Specified by:
write
in interfaceFlowWriter
- Parameters:
content
- the content to writefilename
- the file to write the content to- Returns:
- true if successfully written
-
write
public boolean write(Actor content, OutputStream stream)
Writes the content to the given output stream. The caller must ensure that the stream gets closed.- Specified by:
write
in interfaceFlowWriter
- Parameters:
content
- the content to writestream
- the output stream to write the content to- Returns:
- true if successfully written
-
write
public boolean write(Actor content, Writer writer)
Writes the content to the given writer. The caller must ensure that the writer gets closed.- Specified by:
write
in interfaceFlowWriter
- Parameters:
content
- the content to writewriter
- the writer to write the content to- Returns:
- true if successfully written
-
doWrite
protected boolean doWrite(Actor content, File file)
Performs the actual writing. The caller must ensure that the writer gets closed.
Default implementation returns always false.- Parameters:
content
- the content to writefile
- the file to write the content 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.
Default implementation returns always false.- 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.
Default implementation returns always false.- Parameters:
content
- the content to writeout
- the output stream to write the content to- Returns:
- true if successfully written
-
getWriters
public static String[] getWriters()
Returns a list with classnames of writers.- Returns:
- the writer classnames
-
-