Orbital library

orbital.math
Class ArithmeticFormat

java.lang.Object
  extended by java.text.Format
      extended by orbital.math.ArithmeticFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ArithmeticFormat
extends java.text.Format

ArithmeticFormat is responsible for formatting and parsing arithmetic objects.

With this instance of Format it is possible to format as well as parse the various arithmetic objects.

Although there is a getInstance(Locale) method that is aware of a locale, this class will most likely be instantiated in a locale-independent manner using scientific mathematical notation (see getDefaultInstance()). Anyway, ArithmeticFormat's formatting details can be configured to fit different notation requirements.

You can adjust the output of pure real numbers of an ArithmeticFormat by modifying the corresponding properties of its getNumberFormat() instance. However, to adjust the common format on the whole math system, use MathUtilities.getDefaultPrecisionDigits(), etc.

Author:
André Platzer
See Also:
NumberFormat.INTEGER_FIELD, NumberFormat.FRACTION_FIELD, NumberFormat, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static int DENOMINATOR_FIELD
           
static int IMAGINARY_FIELD
           
static ArithmeticFormat MATH_EXPORT_FORMAT
          A formatter producing parsable output as exportable to systems like Mathematica.
static int NUMERATOR_FIELD
           
static int REAL_FIELD
           
static int SYMBOL_FIELD
           
 
Constructor Summary
ArithmeticFormat(java.util.Locale locale)
          Create a new arithmetic formatter for a specific locale.
 
