Package adams.data.io.output
Class FixedTabularSpreadSheetWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractSpreadSheetWriter
-
- adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
-
- adams.data.io.output.AbstractFormattedSpreadSheetWriter
-
- adams.data.io.output.FixedTabularSpreadSheetWriter
-
- All Implemented Interfaces:
AdditionalInformationHandler,Destroyable,GlobalInfoSupporter,EncodingSupporter,LoggingLevelHandler,LoggingSupporter,LocaleSupporter,OptionHandlingLocaleSupporter,OptionHandler,SizeOfHandler,Stoppable,StoppableWithFeedback,NoHeaderSpreadSheetWriter,SpreadSheetWriter,Serializable
public class FixedTabularSpreadSheetWriter extends AbstractFormattedSpreadSheetWriter implements NoHeaderSpreadSheetWriter
Outputs the spreadsheet in a simple tabular format with fixed column width, as used by dot matrix printers in days gone by.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-missing <java.lang.String> (property: missingValue) The placeholder for missing values. default:
-locale <java.util.Locale> (property: locale) The locale to use for formatting the numbers. default: Default
-number-format <java.lang.String> (property: numberFormat) The format for the numbers (see java.text.DecimalFormat), use empty string for default 'double' output. default:
-encoding <adams.core.base.BaseCharset> (property: encoding) The type of encoding to use when writing using a writer, use empty string for default. default: Default
-column-width <adams.core.base.BaseInteger> [-column-width ...] (property: columnWidth) The width in characters to use for the columns; if only one is specified then this is used for all columns. default: 10
-new-line <java.lang.String> (property: newLine) The newline character(s) to use for the columns; use '\r' for carriage return and '\n' for line feed; Linux/Unix use '\n', Windows uses '\r\n' and old Macs use '\r'. default: \\n
-date-format <adams.data.DateFormatString> (property: dateFormat) The format for dates. default: yyyy-MM-dd more: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
-datetime-format <adams.data.DateFormatString> (property: dateTimeFormat) The format for date/times. default: yyyy-MM-dd HH:mm:ss more: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
-datetimemsec-format <adams.data.DateFormatString> (property: dateTimeMsecFormat) The format for date/time msecs. default: yyyy-MM-dd HH:mm:ss.SSS more: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
-time-format <adams.data.DateFormatString> (property: timeFormat) The format for times. default: HH:mm:ss more: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
-only-float <boolean> (property: onlyFloat) If enabled, all numbers are treated as float rather than distinguishing between long and double. default: false
-no-header <boolean> (property: noHeader) If enabled, no header is output. default: false
-no-border <boolean> (property: noBorder) If enabled, no border is output. default: false
- 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.AbstractSpreadSheetWriter
AbstractSpreadSheetWriter.OutputType
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]m_ActualColumnWidththe actual column widths.protected BaseInteger[]m_ColumnWidththe column width.protected DateFormatStringm_DateFormatthe format string for the dates.protected DateFormatStringm_DateTimeFormatthe format string for the date/times.protected DateFormatStringm_DateTimeMsecFormatthe format string for the date/times msec.protected Stringm_NewLinethe new line.protected booleanm_NoBorderwhether to skip outputting the border.protected booleanm_NoHeaderwhether to skip outputting the header.protected booleanm_OnlyFloatwhether to treat all numbers as float.protected DateFormatStringm_TimeFormatthe format string for the times.-
Fields inherited from class adams.data.io.output.AbstractFormattedSpreadSheetWriter
m_Formatter, m_Locale, m_NumberFormat
-
Fields inherited from class adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
m_MissingValue
-
Fields inherited from class adams.data.io.output.AbstractSpreadSheetWriter
m_Encoding, m_Stopped
-
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 FixedTabularSpreadSheetWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddSeparatorLine(SpreadSheet content, Writer writer)Adds a separator line to the output.StringcolumnWidthTipText()Returns the tip text for this property.StringdateFormatTipText()Returns the tip date for this property.StringdateTimeFormatTipText()Returns the tip date/time for this property.StringdateTimeMsecFormatTipText()Returns the tip date/time for this property.voiddefineOptions()Adds options to the internal list of options.protected booleandoWrite(SpreadSheet content, Writer writer)Performs the actual writing.BaseInteger[]getColumnWidth()Returns the column width.SpreadSheetReadergetCorrespondingReader()Returns, if available, the corresponding reader.DateFormatStringgetDateFormat()Returns the format for date columns.DateFormatStringgetDateTimeFormat()Returns the format for date/time columns.DateFormatStringgetDateTimeMsecFormat()Returns the format for date/time msec columns.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.StringgetNewLine()Returns the string used as newline.booleangetNoBorder()Returns whether to use a border or not.booleangetNoHeader()Returns whether to use a header or not.booleangetOnlyFloat()Returns whether to treat all numbers as float rather than distinguishing between long and double.protected AbstractSpreadSheetWriter.OutputTypegetOutputType()Returns how the data is written.DateFormatStringgetTimeFormat()Returns the format for time columns.StringglobalInfo()Returns a string describing the object.StringnewLineTipText()Returns the tip text for this property.StringnoBorderTipText()Returns the tip text for this property.StringnoHeaderTipText()Returns the tip text for this property.StringonlyFloatTipText()Returns the tip text for this property.protected Stringpad(int col, String s, boolean leftPad)Pads a string either on the left or the right hand side with blanks.voidsetColumnWidth(BaseInteger[] value)Sets the column width.voidsetDateFormat(DateFormatString value)Sets the format for date columns.voidsetDateTimeFormat(DateFormatString value)Sets the format for date/time columns.voidsetDateTimeMsecFormat(DateFormatString value)Sets the format for date/time msec columns.voidsetNewLine(String value)Sets the string to use as newline.voidsetNoBorder(boolean value)Sets whether to use a border or not.voidsetNoHeader(boolean value)Sets whether to use a header or not.voidsetOnlyFloat(boolean value)Sets whether to treat all numbers as float rather than distinguishing between long and double.voidsetTimeFormat(DateFormatString value)Sets the format for time columns.StringtimeFormatTipText()Returns the tip time for this property.-
Methods inherited from class adams.data.io.output.AbstractFormattedSpreadSheetWriter
format, getDefaultNumberFormat, getDefaultUseSimpleNumberFormat, getLocale, getNumberFormat, localeTipText, numberFormatTipText, setLocale, setNumberFormat
-
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
getDefaultMissingValue, getMissingValue, missingValueTipText, setMissingValue
-
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriter
canCompress, doWrite, doWrite, encodingTipText, getAdditionalInformation, getDefaultFormatExtension, getEncoding, getWriters, initialize, isStopped, preWriteFile, reset, setEncoding, stopExecution, supportsCompressedOutput, write, write, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
Methods inherited from interface adams.data.io.output.SpreadSheetWriter
reset, write, write, write, write
-
Methods inherited from interface adams.core.Stoppable
stopExecution
-
Methods inherited from interface adams.core.StoppableWithFeedback
isStopped
-
-
-
-
Field Detail
-
m_ColumnWidth
protected BaseInteger[] m_ColumnWidth
the column width.
-
m_ActualColumnWidth
protected int[] m_ActualColumnWidth
the actual column widths.
-
m_NewLine
protected String m_NewLine
the new line.
-
m_DateFormat
protected DateFormatString m_DateFormat
the format string for the dates.
-
m_DateTimeFormat
protected DateFormatString m_DateTimeFormat
the format string for the date/times.
-
m_DateTimeMsecFormat
protected DateFormatString m_DateTimeMsecFormat
the format string for the date/times msec.
-
m_TimeFormat
protected DateFormatString m_TimeFormat
the format string for the times.
-
m_OnlyFloat
protected boolean m_OnlyFloat
whether to treat all numbers as float.
-
m_NoHeader
protected boolean m_NoHeader
whether to skip outputting the header.
-
m_NoBorder
protected boolean m_NoBorder
whether to skip outputting the border.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin 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:
getFormatDescriptionin interfaceSpreadSheetWriter- Specified by:
getFormatDescriptionin classAbstractSpreadSheetWriter- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceSpreadSheetWriter- Specified by:
getFormatExtensionsin classAbstractSpreadSheetWriter- Returns:
- the extension (without the dot!)
-
getCorrespondingReader
public SpreadSheetReader getCorrespondingReader()
Returns, if available, the corresponding reader.- Specified by:
getCorrespondingReaderin interfaceSpreadSheetWriter- Returns:
- the reader, null if none available
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractFormattedSpreadSheetWriter
-
setColumnWidth
public void setColumnWidth(BaseInteger[] value)
Sets the column width.- Parameters:
value- the width in characters
-
getColumnWidth
public BaseInteger[] getColumnWidth()
Returns the column width.- Returns:
- the width in characters
-
columnWidthTipText
public String columnWidthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNewLine
public void setNewLine(String value)
Sets the string to use as newline.- Parameters:
value- the character(s)
-
getNewLine
public String getNewLine()
Returns the string used as newline.- Returns:
- the character(s)
-
newLineTipText
public String newLineTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setDateFormat
public void setDateFormat(DateFormatString value)
Sets the format for date columns.- Parameters:
value- the format
-
getDateFormat
public DateFormatString getDateFormat()
Returns the format for date columns.- Returns:
- the format
-
dateFormatTipText
public String dateFormatTipText()
Returns the tip date for this property.- Returns:
- tip date for this property suitable for displaying in the gui
-
setDateTimeFormat
public void setDateTimeFormat(DateFormatString value)
Sets the format for date/time columns.- Parameters:
value- the format
-
getDateTimeFormat
public DateFormatString getDateTimeFormat()
Returns the format for date/time columns.- Returns:
- the format
-
dateTimeFormatTipText
public String dateTimeFormatTipText()
Returns the tip date/time for this property.- Returns:
- tip date for this property suitable for displaying in the gui
-
setDateTimeMsecFormat
public void setDateTimeMsecFormat(DateFormatString value)
Sets the format for date/time msec columns.- Parameters:
value- the format
-
getDateTimeMsecFormat
public DateFormatString getDateTimeMsecFormat()
Returns the format for date/time msec columns.- Returns:
- the format
-
dateTimeMsecFormatTipText
public String dateTimeMsecFormatTipText()
Returns the tip date/time for this property.- Returns:
- tip date for this property suitable for displaying in the gui
-
setTimeFormat
public void setTimeFormat(DateFormatString value)
Sets the format for time columns.- Parameters:
value- the format
-
getTimeFormat
public DateFormatString getTimeFormat()
Returns the format for time columns.- Returns:
- the format
-
timeFormatTipText
public String timeFormatTipText()
Returns the tip time for this property.- Returns:
- tip time for this property suitable for displaying in the gui
-
setOnlyFloat
public void setOnlyFloat(boolean value)
Sets whether to treat all numbers as float rather than distinguishing between long and double.- Parameters:
value- true if to treat all numbers as float
-
getOnlyFloat
public boolean getOnlyFloat()
Returns whether to treat all numbers as float rather than distinguishing between long and double.- Returns:
- true if all numbers are treated as float
-
onlyFloatTipText
public String onlyFloatTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNoHeader
public void setNoHeader(boolean value)
Sets whether to use a header or not.- Specified by:
setNoHeaderin interfaceNoHeaderSpreadSheetWriter- Parameters:
value- true if to skip header
-
getNoHeader
public boolean getNoHeader()
Returns whether to use a header or not.- Specified by:
getNoHeaderin interfaceNoHeaderSpreadSheetWriter- Returns:
- true if no header
-
noHeaderTipText
public String noHeaderTipText()
Returns the tip text for this property.- Specified by:
noHeaderTipTextin interfaceNoHeaderSpreadSheetWriter- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setNoBorder
public void setNoBorder(boolean value)
Sets whether to use a border or not.- Parameters:
value- true if to skip border
-
getNoBorder
public boolean getNoBorder()
Returns whether to use a border or not.- Returns:
- true if no border
-
noBorderTipText
public String noBorderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getOutputType
protected AbstractSpreadSheetWriter.OutputType getOutputType()
Returns how the data is written.- Specified by:
getOutputTypein classAbstractSpreadSheetWriter- Returns:
- the type
-
addSeparatorLine
protected void addSeparatorLine(SpreadSheet content, Writer writer) throws Exception
Adds a separator line to the output.- Parameters:
writer- the writer to add the line to- Throws:
Exception- if writing to writer fails
-
pad
protected String pad(int col, String s, boolean leftPad)
Pads a string either on the left or the right hand side with blanks. Shortens it if necessary.- Parameters:
col- the column to pads- the string to padleftPad- whether to pad on the left or right- Returns:
- the padded string
-
doWrite
protected boolean doWrite(SpreadSheet content, Writer writer)
Performs the actual writing. The caller must ensure that the writer gets closed.- Overrides:
doWritein classAbstractSpreadSheetWriter- Parameters:
content- the spreadsheet to writewriter- the writer to write the spreadsheet to- Returns:
- true if successfully written
-
-