|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection java.util.AbstractList java.util.Vector com.rubecula.jquantity.Expression
Class to manage a mathematical expression. It is the Presentable counterpart to SymbolicPresentation. Elements, the order of which is important, are either of:
Replaceable
(which extends Presentable
and java.util.Vector
only), nevertheless it uses numerical classes such as BaseNumber and the
abstract class of Item. This doesn't seem quite right.
// TODO The calculations which use operators on Items and BaseNumbers ought to be
defined somewhere else so that this class could be more "pure".
Nested Class Summary | |
(package private) static class |
Expression.ExpressionException
Static class to define an exception encountered when parsing a formula. |
Nested classes inherited from class java.util.AbstractList |
|
Field Summary | |
private static Lookupable |
$CONSTANTS
This Lookupable object is where "constants" that may be required by any expression can be stored. |
Fields inherited from class java.util.Vector |
capacityIncrement, elementCount, elementData |
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary | |
Expression()
Constructor for an empty formula. |
|
Expression(Presentable presentable)
Constructor for an "anadic" formula of all strings. |
Method Summary | |
static Lookupable |
GetConstants()
|
java.lang.String |
getType()
This method is primarily for development purposes: it yields the name of the class of the presentable object or, in some cases, the class of the presentable object indirectly referenced. |
Presentable |
getValue()
Method to evaluate this expression. |
Presentable |
getValue(java.lang.Object ignored)
This method takes this Expression and returns its logical equivalent, i.e. it evaluates the expression. |
private static Presentable |
LookupConstant(java.lang.String s)
|
static void |
main(java.lang.String[] args)
Main method for testing this class. |
Presentable |
makePresentableInstance(Presentation presentation)
Instance method to convert a Presentation into a Presentable. |
private static Item |
OpAnadic(Operator op)
|
private static Item |
OpDyadicComplex(Item current,
Operator currentOp,
Item number)
|
private static Item |
OpDyadicNonComplex(Item current,
Operator currentOp,
BaseNumber number)
Note that the order of the operands is the reverse of the true order. |
private static Item |
OpMonadic(Operator op,
Item number)
|
static Presentable |
Parse(Presentation presentation)
Create a Rational from a Presentation and return it as a Presentable. |
static Expression |
Parse(SymbolicPresentation presentation,
java.lang.String identifier)
Translates the SymbolicPresentation representation of an expression into an instance of Expression. |
Presentation |
present()
Convert this Presentable object into a Presentation with default attributes. |
Presentation |
present(AttrMap attributes)
Convert this Presentable object into a Presentation, according to the set of attributes provided. |
static void |
SetConstants(Lookupable constants)
|
protected static void |
testExpression(java.io.PrintStream out,
SymbolicPresentation sp,
java.lang.String label)
|
Methods inherited from class java.util.Vector |
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize |
Methods inherited from class java.util.AbstractList |
iterator, listIterator, listIterator |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
iterator, listIterator, listIterator |
Field Detail |
private static Lookupable $CONSTANTS
Constructor Detail |
public Expression()
public Expression(Presentable presentable)
presentable
- the presentable to form this singleton expression.Method Detail |
public static Expression Parse(SymbolicPresentation presentation, java.lang.String identifier) throws PresentationException
presentation
- SymbolicPresentation representation to interpret.identifier
- A string with which to identify this Rational.
PresentationException
- if the presentation cannot be parsed as an Expression.private static Presentable LookupConstant(java.lang.String s) throws PresentationException, PresentableException
PresentationException
PresentableException
public Presentable getValue() throws PresentableException
PresentableException
- name not be found.public Presentable getValue(java.lang.Object ignored) throws PresentableException
getValue
in interface Replaceable
ignored
- Not used.
PresentableException
public Presentation present(AttrMap attributes) throws PresentationException
present
in interface Presentable
attributes
- a map of desired attributes for this presentation.
PresentationException
- if formula cannot be presented with given attributes.public Presentation present() throws PresentationException
PresentationException
- if formula cannot be presented with given attributes.public java.lang.String getType()
getType
in interface Presentable
public Presentable makePresentableInstance(Presentation presentation) throws PresentationException
makePresentableInstance
in interface Presentable
presentation
- of a number to be converted into a Presentable number.
PresentationException
- if presentation cannot be parsed appropriately.public static Presentable Parse(Presentation presentation) throws PresentationException
presentation
- A presentation which should be parsed to form a Presentable.
PresentationException
- if the presentation cannot be parsed as a Presentable
object.private static Item OpAnadic(Operator op) throws PresentableException
PresentableException
private static Item OpMonadic(Operator op, Item number) throws PresentableException
PresentableException
private static Item OpDyadicNonComplex(Item current, Operator currentOp, BaseNumber number) throws PresentableException
current
- the "current" value - generally the accumulated result of the
expression thus far.currentOp
- the "current" operator.number
- the new number to be combined with the current value
PresentableException
private static Item OpDyadicComplex(Item current, Operator currentOp, Item number) throws PresentableException
PresentableException
protected static void testExpression(java.io.PrintStream out, SymbolicPresentation sp, java.lang.String label)
public static void main(java.lang.String[] args)
args
- String[] : the command line options.public static Lookupable GetConstants()
public static void SetConstants(Lookupable constants)
constants
- The Lookupable constants to be used as our "constants" definition to set.$CONSTANTS
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |