|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
org.apache.commons.math.util.CompositeFormat
org.apache.commons.math.complex.ComplexFormat
public class ComplexFormat
Formats a Complex number in cartesian format "Re(c) + Im(c)i". 'i' can be replaced with 'j' (or anything else), and the number format for both real and imaginary parts can be configured.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.Format |
|---|
Format.Field |
| Constructor Summary | |
|---|---|
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 realFormat,
NumberFormat imaginaryFormat)
Create an instance with a custom number format for the real part and a custom number format for the imaginary part. |
|
ComplexFormat(String imaginaryCharacter)
Create an instance with a custom imaginary character, and the default number format for both real and imaginary parts. |
|
ComplexFormat(String imaginaryCharacter,
NumberFormat format)
Create an instance with a custom imaginary character, and a custom number format for both real and imaginary parts. |
|
ComplexFormat(String imaginaryCharacter,
NumberFormat realFormat,
NumberFormat imaginaryFormat)
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. |
|
| Method Summary | |
|---|---|
StringBuffer |
format(Complex complex,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a Complex object to produce a string. |
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Formats a object to produce a string. |
static String |
formatComplex(Complex c)
This static method calls Format.format(Object) on a default instance of
ComplexFormat. |
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. |
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. |
Object |
parseObject(String source,
ParsePosition pos)
Parses a string to produce a object. |
void |
setImaginaryCharacter(String imaginaryCharacter)
Modify the imaginaryCharacter. |
void |
setImaginaryFormat(NumberFormat imaginaryFormat)
Modify the imaginaryFormat. |
void |
setRealFormat(NumberFormat realFormat)
Modify the realFormat. |
| Methods inherited from class org.apache.commons.math.util.CompositeFormat |
|---|
formatDouble, getDefaultNumberFormat, getDefaultNumberFormat, parseAndIgnoreWhitespace, parseFixedstring, parseNextCharacter, parseNumber |
| Methods inherited from class java.text.Format |
|---|
clone, format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ComplexFormat()
public ComplexFormat(NumberFormat format)
format - the custom format for both real and imaginary parts.
public ComplexFormat(NumberFormat realFormat,
NumberFormat imaginaryFormat)
realFormat - the custom format for the real part.imaginaryFormat - the custom format for the imaginary part.public ComplexFormat(String imaginaryCharacter)
imaginaryCharacter - The custom imaginary character.
public ComplexFormat(String imaginaryCharacter,
NumberFormat format)
imaginaryCharacter - The custom imaginary character.format - the custom format for both real and imaginary parts.
public ComplexFormat(String imaginaryCharacter,
NumberFormat realFormat,
NumberFormat imaginaryFormat)
imaginaryCharacter - The custom imaginary character.realFormat - the custom format for the real part.imaginaryFormat - the custom format for the imaginary part.| Method Detail |
|---|
public static Locale[] getAvailableLocales()
This is the same set as the NumberFormat set.
public static String formatComplex(Complex c)
Format.format(Object) on a default instance of
ComplexFormat.
c - Complex 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 field
public 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.
format in class Formatobj - 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 field
IllegalArgumentException - 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 NumberFormat getRealFormat()
public Complex parse(String source)
throws ParseException
Complex object.
source - the string to parse
Complex object.
ParseException - 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.
public Object parseObject(String source,
ParsePosition pos)
parseObject in class Formatsource - the string to parsepos - input/ouput parsing parameter.
Format.parseObject(java.lang.String, java.text.ParsePosition)public void setImaginaryCharacter(String imaginaryCharacter)
imaginaryCharacter - The new imaginaryCharacter value.
IllegalArgumentException - if imaginaryCharacter is
null or an empty string.public void setImaginaryFormat(NumberFormat imaginaryFormat)
imaginaryFormat - The new imaginaryFormat value.
IllegalArgumentException - if imaginaryFormat is
null.public void setRealFormat(NumberFormat realFormat)
realFormat - The new realFormat value.
IllegalArgumentException - if realFormat is
null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||