Method Summary
 java.lang.String format(Arithmetic obj)
          Get a formatted string representation of an arithmetic object.
 java.lang.StringBuffer format(Arithmetic obj, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
           
 java.lang.String format(Complex obj)
          Specialization of format.
 java.lang.StringBuffer format(Complex v, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Fraction obj)
          Specialization of format.
 java.lang.StringBuffer format(Fraction as, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Integer obj)
          Specialization of format.
 java.lang.StringBuffer format(Integer v, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(MathFunctor obj)
          Specialization of format.
 java.lang.StringBuffer format(MathFunctor f, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Matrix obj)
          Specialization of format.
 java.lang.StringBuffer format(Matrix v, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
           
 java.lang.String format(Polynomial obj)
          Specialization of format.
 java.lang.StringBuffer format(Polynomial p, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Quotient obj)
          Specialization of format.
 java.lang.StringBuffer format(Quotient q, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Rational obj)
          Specialization of format.
 java.lang.StringBuffer format(Rational v, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Real obj)
          Specialization of format.
 java.lang.StringBuffer format(Real v, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Scalar obj)
          Specialization of format.
 java.lang.StringBuffer format(Scalar obj, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format, formatting scalar objects as they please.
 java.lang.String format(Symbol obj)
          Specialization of format.
 java.lang.StringBuffer format(Symbol s, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Tensor obj)
          Specialization of format.
 java.lang.StringBuffer format(Tensor obj, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format, formatting tensor objects as they please.
 java.lang.String format(UnivariatePolynomial obj)
          Specialization of format.
 java.lang.StringBuffer format(UnivariatePolynomial p, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
 java.lang.String format(Vector obj)
          Specialization of format.
 java.lang.StringBuffer format(Vector v, java.lang.StringBuffer result, java.text.FieldPosition fieldPosition)
          Specialization of format.
static ArithmeticFormat getDefaultInstance()
          Get the default instance of format that does scientific mathematical formatting.
static ArithmeticFormat getInstance()
          Returns the default number format for the current default locale.
static ArithmeticFormat getInstance(java.util.Locale locale)
           
 java.text.NumberFormat getNumberFormat()
          Get the inner number format used to format pure real numbers.
 java.lang.String getPolynomialVariable()
           
 Arithmetic parse(java.lang.String source)
          Parse an arithmetic object string representation.
 Arithmetic parse(java.lang.String source, java.text.ParsePosition status)
          Parse an arithmetic object string representation.
 java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition status)
           
protected  void setNumberFormat(java.text.NumberFormat newNumberFormat)
          Set the inner number format used to format pure real numbers.
 void setPolynomialVariable(java.lang.String polynomialVariable)
          Set the denotation of the formal parameter of polynomials.
 
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
 

Field Detail

NUMERATOR_FIELD

public static final int NUMERATOR_FIELD
See Also:
Constant Field Values

DENOMINATOR_FIELD

public static final int DENOMINATOR_FIELD
See Also:
Constant Field Values

REAL_FIELD

public static final int REAL_FIELD
See Also:
Constant Field Values

IMAGINARY_FIELD

public static final int IMAGINARY_FIELD
See Also:
Constant Field Values

SYMBOL_FIELD

public static final int SYMBOL_FIELD
See Also:
Constant Field Values

MATH_EXPORT_FORMAT

public static final ArithmeticFormat MATH_EXPORT_FORMAT
A formatter producing parsable output as exportable to systems like Mathematica.

Constructor Detail

ArithmeticFormat

public ArithmeticFormat(java.util.Locale locale)
Create a new arithmetic formatter for a specific locale.

Method Detail

getInstance

public static ArithmeticFormat getInstance(java.util.Locale locale)
See Also:
"FacadeFactory"

getInstance

public static ArithmeticFormat getInstance()
Returns the default number format for the current default locale.

See Also:
getDefaultInstance(), "FacadeFactory"

getDefaultInstance

public static final ArithmeticFormat getDefaultInstance()
Get the default instance of format that does scientific mathematical formatting. Used in Object.toString() methods in this package.

See Also:
NumberFormat.getScientificInstance(), "FacadeFactory"

getPolynomialVariable

public java.lang.String getPolynomialVariable()

setPolynomialVariable

public void setPolynomialVariable(java.lang.String polynomialVariable)
Set the denotation of the formal parameter of polynomials.

Parameters:
polynomialVariable - the string that is used to denote the formal parameter X of R[X].

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Get the inner number format used to format pure real numbers.


setNumberFormat

protected void setNumberFormat(java.text.NumberFormat newNumberFormat)
Set the inner number format used to format pure real numbers.


format

public java.lang.String format(Arithmetic obj)
Get a formatted string representation of an arithmetic object.

See Also:
Format.format(Object)

format

public java.lang.String format(Scalar obj)
Specialization of format.


format

public java.lang.String format(Tensor obj)
Specialization of format.


format

public java.lang.String format(Vector obj)
Specialization of format.


format

public java.lang.String format(Matrix obj)
Specialization of format.


format

public java.lang.String format(Complex obj)
Specialization of format.


format

public java.lang.String format(Real obj)
Specialization of format.


format

public java.lang.String format(Rational obj)
Specialization of format.


format

public java.lang.String format(Integer obj)
Specialization of format.


format

public java.lang.String format(Polynomial obj)
Specialization of format.


format

public java.lang.String format(UnivariatePolynomial obj)
Specialization of format.


format

public java.lang.String format(Quotient obj)
Specialization of format.


format

public java.lang.String format(Fraction obj)
Specialization of format.


format

public java.lang.String format(Symbol obj)
Specialization of format.


format

public java.lang.String format(MathFunctor obj)
Specialization of format.


format

public java.lang.StringBuffer format(java.lang.Object obj,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specified by:
format in class java.text.Format

format

public java.lang.StringBuffer format(Arithmetic obj,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)

format

public java.lang.StringBuffer format(Scalar obj,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format, formatting scalar objects as they please.


format

public java.lang.StringBuffer format(Tensor obj,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format, formatting tensor objects as they please.


format

public java.lang.StringBuffer format(Vector v,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Matrix v,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Complex v,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Real v,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Rational v,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Integer v,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Polynomial p,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(UnivariatePolynomial p,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Quotient q,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Fraction as,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(Symbol s,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


format

public java.lang.StringBuffer format(MathFunctor f,
                                     java.lang.StringBuffer result,
                                     java.text.FieldPosition fieldPosition)
Specialization of format.


parse

public Arithmetic parse(java.lang.String source,
                        java.text.ParsePosition status)
Parse an arithmetic object string representation.

See Also:
NumberFormat.parse(String, ParsePosition)

parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    java.text.ParsePosition status)
Specified by:
parseObject in class java.text.Format

parse

public Arithmetic parse(java.lang.String source)
                 throws java.text.ParseException
Parse an arithmetic object string representation.

Throws:
java.text.ParseException
See Also:
parse(String, ParsePosition)

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.