com.rubecula.math
Class Macro

java.lang.Object
  extended bycom.rubecula.math.Macro
All Implemented Interfaces:
Presentable

public class Macro
extends java.lang.Object
implements Presentable

Class to model a macro, that's to say a compound operator, as a Presentable. The definition of the macro is held as a set of strings concatenated with $S_DELIM.

Since:
V_0_4
Version:
$Revision: 1.1 $
Author:
Robin Hillyard

Field Summary
private  java.lang.String _Definition
          The definition of the macro.
private static java.lang.String $S_DELIM
          Delimiter of operators within a Macro.
 
Constructor Summary
Macro(java.lang.String definition)
          Primary constructor to create a Macro from a String.
Macro(java.lang.String first, java.lang.String second)
           
 
Method Summary
 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 makePresentableInstance(Presentation presentation)
          Instance method to convert a Presentation into a Presentable.
 Presentation present(AttrMap attributes)
          Convert this Presentable object into a Presentation, according to the set of attributes provided.
 java.util.StringTokenizer tokenize()
           
static Macro valueOf(java.lang.String[] operations)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

$S_DELIM

private static final java.lang.String $S_DELIM
Delimiter of operators within a Macro. Value: ;

See Also:
Constant Field Values

_Definition

private final java.lang.String _Definition
The definition of the macro. Naturally, we would prefer to extend String rather than use this delegate field. But String is final.

Constructor Detail

Macro

public Macro(java.lang.String definition)
Primary constructor to create a Macro from a String.

Parameters:
definition -

Macro

public Macro(java.lang.String first,
             java.lang.String second)
Method Detail

valueOf

public static final Macro valueOf(java.lang.String[] operations)

present

public Presentation present(AttrMap attributes)
                     throws PresentationException
Description copied from interface: Presentable
Convert this Presentable object into a Presentation, according to the set of attributes provided.

Specified by:
present in interface Presentable
Parameters:
attributes - a map of the attributes desired for the construction of the new presentation (may be empty).
Returns:
an appropriate instance of Presentation.
Throws:
PresentationException - in case of parsing error.

makePresentableInstance

public Presentable makePresentableInstance(Presentation presentation)
                                    throws PresentationException
Description copied from interface: Presentable
Instance method to convert a Presentation into a Presentable. Ideally, this would be a class method, but such a method cannot be defined in an interface. Nor can it be defined in an abstract class with the intention of overriding it in a subclass. Polymorphism just doesn't work that way.
Therefore, the present value (as in fields) of the instance is essentially ignored - only the methods are important.

Specified by:
makePresentableInstance in interface Presentable
Parameters:
presentation - of a number to be converted into a Presentable number.
Returns:
a number in the form of a Presentable.
Throws:
PresentationException - in case of parsing error.

getType

public java.lang.String getType()
Description copied from interface: Presentable
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. The text returned is not necessarily the canonical class name.

Specified by:
getType in interface Presentable
Returns:
a representation of the effective class of this object.

tokenize

public java.util.StringTokenizer tokenize()