Package adams.data.io.output
Class TextFileWithLineNumbersWriter
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,EncodingSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
public class TextFileWithLineNumbersWriter extends TextFileWriter
Writes the content to a text file, preceding each line with its line number.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-enabled <boolean> (property: enabled) Whether the writer is enabled. default: true
-encoding <adams.core.base.BaseCharset> (property: encoding) The type of encoding to use. default: Default
-filename-generator <adams.core.io.AbstractFilenameGenerator> (property: filenameGenerator) The filename generator to use. default: adams.core.io.SimpleFilenameGenerator
-ignore-name <boolean> (property: ignoreName) If set to true, then the name of the content is ignored for generating the filename (useful when prefix or suffix is based on variables). default: false
-append <boolean> (property: append) If enabled, the content gets appended rather than rewriting the file. default: false
-separator <java.lang.String> (property: separator) The separator between line number and line content. default:
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_Count
the line count.protected String
m_Separator
the separator between the line number and the actual line.-
Fields inherited from class adams.data.io.output.TextFileWriter
m_Append
-
Fields inherited from class adams.data.io.output.AbstractTextWriterWithFilenameGenerator
m_FilenameGenerator, m_IgnoreName
-
Fields inherited from class adams.data.io.output.AbstractTextWriterWithEncoding
m_Encoding
-
Fields inherited from class adams.data.io.output.AbstractTextWriter
m_Enabled
-
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 TextFileWithLineNumbersWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected String
doWrite(String content, String name)
Writes the given content under the specified name.String
getSeparator()
Returns the separator between line number and line content.String
globalInfo()
Returns a short description of the writer.protected void
reset()
Resets the count.String
separatorTipText()
Returns the tip text for this property.void
setSeparator(String value)
Sets the separator between line number and line content.-
Methods inherited from class adams.data.io.output.TextFileWriter
appendTipText, getAppend, setAppend
-
Methods inherited from class adams.data.io.output.AbstractTextWriterWithFilenameGenerator
createFilename, filenameGeneratorTipText, getFilenameGenerator, getIgnoreName, ignoreNameTipText, setFilenameGenerator, setIgnoreName
-
Methods inherited from class adams.data.io.output.AbstractTextWriterWithEncoding
encodingTipText, getEncoding, setEncoding
-
Methods inherited from class adams.data.io.output.AbstractTextWriter
enabledTipText, getEnabled, setEnabled, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, 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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Separator
protected String m_Separator
the separator between the line number and the actual line.
-
m_Count
protected int m_Count
the line count.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a short description of the writer.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Overrides:
globalInfo
in classTextFileWriter
- Returns:
- a description of the writer
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classTextFileWriter
-
reset
protected void reset()
Resets the count.- Overrides:
reset
in classAbstractOptionHandler
-
setSeparator
public void setSeparator(String value)
Sets the separator between line number and line content.- Parameters:
value
- the separator
-
getSeparator
public String getSeparator()
Returns the separator between line number and line content.- Returns:
- the separator
-
separatorTipText
public String separatorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
doWrite
protected String doWrite(String content, String name)
Writes the given content under the specified name.- Overrides:
doWrite
in classTextFileWriter
- Parameters:
content
- the content to writename
- the name under which to save the content- Returns:
- if a file was generated, the filename the content was written as, otherwise null
-
-