The prefix and suffix "{" and "}" and the separator "; " can be replaced by any user-defined strings. The number format for components can be configured.
White space is ignored at parse time, even if it is in the prefix, suffix or separator specifications. So even if the default separator does include a space character that is used at format time, both input string "{1;1;1}" and " { 1 ; 1 ; 1 } " will be parsed without error and the same vector will be returned. In the second case, however, the parse position after parsing will be just after the closing curly brace, i.e. just before the trailing space.
Note
using "," as a separator may interfere with the grouping separator
of the default NumberFormat for the current locale. Thus it is advised
to use a NumberFormat instance with disabled grouping in such a case.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | DEFAULT_PREFIX
The default prefix: "{". |
| public static final String | DEFAULT_SEPARATOR
The default separator: ", ". |
| public static final String | DEFAULT_SUFFIX
The default suffix: "}". |
| private final NumberFormat | format
The format used for components. |
| private final String | prefix
Prefix. |
| private final String | separator
Separator. |
| private final String | suffix
Suffix. |
| private final String | trimmedPrefix
Trimmed prefix. |
| private final String | trimmedSeparator
Trimmed separator. |
| private final String | trimmedSuffix
Trimmed suffix. |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | VectorFormat(final NumberFormat
the custom format for components. format)Create an instance with a custom number format for components. |
| protected | VectorFormat(final String
prefix to use instead of the default "{" prefix, final String suffix to use instead of the default "}" suffix, final String separator to use instead of the default "; " separator)Create an instance with custom prefix, suffix and separator. |
| protected | VectorFormat(final String
prefix to use instead of the default "{" prefix, final String suffix to use instead of the default "}" suffix, final String separator to use instead of the default "; " separator, final NumberFormat the custom format for components. format)Create an instance with custom prefix, suffix, separator and format for components. |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public abstract StringBuffer | Returns: the value passed in as toAppendTo.the object to format. vector, StringBuffer where the text is to be appended toAppendTo, FieldPosition On input: an alignment field, if desired. On output: the
offsets of the alignment field pos)Formats a |
| protected StringBuffer | Returns: the value passed in as toAppendTo.where the text is to be appended toAppendTo, FieldPosition On input: an alignment field, if desired. On output: the
offsets of the alignment field pos, double... coordinates of the object to format. coordinates)Formats the coordinates of a |
| public static Locale[] | Returns: available point/vector format locales.Get the set of locales for which point/vector formats are available. |
| public NumberFormat | |
| public String | |
| public String | |
| public String | |
| public abstract Vector | |
| public abstract Vector | Returns: the parsedVector object.the string to parse source, ParsePosition input/output parsing parameter. pos)Parses a string to produce a |
| protected double[] | Returns: coordinates array.dimension of the space dimension, String the string to parse source, ParsePosition input/output parsing parameter. pos)Parses a string to produce an array of coordinates. |
| DEFAULT_PREFIX | back to summary |
|---|---|
| public static final String DEFAULT_PREFIX The default prefix: "{". | |
| DEFAULT_SEPARATOR | back to summary |
|---|---|
| public static final String DEFAULT_SEPARATOR The default separator: ", ". | |
| DEFAULT_SUFFIX | back to summary |
|---|---|
| public static final String DEFAULT_SUFFIX The default suffix: "}". | |
| format | back to summary |
|---|---|
| private final NumberFormat format The format used for components. | |
| prefix | back to summary |
|---|---|
| private final String prefix Prefix. | |
| separator | back to summary |
|---|---|
| private final String separator Separator. | |
| suffix | back to summary |
|---|---|
| private final String suffix Suffix. | |
| trimmedPrefix | back to summary |
|---|---|
| private final String trimmedPrefix Trimmed prefix. | |
| trimmedSeparator | back to summary |
|---|---|
| private final String trimmedSeparator Trimmed separator. | |
| trimmedSuffix | back to summary |
|---|---|
| private final String trimmedSuffix Trimmed suffix. | |
| VectorFormat | back to summary |
|---|---|
| protected VectorFormat() Create an instance with default settings. The instance uses the default prefix, suffix and separator: "{", "}", and "; " and the default number format for components. | |
| VectorFormat | back to summary |
|---|---|
| protected VectorFormat(final NumberFormat format) Create an instance with a custom number format for components.
| |
| VectorFormat | back to summary |
|---|---|
| protected VectorFormat(final String prefix, final String suffix, final String separator) Create an instance with custom prefix, suffix and separator. | |
| VectorFormat | back to summary |
|---|---|
| protected VectorFormat(final String prefix, final String suffix, final String separator, final NumberFormat format) Create an instance with custom prefix, suffix, separator and format for components.
| |
| format | back to summary |
|---|---|
| public String format(Vector<S> vector) Formats a | |
| format | back to summary |
|---|---|
| public abstract StringBuffer format(Vector<S> vector, StringBuffer toAppendTo, FieldPosition pos) Formats a
| |
| format | back to summary |
|---|---|
| protected StringBuffer format(StringBuffer toAppendTo, FieldPosition pos, double... coordinates) Formats the coordinates of a
| |
| getAvailableLocales | back to summary |
|---|---|
| public static Locale[] getAvailableLocales() Get the set of locales for which point/vector formats are available. This is the same set as the
| |
| getFormat | back to summary |
|---|---|
| public NumberFormat getFormat() Get the components format.
| |
| getPrefix | back to summary |
|---|---|
| public String getPrefix() Get the format prefix.
| |
| getSeparator | back to summary |
|---|---|
| public String getSeparator() Get the format separator between components.
| |
| getSuffix | back to summary |
|---|---|
| public String getSuffix() Get the format suffix.
| |
| parse | back to summary |
|---|---|
| public abstract Vector Parses a string to produce a
| |
| parse | back to summary |
|---|---|
| public abstract Vector Parses a string to produce a
| |
| parseCoordinates | back to summary |
|---|---|
| protected double[] parseCoordinates(int dimension, String source, ParsePosition pos) Parses a string to produce an array of coordinates.
| |