public class ComplexFormat extends Object
Constructor and Description |
---|
ComplexFormat()
Create an instance with the default imaginary character, 'i', and the
default number format for both real and imaginary parts.
|
ComplexFormat(NumberFormat format)
Create an instance with a custom number format for both real and
imaginary parts.
|
ComplexFormat(NumberFormat realFormatIn,
NumberFormat imaginaryFormatIn)
Create an instance with a custom number format for the real part and a
custom number format for the imaginary part.
|
ComplexFormat(String imaginaryCharacterIn)
Create an instance with a custom imaginary character, and the default
number format for both real and imaginary parts.
|
ComplexFormat(String imaginaryCharacterIn,
NumberFormat format)
Create an instance with a custom imaginary character, and a custom number
format for both real and imaginary parts.
|
ComplexFormat(String imaginaryCharacterIn,
NumberFormat realFormatIn,
NumberFormat imaginaryFormatIn)
Create an instance with a custom imaginary character, a custom number
format for the real part, and a custom number format for the imaginary
part.
|
Modifier and Type | Method and Description |
---|---|
String |
format(Complex c)
This method calls
format(Object,StringBuffer,FieldPosition) . |
StringBuffer |
format(Complex complex,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a
Complex object to produce a string. |
String |
format(Double c)
This method calls
format(Object,StringBuffer,FieldPosition) . |
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a object to produce a string.
|
static Locale[] |
getAvailableLocales()
Get the set of locales for which complex formats are available.
|
String |
getImaginaryCharacter()
Access the imaginaryCharacter.
|
NumberFormat |
getImaginaryFormat()
Access the imaginaryFormat.
|
static ComplexFormat |
getInstance()
Returns the default complex format for the current locale.
|
static ComplexFormat |
getInstance(Locale locale)
Returns the default complex format for the given locale.
|
static ComplexFormat |
getInstance(String imaginaryCharacter,
Locale locale)
Returns the default complex format for the given locale.
|
NumberFormat |
getRealFormat()
Access the realFormat.
|
Complex |
parse(String source)
Parses a string to produce a
Complex object. |
Complex |
parse(String source,
ParsePosition pos)
Parses a string to produce a
Complex object. |
public ComplexFormat()
public ComplexFormat(NumberFormat format)
format
- the custom format for both real and imaginary parts.NullArgumentException
- if realFormat
is null
.public ComplexFormat(NumberFormat realFormatIn, NumberFormat imaginaryFormatIn)
realFormatIn
- the custom format for the real part.imaginaryFormatIn
- the custom format for the imaginary part.NullArgumentException
- if imaginaryFormat
is null
.NullArgumentException
- if realFormat
is null
.public ComplexFormat(String imaginaryCharacterIn)
imaginaryCharacterIn
- The custom imaginary character.NullArgumentException
- if imaginaryCharacter
is null
.NoDataException
- if imaginaryCharacter
is an
empty string.public ComplexFormat(String imaginaryCharacterIn, NumberFormat format)
imaginaryCharacterIn
- The custom imaginary character.format
- the custom format for both real and imaginary parts.NullArgumentException
- if imaginaryCharacter
is null
.NoDataException
- if imaginaryCharacter
is an
empty string.NullArgumentException
- if format
is null
.public ComplexFormat(String imaginaryCharacterIn, NumberFormat realFormatIn, NumberFormat imaginaryFormatIn)
imaginaryCharacterIn
- The custom imaginary character.realFormatIn
- the custom format for the real part.imaginaryFormatIn
- the custom format for the imaginary part.NullArgumentException
- if imaginaryCharacter
is null
.NoDataException
- if imaginaryCharacter
is an
empty string.NullArgumentException
- if imaginaryFormat
is null
.NullArgumentException
- if realFormat
is null
.public static Locale[] getAvailableLocales()
This is the same set as the NumberFormat
set.
public String format(Complex c)
format(Object,StringBuffer,FieldPosition)
.c
- Complex object to format.public String format(Double c)
format(Object,StringBuffer,FieldPosition)
.c
- Double object to format.public StringBuffer format(Complex complex, StringBuffer toAppendTo, FieldPosition pos)
Complex
object to produce a string.complex
- the object to format.toAppendTo
- where the text is to be appendedpos
- On input: an alignment field, if desired. On output: the
offsets of the alignment fieldpublic StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
obj
must be either a Complex
object or a Number
object. Any other type of
object will result in an IllegalArgumentException
being thrown.obj
- the object to format.toAppendTo
- where the text is to be appendedpos
- On input: an alignment field, if desired. On output: the
offsets of the alignment fieldMathIllegalArgumentException
- is obj
is not a valid type.Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
public String getImaginaryCharacter()
public NumberFormat getImaginaryFormat()
public static ComplexFormat getInstance()
public static ComplexFormat getInstance(Locale locale)
locale
- the specific locale used by the format.public static ComplexFormat getInstance(String imaginaryCharacter, Locale locale)
locale
- the specific locale used by the format.imaginaryCharacter
- Imaginary character.NullArgumentException
- if imaginaryCharacter
is null
.NoDataException
- if imaginaryCharacter
is an
empty string.public NumberFormat getRealFormat()
public Complex parse(String source)
Complex
object.source
- the string to parse.Complex
object.MathParseException
- if the beginning of the specified string
cannot be parsed.public Complex parse(String source, ParsePosition pos)
Complex
object.source
- the string to parsepos
- input/ouput parsing parameter.Complex
object.Copyright © 2023 CNES. All rights reserved.