- All Implemented Interfaces:
Serializable
,Cloneable
,Localized
Formats parameter descriptors or
parameter values in a tabular format.
This format assumes a monospaced font and an encoding supporting drawing box
characters (e.g. UTF-8).
This class can format parameters with different levels of verbosity, specified by the ParameterFormat.ContentLevel
property. The content level controls whether the formatter should write all names and aliases (at the cost of
multi-line rows), or to pickup one name per parameter for a more compact table. See ParameterFormat.ContentLevel
javadoc for output examples.
Example
The Mercator (variant A) example given inDefaultParameterDescriptorGroup
javadoc
will be formatted by default as below:
EPSG: Mercator (variant A) ┌────────────────────────────────┬────────┬────────────┬───────────────┬───────────────┐ │ Name (EPSG) │ Type │ Obligation │ Value domain │ Default value │ ├────────────────────────────────┼────────┼────────────┼───────────────┼───────────────┤ │ Latitude of natural origin │ Double │ Mandatory │ [-80 … 84]° │ 0.0° │ │ Longitude of natural origin │ Double │ Mandatory │ [-180 … 180]° │ 0.0° │ │ Scale factor at natural origin │ Double │ Mandatory │ (0 … ∞) │ 1.0 │ │ False easting │ Double │ Mandatory │ (−∞ … ∞) m │ 0.0 m │ │ False northing │ Double │ Mandatory │ (−∞ … ∞) m │ 0.0 m │ └────────────────────────────────┴────────┴────────────┴───────────────┴───────────────┘
Input types
The kinds of objects accepted by this formatter are:Class | Remarks |
---|---|
ParameterValueGroup | Default values column is replaced by a column of the actual values. |
ParameterDescriptorGroup | Table caption is the parameter group name. |
OperationMethod | Table caption is the method name (not necessarily the same than parameter group name). |
IdentifiedObject[] | Accepted only for ParameterFormat.ContentLevel.NAME_SUMMARY . |
Limitations
- The current implementation can only format features — parsing is not yet implemented.
ParameterFormat
, like mostjava.text.Format
subclasses, is not thread-safe.
- Since:
- 0.4
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The amount of information to include in the table formatted byParameterFormat
.Nested classes/interfaces inherited from class Format
Format.Field
-
Field Summary
Fields inherited from class TabularFormat
beforeFill, columnSeparator, fillCharacter, lineSeparator, omitTrailingNulls
-
Constructor Summary
ConstructorDescriptionCreates a new formatter for the default locale and timezone.ParameterFormat
(Locale locale, TimeZone timezone) Creates a new formatter for the given locale and timezone. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this format.void
format
(Object object, Appendable toAppendTo) Formats the given object to the given stream of buffer.Returns the colors for an output on X3.64 compatible terminal, ornull
if none.Returns the amount of information to put in the table.getLocale
(Locale.Category category) Returns the locale for the given category.String[]
Returns the code spaces of names, aliases and identifiers to show, ornull
if there is no restriction.Returns the type of objects formatted by this class.parse
(CharSequence text, ParsePosition pos) Not yet supported.void
setColors
(Colors colors) Sets the colors for an output on X3.64 compatible terminal.void
Sets the amount of information to put in the table.void
setPreferredCodespaces
(String... codespaces) Filters names, aliases and identifiers by their code spaces.Methods inherited from class TabularFormat
getColumnSeparatorMatcher, getColumnSeparatorPattern, getLineSeparator, setColumnSeparatorPattern, setLineSeparator
Methods inherited from class CompoundFormat
createFormat, format, getFormat, getLocale, getTimeZone, parseObject, parseObject
Methods inherited from class Format
format, formatToCharacterIterator
-
Constructor Details
-
ParameterFormat
public ParameterFormat()Creates a new formatter for the default locale and timezone. -
ParameterFormat
Creates a new formatter for the given locale and timezone.- Parameters:
locale
- the locale, ornull
forLocale.ROOT
.timezone
- the timezone, ornull
for UTC.
-
-
Method Details
-
getValueType
Returns the type of objects formatted by this class. This method has to returnObject.class
since it is the only common parent to all object types accepted by this formatter.- Specified by:
getValueType
in classCompoundFormat<Object>
- Returns:
Object.class
-
getLocale
Returns the locale for the given category.Locale.Category.FORMAT
specifies the locale to use for values.Locale.Category.DISPLAY
specifies the locale to use for labels.
- Overrides:
getLocale
in classCompoundFormat<Object>
- Parameters:
category
- the category for which a locale is desired.- Returns:
- the locale for the given category (never
null
).
-
getContentLevel
Returns the amount of information to put in the table. The default value isParameterFormat.ContentLevel.BRIEF
.- Returns:
- the table content.
-
setContentLevel
Sets the amount of information to put in the table.- Parameters:
level
- the amount of information to put in the table.
-
getPreferredCodespaces
Returns the code spaces of names, aliases and identifiers to show, ornull
if there is no restriction. This method returns the sequence specified by the last call tosetPreferredCodespaces(String[])
, without duplicated values.The default value is
null
.- Returns:
- the code spaces of names and identifiers to show, or
null
if no restriction.
-
setPreferredCodespaces
Filters names, aliases and identifiers by their code spaces. If the given array is non-null, then the only names, aliases and identifiers to be formatted are those having aReferenceIdentifier.getCodeSpace()
,ScopedName.head()
orGenericName.scope()
value in the given list, unless no name or alias matches this criterion.- Parameters:
codespaces
- the preferred code spaces of names, aliases and identifiers to format, ornull
for accepting all of them. Some typical values are"EPSG"
,"OGC"
or"GeoTIFF"
.
-
getColors
Returns the colors for an output on X3.64 compatible terminal, ornull
if none. The default value isnull
.- Returns:
- the colors for an output on X3.64 compatible terminal, or
null
if none.
-
setColors
Sets the colors for an output on X3.64 compatible terminal.- Parameters:
colors
- the colors for an output on X3.64 compatible terminal, ornull
if none.
-
format
Formats the given object to the given stream of buffer. The object may be an instance of any of the following types:- Specified by:
format
in classCompoundFormat<Object>
- Parameters:
object
- the object to format.toAppendTo
- where to format the object.- Throws:
IOException
- if an error occurred while writing to the given appendable.
-
parse
Not yet supported.- Specified by:
parse
in classCompoundFormat<Object>
- Parameters:
text
- the character sequence for the object to parse.pos
- the position where to start the parsing. On return, the position where the parsing stopped or where an error occurred.- Returns:
- currently never return.
- Throws:
ParseException
- currently always thrown.
-
clone
Returns a clone of this format.- Overrides:
clone
in classTabularFormat<Object>
- Returns:
- a clone of this format.
-