Class PropertyFormat

java.lang.Object
org.apache.sis.io.LineAppender
org.apache.sis.internal.util.PropertyFormat
All Implemented Interfaces:
Flushable, Appendable, Localized

public abstract class PropertyFormat extends LineAppender implements Localized
Creates string representation of property values of unknown type. Tabulations are replaced by spaces, and line feeds can optionally be replaced by the Pilcrow character. Subclasses need to override Localized.getLocale(), and should also override toString(Object).
Since:
1.1
Version:
1.2
Author:
Martin Desruisseaux (Geomatys)
  • Field Details

    • columnFormat

      protected transient Format columnFormat
      The format for the column in process of being written. This is a format to use for the column as a whole. This field is updated for every new column to write. May be null if the format is unspecified.
    • out

      protected final Appendable out
      The underlying character output stream or buffer.
  • Constructor Details

    • PropertyFormat

      protected PropertyFormat(Appendable out)
      Creates a new instance which will write to the given appendable.
      Parameters:
      out - where to format the objects.
  • Method Details

    • appendValue

      public final void appendValue(Object value) throws IOException
      Appends a textual representation of the given value.
      Parameters:
      value - the value to format (may be null).
      Throws:
      IOException - if an error occurred while writing the value.
    • toString

      protected String toString(Object value)
      Invoked by PropertyFormat for formatting a value which has not been recognized as one of the types to be handled in a special way. Some of the types handled in a special way are InternationalString,
      invalid reference
      ControlledVocabulary
      , Enum, Type, Locale, TimeZone, Charset, Currency, Record, Iterable and arrays. Other types should be handled by this method. In particular, Number, Date and Angle are not handled by default by this PropertyFormat class and should be handled here.
      Parameters:
      value - the value to format (never null).
      Returns:
      the formatted value.
    • freeText

      protected String freeText(String text)
      Invoked after formatting a text that could be anything. It current version, it includes all kinds of CharSequence including InternationalString, together with Object.toString() values computed by the default toString(Object) implementation. The default freeText(…) implementation removes white space and control characters. Subclasses can override for example for making a text shorter.
      Parameters:
      text - the free text, or null.
      Returns:
      the text to append.
    • append

      public Appendable append(CharSequence sequence) throws IOException
      Appends the specified character sequence. The default implementation delegates to Appendable.append(CharSequence, int, int).
      Specified by:
      append in interface Appendable
      Parameters:
      sequence - the character sequence to append, or null.
      Returns:
      a reference to this Appendable.
      Throws:
      IOException - if an I/O error occurred.
    • toString

      public String toString()
      Returns the content of this Appendable as a string if possible, or the localized "Unavailable content" string otherwise.
      Overrides:
      toString in class Object
      Returns:
      the content of this Appendable, or a localized message for unavailable content.
      See Also: