tcra
Class MathString<ElementType extends MathType>

java.lang.Object
  extended by tcra.MathString<ElementType>
All Implemented Interfaces:
MathType

public class MathString<ElementType extends MathType>
extends java.lang.Object
implements MathType

MathString is an abstraction of the mathematical "String of [ElementType]". MathString is parameterized to allow the elements to be of any type of MathType.


Constructor Summary
MathString(java.util.Vector<ElementType> elem, MathStringParser msp)
          Class constructor specifying the elements in the string and the MathStringParser used to parse the String from user input.
 
Method Summary
 MathString<ElementType> concat(ElementType latter)
          Returns a MathString that has had the provided element concatenated on to it.
 MathString<ElementType> concat(MathString<ElementType> latter)
          Returns a MathString that is the concatenation of this MathString and another MathString provided by the user.
 boolean equals(java.lang.Object other)
          Tests the MathString provided and this MathString for equality.
 java.util.Vector<ElementType> getContents()
          Returns the contents of the MathString.
 int length()
          Returns the number of elements in the MathString
 MathString<ElementType> preconcat(ElementType former)
          Returns a MathString that has had the provided element concatenated on to the beginning of this string.
 java.util.Vector<MathString<ElementType>> split(int elemNum)
          Returns two seperate MathStrings that this MathString split after the specified element number.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MathString

public MathString(java.util.Vector<ElementType> elem,
                  MathStringParser msp)
Class constructor specifying the elements in the string and the MathStringParser used to parse the String from user input.

Parameters:
elem - Vector of the parameterized type ElementType that is the contents of the MathString
msp - MathStringParser used to parse the user input
Method Detail

length

public int length()
Returns the number of elements in the MathString

Returns:
number of elements contained in the MathString

concat

public MathString<ElementType> concat(MathString<ElementType> latter)
Returns a MathString that is the concatenation of this MathString and another MathString provided by the user.

Parameters:
latter - MathString to be concatenated onto this MathString.
Returns:
Concatenized MathString.

concat

public MathString<ElementType> concat(ElementType latter)
Returns a MathString that has had the provided element concatenated on to it.

Parameters:
latter - Element to be added to this MathString
Returns:
Concatenized MathString

preconcat

public MathString<ElementType> preconcat(ElementType former)
Returns a MathString that has had the provided element concatenated on to the beginning of this string.

Parameters:
former - Element to be added to this MathString
Returns:
Concatenized MathString

equals

public boolean equals(java.lang.Object other)
Tests the MathString provided and this MathString for equality. They are equal if the contents of the MathStrings are equal and in the same order.

Specified by:
equals in interface MathType
Overrides:
equals in class java.lang.Object
Parameters:
other - MathString that this is compared to.
Returns:
true if the MathString and the MathString provided are equal. false otherwise.

split

public java.util.Vector<MathString<ElementType>> split(int elemNum)
Returns two seperate MathStrings that this MathString split after the specified element number.

Parameters:
elemNum - position to split the MathString around.
Returns:
Vector containing two MathStrings. The first will contain elemNum elements, and the second will contain this.length() - elemNum elements.

getContents

public java.util.Vector<ElementType> getContents()
Returns the contents of the MathString.

Returns:
Vector containing the contents of the MathString.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object