Class 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
    • 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.
    • Constructor Detail

      • FixedTabularSpreadSheetWriter

        public FixedTabularSpreadSheetWriter()
    • Method Detail

      • 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:
        setNoHeader in interface NoHeaderSpreadSheetWriter
        Parameters:
        value - true if to skip header
      • noHeaderTipText

        public String noHeaderTipText()
        Returns the tip text for this property.
        Specified by:
        noHeaderTipText in interface NoHeaderSpreadSheetWriter
        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
      • 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 pad
        s - the string to pad
        leftPad - 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:
        doWrite in class AbstractSpreadSheetWriter
        Parameters:
        content - the spreadsheet to write
        writer - the writer to write the spreadsheet to
        Returns:
        true if successfully written