public class Symbols extends Object implements Localized, Cloneable, Serializable
SQUARE_BRACKETS
and CURLY_BRACKETS
,
define the symbols for ISO 19162 compliant WKT formatting. Their properties are:
Users can create their own
Locale for number format: Locale.ROOT
Bracket symbols: [
…]
or(
…)
Note: the […]
brackets are common in referencing WKT, while the(…)
brackets are common in geometry WKT.Quote symbols: "
…"
Note: Apache SIS accepts also “…”
quotes for more readableString
literals in Java code, but this is non-standard.Sequence symbols: {
…}
Separator: ,
Symbols
instance for parsing or formatting a WKT with different symbols.WKTFormat.getSymbols()
,
WKTFormat.setSymbols(Symbols)
,
Serialized FormDefined in the sis-metadata
module
Modifier and Type | Field and Description |
---|---|
static Symbols |
CURLY_BRACKETS
A set of symbols with values between parentheses, like
DATUM("WGS84") . |
static Symbols |
SQUARE_BRACKETS
A set of symbols with values between square brackets, like
DATUM["WGS84"] . |
Constructor and Description |
---|
Symbols(Symbols symbols)
Creates a new set of WKT symbols initialized to a copy of the given symbols.
|
Modifier and Type | Method and Description |
---|---|
Symbols |
clone()
Returns a clone of this
Symbols . |
boolean |
containsAxis(CharSequence wkt)
Returns
true if the given WKT contains at least one instance of the AXIS[…] element. |
boolean |
containsElement(CharSequence wkt,
String element)
Returns
true if the given WKT contains at least one instance of the given element. |
boolean |
equals(Object other)
Compares this
Symbols with the given object for equality. |
int |
getCloseSequence()
Returns the character used for closing a sequence of values.
|
int |
getClosingBracket(int index)
Returns the closing bracket character at the given index.
|
int |
getClosingQuote(int index)
Returns the closing quote character at the given index.
|
static Symbols |
getDefault()
Returns the default set of symbols.
|
Locale |
getLocale()
Returns the locale for formatting dates and numbers.
|
int |
getNumPairedBrackets()
Returns the number of paired brackets.
|
int |
getNumPairedQuotes()
Returns the number of paired quotes.
|
int |
getOpeningBracket(int index)
Returns the opening bracket character at the given index.
|
int |
getOpeningQuote(int index)
Returns the opening quote character at the given index.
|
int |
getOpenSequence()
Returns the character used for opening a sequence of values.
|
String |
getSeparator()
Returns the string used as a separator in a list of values.
|
int |
hashCode()
Returns a hash code value for this object.
|
void |
setLocale(Locale locale)
Sets the locale of decimal format symbols or other symbols.
|
void |
setPairedBrackets(String preferred,
String... alternatives)
Sets the opening and closing brackets to the given pairs.
|
void |
setPairedQuotes(String preferred,
String... alternatives)
Sets the opening and closing quotes to the given pairs.
|
void |
setSeparator(String separator)
Sets the string to use as a separator in a list of values.
|
void |
setSequenceBrackets(int openSequence,
int closeSequence)
Sets the characters used for opening and closing a sequence of values.
|
public static final Symbols SQUARE_BRACKETS
DATUM["WGS84"]
.
This instance defines:
Locale.ROOT
for decimal format symbols.DATUM["WGS84"]
, but accepting also curly brackets as in
DATUM("WGS84")
. Both are legal WKT.'"'
) by default, but accepting also “…” quotes
for more readable String
constants in Java code.", "
).public static final Symbols CURLY_BRACKETS
DATUM("WGS84")
.
This instance is identical to SQUARE_BRACKETS
except that the default
brackets are the curly ones instead than the square ones (but both are still
accepted at parsing time).
This format is rare with referencing objects but common with geometry objects.
public Symbols(Symbols symbols)
symbols
- The symbols to copy.public static Symbols getDefault()
SQUARE_BRACKETS
.public final Locale getLocale()
Locale.ROOT
.
Symbols
locale and WKTFormat
localeWKTFormat.getLocale(Locale.DISPLAY)
property specifies the language to use when
formatting InternationalString
instances and can be set to any value.
On the contrary, the Locale
property of this Symbols
class controls
the decimal format symbols and is very rarely set to an other locale than Locale.ROOT
.getLocale
in interface Localized
CompoundFormat.getLocale()
public void setLocale(Locale locale)
locale
- The new symbols locale.public final int getNumPairedBrackets()
[…]
and (…)
bracket pairs, then this method returns 2.getOpeningBracket(int)
,
getClosingBracket(int)
public final int getOpeningBracket(int index)
index
- Index of the opening bracket to get, from 0 to getNumPairedBrackets()
exclusive.IndexOutOfBoundsException
- if the given index is out of bounds.public final int getClosingBracket(int index)
index
- Index of the closing bracket to get, from 0 to getNumPairedBrackets()
exclusive.IndexOutOfBoundsException
- if the given index is out of bounds.public void setPairedBrackets(String preferred, String... alternatives)
symbols.setPairedBrackets("()", "[]");
preferred
- The preferred pair of opening and closing quotes, used at formatting time.alternatives
- Alternative pairs of opening and closing quotes accepted at parsing time.public final int getNumPairedQuotes()
"…"
and “…”
quote pairs, then this method returns 2.getOpeningQuote(int)
,
getClosingQuote(int)
public final int getOpeningQuote(int index)
'"'
.
All other index are for optional quotes accepted at parsing time.index
- Index of the opening quote to get, from 0 to getNumPairedQuotes()
exclusive.IndexOutOfBoundsException
- if the given index is out of bounds.public final int getClosingQuote(int index)
'"'
.
All other index are for optional quotes accepted at parsing time.index
- Index of the closing quote to get, from 0 to getNumPairedQuotes()
exclusive.IndexOutOfBoundsException
- if the given index is out of bounds.public void setPairedQuotes(String preferred, String... alternatives)
String
constants in Java code), but still accept the standard "…" quotation marks
at parsing time:
symbols.setPairedQuotes("“”", "\"\"");
preferred
- The preferred pair of opening and closing quotes, used at formatting time.alternatives
- Alternative pairs of opening and closing quotes accepted at parsing time.public final int getOpenSequence()
'{'
.public final int getCloseSequence()
'}'
.public void setSequenceBrackets(int openSequence, int closeSequence)
openSequence
- The character for opening a sequence of values, as a Unicode code point.closeSequence
- The character for closing a sequence of values, as a Unicode code point.public final String getSeparator()
", "
,
but may be different if a non-English locale is used for formatting numbers.public void setSeparator(String separator)
separator
- The new string to use as a separator in a list of values.public boolean containsElement(CharSequence wkt, String element)
true
if the given WKT contains at least one instance of the given element.
Invoking this method is equivalent to invoking String.contains(CharSequence)
except
for the following:
wkt
- The WKT to inspect.element
- The element to search for.true
if the given WKT contains at least one instance of the given element.public boolean containsAxis(CharSequence wkt)
true
if the given WKT contains at least one instance of the AXIS[…]
element.
Invoking this method is equivalent to invoking
containsElement(wkt, "AXIS")
.
AXIS[…]
elements in a WKT is an indication that the encoded
object may not be understood as intended by some external softwares.wkt
- The WKT to inspect.true
if the given WKT contains at least one instance of the AXIS[…]
element.public Symbols clone()
Symbols
.public boolean equals(Object other)
Symbols
with the given object for equality.Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.