public abstract class FormattableObject extends Object
WKTFormat
checks for this class at formatting time for each element to format.
When a FormattableObject
element is found, its formatTo(Formatter)
method
is invoked for allowing the element to control its formatting.
This class provides two methods for getting a default Well Known Text representation of this object:
toWKT()
tries to return a strictly compliant WKT or throws UnformattableObjectException
if this object contains elements not defined by the ISO 19162 standard.toString()
returns a WKT with some redundant information omitted and some constraints relaxed.
This method never throw UnformattableObjectException
;
it will rather use non-standard representation if necessary.print()
method is provided, which is roughly equivalent to
System.out.println(this)
except that syntax coloring is automatically applied
if the terminal seems to support the ANSI escape codes.
toWKT()
will throw a UnformattableObjectException
.toString()
will ignore the problem and uses non-standard elements if needed.print()
will show the non-standard elements in red if syntax coloring is enabled.Defined in the sis-metadata
module
Modifier | Constructor and Description |
---|---|
protected |
FormattableObject()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract String |
formatTo(Formatter formatter)
Formats the inner part of this Well Known Text (WKT) element into the given formatter.
|
void |
print()
Prints a string representation of this object to the standard output stream.
|
String |
toString()
Returns a Well Known Text (WKT) or an alternative text representation for this object.
|
String |
toString(Convention convention)
Returns a Well Known Text (WKT) for this object using the specified convention.
|
String |
toWKT()
Returns a strictly compliant Well Known Text (WKT) using the default convention,
symbols and indentation.
|
public String toWKT() throws UnformattableObjectException
UnformattableObjectException
.
By default this method formats this object according the Convention.WKT2
rules.
UnformattableObjectException
- if this object can not be formatted as a standard WKT.IdentifiedObject.toWKT()
public String toString()
By default this method formats this object according the Convention.WKT2_SIMPLIFIED
rules,
except that Unicode characters are kept as-is (they are not converted to ASCII).
Consequently the WKT is not guaranteed to be ISO 19162 compliant.
For stricter conformance, use toWKT()
instead.
public String toString(Convention convention)
For stricter conformance to ISO 19162 standard, use toWKT()
or WKTFormat
instead.
convention
- the WKT convention to use.@Debug public void print()
This is a convenience method for debugging purpose and for console applications.
protected abstract String formatTo(Formatter formatter)
WKTFormat
when a formattable element is found.
Keywords, opening and closing brackets shall not be formatted here.
For example if this formattable element is for a GeodeticCRS[…]
element,
then this method shall write the content starting at the insertion point shown below:
GeodeticCRS[ ] ↑ (insertion point)
Formatter.setInvalidWKT(…)
methods.
Alternatively, the implementation may also have no WKT keyword for this object.
This happen frequently when an abstract class defines a base implementation,
while the keyword needs to be defined by the concrete subclasses.
In such case, the method in the abstract class shall return null
.
formatter
- the formatter where to format the inner content of this WKT element.null
if unknown.toWKT()
,
toString()
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.