Package org.apache.sis.internal.util
Class PropertyFormat
java.lang.Object
org.apache.sis.io.Appender
org.apache.sis.io.LineAppender
org.apache.sis.internal.util.PropertyFormat
- All Implemented Interfaces:
Flushable,Appendable,Localized
- Direct Known Subclasses:
TreeTableFormat.Writer
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPropertyFormat(Appendable out) Creates a new instance which will write to the given appendable. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendCollection(Iterable<?> values, boolean recursive) Writes the values of the given collection.private <V> voidappendCompound(CompoundFormat<V> format, Object value) Workaround for the inability to define the variable<V>locally.private voidappendName(org.opengis.util.GenericName name) Localizes the given name in the display locale, or formats "(Unnamed)" if no localized value is found.final voidappendValue(Object value) Appends a textual representation of the given value.private voidappendValue(Object value, boolean recursive) Appends a textual representation of the given value, with a check for nested collections.protected StringInvoked after formatting a text that could be anything.protected StringInvoked byPropertyFormatfor formatting a value which has not been recognized as one of the types to be handled in a special way.Methods inherited from class org.apache.sis.io.LineAppender
append, append, clear, flush, getLineSeparator, getMaximalLineLength, getTabulationWidth, isTabulationExpanded, onLineBegin, setLineSeparator, setMaximalLineLength, setTabulationExpanded, setTabulationWidth
-
Field Details
-
MISSING
The string to insert for missing values.- See Also:
-
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 benullif the format is unspecified.
-
-
Constructor Details
-
PropertyFormat
Creates a new instance which will write to the given appendable.- Parameters:
out- where to format the objects.
-
-
Method Details
-
appendValue
Appends a textual representation of the given value.- Parameters:
value- the value to format (may benull).- Throws:
IOException- if an error occurred while writing the value.
-
appendValue
Appends a textual representation of the given value, with a check for nested collections.- Parameters:
value- the value to format (may benull).recursive-trueif this method is invoking itself for writing collection values.- Throws:
IOException
-
toString
Invoked byPropertyFormatfor 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 areInternationalString,ControlledVocabulary,Enum,Type,Locale,TimeZone,Charset,Currency,Record,Iterableand arrays. Other types should be handled by this method. In particular,Number,DateandAngleare not handled by default by thisPropertyFormatclass and should be handled here.- Parameters:
value- the value to format (nevernull).- Returns:
- the formatted value.
-
freeText
Invoked after formatting a text that could be anything. It current version, it includes all kinds ofCharSequenceincludingInternationalString, together withObject.toString()values computed by the defaulttoString(Object)implementation. The defaultfreeText(…)implementation removes white space and control characters. Subclasses can override for example for making a text shorter.- Parameters:
text- the free text, ornull.- Returns:
- the text to append.
-
appendCollection
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
Localizes the given name in the display locale, or formats "(Unnamed)" if no localized value is found.- Throws:
IOException
-