org.apache.commons.math3.util

## Class CompositeFormat

- java.lang.Object
- - org.apache.commons.math3.util.CompositeFormat

    public class CompositeFormat
    extends java.lang.Object

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

Version:
  $Id: CompositeFormat.java 1416643 2012-12-03 19:37:14Z tn $

### Constructor Summary

Constructors
`private` `CompositeFormat()` Class contains only static methods.

### Method Summary

Methods
`static java.lang.StringBuffer` `formatDouble(double value, java.text.NumberFormat format, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)` Formats a double value to produce a string.
`static java.text.NumberFormat` `getDefaultNumberFormat()` Create a default number format.
`static java.text.NumberFormat` `getDefaultNumberFormat(java.util.Locale locale)` Create a default number format.
`static void` `parseAndIgnoreWhitespace(java.lang.String source, java.text.ParsePosition pos)` Parses `source` until a non-whitespace character is found.
`static boolean` `parseFixedstring(java.lang.String source, java.lang.String expected, java.text.ParsePosition pos)` Parse `source` for an expected fixed string.
`static char` `parseNextCharacter(java.lang.String source, java.text.ParsePosition pos)` Parses `source` until a non-whitespace character is found.
`private static java.lang.Number` `parseNumber(java.lang.String source, double value, java.text.ParsePosition pos)` Parses `source` for special double values.
`static java.lang.Number` `parseNumber(java.lang.String source, java.text.NumberFormat format, java.text.ParsePosition pos)` Parses `source` for a number.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CompositeFormat

    private CompositeFormat()

Class contains only static methods.

### Method Detail

#### getDefaultNumberFormat

    public static java.text.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:
  the default number format.

#### getDefaultNumberFormat

    public static java.text.NumberFormat getDefaultNumberFormat(java.util.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` - the specific locale used by the format.
Returns:
  the default number format specific to the given locale.

#### parseAndIgnoreWhitespace

    public static void parseAndIgnoreWhitespace(java.lang.String source,
                                java.text.ParsePosition pos)

Parses `source` until a non-whitespace character is found.

Parameters:
  `source` - the string to parse
  `pos` - input/output parsing parameter. On output, `pos` holds the index of the next non-whitespace character.

#### parseNextCharacter

    public static char parseNextCharacter(java.lang.String source,
                          java.text.ParsePosition pos)

Parses `source` until a non-whitespace character is found.

Parameters:
  `source` - the string to parse
  `pos` - input/output parsing parameter.
Returns:
  the first non-whitespace character.

#### parseNumber

    private static java.lang.Number parseNumber(java.lang.String source,
                               double value,
                               java.text.ParsePosition pos)

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

Parameters:
  `source` - the string to parse
  `value` - the special value to parse.
  `pos` - input/output parsing parameter.
Returns:
  the special number.

#### parseNumber

    public static java.lang.Number parseNumber(java.lang.String source,
                               java.text.NumberFormat format,
                               java.text.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` - the string to parse
  `format` - the number format used to parse normal, numeric values.
  `pos` - input/output parsing parameter.
Returns:
  the parsed number.

#### parseFixedstring

    public static boolean parseFixedstring(java.lang.String source,
                           java.lang.String expected,
                           java.text.ParsePosition pos)

Parse `source` for an expected fixed string.

Parameters:
  `source` - the string to parse
  `expected` - expected string
  `pos` - input/output parsing parameter.
Returns:
  true if the expected string was there

#### formatDouble

    public static java.lang.StringBuffer formatDouble(double value,
                                      java.text.NumberFormat format,
                                      java.lang.StringBuffer toAppendTo,
                                      java.text.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` - the double to format.
  `format` - the format used.
  `toAppendTo` - where the text is to be appended
  `pos` - On input: an alignment field, if desired. On output: the offsets of the alignment field
Returns:
  the value passed in as toAppendTo.