Class PropertyFormat

All Implemented Interfaces:
Flushable, Appendable, Localized
Direct Known Subclasses:
TreeTableFormat.Writer

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
  • Field Details

    • MISSING

      private static final String MISSING
      The string to insert for missing values.
      See Also:
    • 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.
  • 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.
    • appendValue

      private void appendValue(Object value, boolean recursive) throws IOException
      Appends a textual representation of the given value, with a check for nested collections.
      Parameters:
      value - the value to format (may be null).
      recursive - true if this method is invoking itself for writing collection values.
      Throws:
      IOException
    • 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.
    • appendCollection

      private void appendCollection(Iterable<?> values, boolean recursive) throws IOException
      Writes the values of the given collection. A maximum of 10 values will be written. If the collection contains other collections, the other collections will not be written recursively.
      Throws:
      IOException
    • appendCompound

      @Workaround(library="JDK", version="1.7") private <V> void appendCompound(CompoundFormat<V> format, Object value) throws IOException
      Workaround for the inability to define the variable <V> locally.
      Throws:
      IOException
    • appendName

      private void appendName(org.opengis.util.GenericName name) throws IOException
      Localizes the given name in the display locale, or formats "(Unnamed)" if no localized value is found.
      Throws:
      IOException