Top Description Constructors Methods
org.apache.commons.math3.util

public Class CompositeFormat

extends Object
Class Inheritance
Imports
java.text.FieldPosition, .NumberFormat, .ParsePosition, java.util.Locale

Base class for formatters of composite objects (complex numbers, vectors ...).

Constructor Summary

AccessConstructor and Description
private
CompositeFormat()

Class contains only static methods.

Method Summary

Modifier and TypeMethod and Description
public static StringBuffer

Returns:

the value passed in as toAppendTo.
formatDouble
(final double
the double to format.
value
,
final NumberFormat
the format used.
format
,
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
)

Formats a double value to produce a string.

public static NumberFormat

Returns:

the default number format.
getDefaultNumberFormat
()

Create a default number format.

public static NumberFormat

Returns:

the default number format specific to the given locale.
getDefaultNumberFormat
(final Locale
the specific locale used by the format.
locale
)

Create a default number format.

public static void
parseAndIgnoreWhitespace(final String
the string to parse
source
,
final ParsePosition
input/output parsing parameter. On output, pos holds the index of the next non-whitespace character.
pos
)

Parses source until a non-whitespace character is found.

public static boolean

Returns:

true if the expected string was there
parseFixedstring
(final String
the string to parse
source
,
final String
expected string
expected
,
final ParsePosition
input/output parsing parameter.
pos
)

Parse source for an expected fixed string.

public static char

Returns:

the first non-whitespace character.
parseNextCharacter
(final String
the string to parse
source
,
final ParsePosition
input/output parsing parameter.
pos
)

Parses source until a non-whitespace character is found.

private static Number

Returns:

the special number.
parseNumber
(final String
the string to parse
source
,
final double
the special value to parse.
value
,
final ParsePosition
input/output parsing parameter.
pos
)

Parses source for special double values.

public static Number

Returns:

the parsed number.
parseNumber
(final String
the string to parse
source
,
final NumberFormat
the number format used to parse normal, numeric values.
format
,
final ParsePosition
input/output parsing parameter.
pos
)

Parses source for a number.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CompositeFormatback to summary
private CompositeFormat()

Class contains only static methods.

Method Detail

formatDoubleback to summary
public static StringBuffer formatDouble(final double value, final NumberFormat format, final StringBuffer toAppendTo, final FieldPosition pos)

Formats a double value to produce a string. In general, the value is formatted using the formatting rules of format. There are three exceptions to this:

  1. NaN is formatted as '(NaN)'
  2. Positive infinity is formatted as '(Infinity)'
  3. Negative infinity is formatted as '(-Infinity)'
Parameters
value:double

the double to format.

format:NumberFormat

the format used.

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.

getDefaultNumberFormatback to summary
public static NumberFormat getDefaultNumberFormat()

Create a default number format. The default number format is based on NumberFormat#getInstance() with the only customizing that the maximum number of fraction digits is set to 10.

Returns:NumberFormat

the default number format.

getDefaultNumberFormatback to summary
public static NumberFormat getDefaultNumberFormat(final Locale locale)

Create a default number format. The default number format is based on NumberFormat#getInstance(java.util.Locale) with the only customizing that the maximum number of fraction digits is set to 10.

Parameters
locale:Locale

the specific locale used by the format.

Returns:NumberFormat

the default number format specific to the given locale.

parseAndIgnoreWhitespaceback to summary
public static void parseAndIgnoreWhitespace(final String source, final ParsePosition pos)

Parses source until a non-whitespace character is found.

Parameters
source:String

the string to parse

pos:ParsePosition

input/output parsing parameter. On output, pos holds the index of the next non-whitespace character.

parseFixedstringback to summary
public static boolean parseFixedstring(final String source, final String expected, final ParsePosition pos)

Parse source for an expected fixed string.

Parameters
source:String

the string to parse

expected:String

expected string

pos:ParsePosition

input/output parsing parameter.

Returns:boolean

true if the expected string was there

parseNextCharacterback to summary
public static char parseNextCharacter(final String source, final ParsePosition pos)

Parses source until a non-whitespace character is found.

Parameters
source:String

the string to parse

pos:ParsePosition

input/output parsing parameter.

Returns:char

the first non-whitespace character.

parseNumberback to summary
private static Number parseNumber(final String source, final double value, final ParsePosition pos)

Parses source for special double values. These values include Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY.

Parameters
source:String

the string to parse

value:double

the special value to parse.

pos:ParsePosition

input/output parsing parameter.

Returns:Number

the special number.

parseNumberback to summary
public static Number parseNumber(final String source, final NumberFormat format, final ParsePosition pos)

Parses source for a number. This method can parse normal, numeric values as well as special values. These special values include Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY.

Parameters
source:String

the string to parse

format:NumberFormat

the number format used to parse normal, numeric values.

pos:ParsePosition

input/output parsing parameter.

Returns:Number

the parsed number.