sbrt.shell.text.math
Class LinCombTermFormatV2<V>

java.lang.Object
  extended by sbrt.shell.text.math.LinCombTermFormatV2<V>
Type Parameters:
V - the variable type.
All Implemented Interfaces:
Format, Formatter<LinearComb.Term<? extends V>>, LinearCombTermFormat<V>, Parser<LinearComb.Term<? extends V>>, SimpleFormat<LinearComb.Term<? extends V>>

public final class LinCombTermFormatV2<V>
extends java.lang.Object
implements LinearCombTermFormat<V>

This class is a concrete implementation of LinearCombTermFormat. Terms have the following format: coefficient variable.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Constructor Summary
LinCombTermFormatV2(SimpleFormat<V> variableFormat)
          Constructs a new linear combination term format using the provided formats.
 
Method Summary
 java.lang.String format(LinearComb.Term<? extends V> term)
          Returns a formatted string representation of the provided term.
 CoeffFormatV2 getCoeffFormat()
          Returns the format used for coefficients.
 SimpleFormat<V> getVariableFormat()
          Returns the format used for variables.
 LinearComb.Term<V> parse(java.lang.String term)
          Parses the provided string and returns its corresponding term.
 LinearComb.Term<V> parse(java.lang.String coefficient, java.lang.String variable)
          Parses the provided strings and returns their corresponding term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sbrt.shell.text.Formatter
format
 

Constructor Detail

LinCombTermFormatV2

public LinCombTermFormatV2(SimpleFormat<V> variableFormat)
Constructs a new linear combination term format using the provided formats.

Parameters:
variableFormat - the format to use for variables.
Method Detail

getVariableFormat

public SimpleFormat<V> getVariableFormat()
Returns the format used for variables.

Returns:
the format used for variables.

getCoeffFormat

public CoeffFormatV2 getCoeffFormat()
Returns the format used for coefficients.

Returns:
the format used for coefficients.

format

public java.lang.String format(LinearComb.Term<? extends V> term)
Returns a formatted string representation of the provided term.

Specified by:
format in interface LinearCombTermFormat<V>
Parameters:
term - the term to be formatted.
Returns:
a formatted string representation of the provided term.

parse

public LinearComb.Term<V> parse(java.lang.String term)
Parses the provided string and returns its corresponding term.

Specified by:
parse in interface LinearCombTermFormat<V>
Specified by:
parse in interface Parser<LinearComb.Term<? extends V>>
Parameters:
term - the string to be parsed.
Returns:
the term corresponding to the provided string.

parse

public LinearComb.Term<V> parse(java.lang.String coefficient,
                                java.lang.String variable)
Parses the provided strings and returns their corresponding term.

Parameters:
coefficient - the string of the coefficient to be parsed.
variable - the string of the variable to be parsed.
Returns:
the term corresponding to the provided strings.