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

public Class Vector3DFormat

extends VectorFormat<Euclidean3D>
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 3D vector in components list format "{x; y; z}".

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.

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
Vector3DFormat()

Create an instance with default settings.

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

Create an instance with a custom number format for components.

public
Vector3DFormat(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.

public
Vector3DFormat(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.

Method Summary

Modifier and TypeMethod and Description
public StringBuffer

Returns:

the value passed in as toAppendTo.
format
(final Vector<Euclidean3D>
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 Vector3D object to produce a string.

public static Vector3DFormat

Returns:

the default 3D vector format.
getInstance
()

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

public static Vector3DFormat

Returns:

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

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

public Vector3D

Returns:

the parsed Vector3D object.
parse
(final String
the string to parse
source
)

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

Parses a string to produce a Vector3D object.

public Vector3D

Returns:

the parsed Vector3D object.
parse
(final String
the string to parse
source
,
final ParsePosition
input/ouput parsing parameter.
pos
)

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

Parses a string to produce a Vector3D object.

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

Constructor Detail

Vector3DFormatback to summary
public Vector3DFormat()

Create an instance with default settings.

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

Vector3DFormatback to summary
public Vector3DFormat(final NumberFormat format)

Create an instance with a custom number format for components.

Parameters
format:NumberFormat

the custom format for components.

Vector3DFormatback to summary
public Vector3DFormat(final String prefix, final String suffix, final String separator)

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 "}"

separator:String

separator to use instead of the default "; "

Vector3DFormatback to summary
public Vector3DFormat(final String prefix, final String suffix, final String separator, 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 "}"

separator:String

separator to use instead of the default "; "

format:NumberFormat

the custom format for components.

Method Detail

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

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

Formats a Vector3D object to produce a string.

Parameters
vector:Vector<Euclidean3D>

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 Vector3DFormat getInstance()

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

Returns:Vector3DFormat

the default 3D vector format.

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

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

Parameters
locale:Locale

the specific locale used by the format.

Returns:Vector3DFormat

the 3D vector format specific to the given locale.

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

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

Parses a string to produce a Vector3D object.

Parameters
source:String

the string to parse

Returns:Vector3D

the parsed Vector3D object.

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

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

Parses a string to produce a Vector3D object.

Parameters
source:String

the string to parse

pos:ParsePosition

input/ouput parsing parameter.

Returns:Vector3D

the parsed Vector3D object.

Annotations
@Override