Top Description Fields Constructors Methods
org.apache.commons.math3.geometry.euclidean.oned

public Class Vector1DFormat

extends VectorFormat<Euclidean1D>
Class Inheritance
Imports
java.text.FieldPosition, .NumberFormat, .ParsePosition, java.util.Locale, org.apache.commons.math3.exception.MathParseException, org.apache.commons.math3.geometry.Vector, .VectorFormat, org.apache.commons.math3.util.CompositeFormat

Formats a 1D vector in components list format "{x}".

The prefix and suffix "{" and "}" 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}" and " { 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.

Since
3.0

Field Summary

Inherited from org.apache.commons.math3.geometry.VectorFormat:
DEFAULT_PREFIXDEFAULT_SEPARATORDEFAULT_SUFFIX

Constructor Summary

AccessConstructor and Description
public
Vector1DFormat()

Create an instance with default settings.

public
Vector1DFormat(final NumberFormat
the custom format for components.
format
)

Create an instance with a custom number format for components.

public
Vector1DFormat(final String
prefix to use instead of the default "{"
prefix
,
final String
suffix to use instead of the default "}"
suffix
)

Create an instance with custom prefix, suffix and separator.

public
Vector1DFormat(final String
prefix to use instead of the default "{"
prefix
,
final String
suffix to use instead of the default "}"
suffix
,
final NumberFormat
the custom format for components.
format
)

Create an instance with custom prefix, suffix, separator and format for components.

Method Summary

Modifier and TypeMethod and Description
public StringBuffer
format(final Vector<Euclidean1D>
the object to format.
vector
,
final StringBuffer
where the text is to be appended
toAppendTo
,
final FieldPosition
On input: an alignment field, if desired. On output: the offsets of the alignment field
pos
)

Implements abstract org.apache.commons.math3.geometry.VectorFormat.format.

Formats a Vector object to produce a string.

public static Vector1DFormat

Returns:

the default 1D vector format.
getInstance
()

Returns the default 1D vector format for the current locale.

public static Vector1DFormat

Returns:

the 1D vector format specific to the given locale.
getInstance
(final Locale
the specific locale used by the format.
locale
)

Returns the default 1D vector format for the given locale.

public Vector1D
parse(final String
the string to parse
source
)

Implements abstract org.apache.commons.math3.geometry.VectorFormat.parse.

Parses a string to produce a Vector object.

public Vector1D
parse(final String
the string to parse
source
,
final ParsePosition
input/output parsing parameter.
pos
)

Implements abstract org.apache.commons.math3.geometry.VectorFormat.parse.

Parses a string to produce a Vector object.

Inherited from org.apache.commons.math3.geometry.VectorFormat:
formatformatgetAvailableLocalesgetFormatgetPrefixgetSeparatorgetSuffixparseCoordinates

Constructor Detail

Vector1DFormatback to summary
public Vector1DFormat()

Create an instance with default settings.

The instance uses the default prefix, suffix and separator: "{", "}", and "; " and the default number format for components.

Vector1DFormatback to summary
public Vector1DFormat(final NumberFormat format)

Create an instance with a custom number format for components.

Parameters
format:NumberFormat

the custom format for components.

Vector1DFormatback to summary
public Vector1DFormat(final String prefix, final String suffix)

Create an instance with custom prefix, suffix and separator.

Parameters
prefix:String

prefix to use instead of the default "{"

suffix:String

suffix to use instead of the default "}"

Vector1DFormatback to summary
public Vector1DFormat(final String prefix, final String suffix, final NumberFormat format)

Create an instance with custom prefix, suffix, separator and format for components.

Parameters
prefix:String

prefix to use instead of the default "{"

suffix:String

suffix to use instead of the default "}"

format:NumberFormat

the custom format for components.

Method Detail

formatback to summary
public StringBuffer format(final Vector<Euclidean1D> vector, final StringBuffer toAppendTo, final FieldPosition pos)

Implements abstract org.apache.commons.math3.geometry.VectorFormat.format.

Doc from org.apache.commons.math3.geometry.VectorFormat.format.

Formats a Vector object to produce a string.

Parameters
vector:Vector<Euclidean1D>

the object to format.

toAppendTo:StringBuffer

where the text is to be appended

pos:FieldPosition

On input: an alignment field, if desired. On output: the offsets of the alignment field

Returns:StringBuffer

the value passed in as toAppendTo.

Annotations
@Override
getInstanceback to summary
public static Vector1DFormat getInstance()

Returns the default 1D vector format for the current locale.

Returns:Vector1DFormat

the default 1D vector format.

getInstanceback to summary
public static Vector1DFormat getInstance(final Locale locale)

Returns the default 1D vector format for the given locale.

Parameters
locale:Locale

the specific locale used by the format.

Returns:Vector1DFormat

the 1D vector format specific to the given locale.

parseback to summary
public Vector1D parse(final String source) throws MathParseException

Implements abstract org.apache.commons.math3.geometry.VectorFormat.parse.

Doc from org.apache.commons.math3.geometry.VectorFormat.parse.

Parses a string to produce a Vector object.

Parameters
source:String

the string to parse

Returns:Vector1D

the parsed Vector object.

Annotations
@Override
Exceptions
MathParseException:
if the beginning of the specified string cannot be parsed.
parseback to summary
public Vector1D parse(final String source, final ParsePosition pos)

Implements abstract org.apache.commons.math3.geometry.VectorFormat.parse.

Doc from org.apache.commons.math3.geometry.VectorFormat.parse.

Parses a string to produce a Vector object.

Parameters
source:String

the string to parse

pos:ParsePosition

input/output parsing parameter.

Returns:Vector1D

the parsed Vector object.

Annotations
@Override