MathString
Date: 2008-02-28

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## tcra.math
Class MathString<ElementType extends MathType>

    java.lang.Object
      tcra.math.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
`boolean` | `compareElement(int index, ElementType compare)` Checks the provided [ElementType] and the element of the string at 'index' for equality.
`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.
`ElementType` | `elementAt(int index)` Returns the element in the string at the specified index.
`boolean` | `equals(java.lang.Object other)` Tests the MathString provided and this MathString for equality.
`boolean` | `isSuffix(MathString<ElementType> suffix)` Checks to see if the provided MathString is contained at the end of this MathString.
`int` | `length()` Returns the number of elements in the MathString
`MathString<ElementType>` | `prepend(ElementType former)` Returns a MathString that has had the provided element concatenated on to the beginning of this string.
`MathString<ElementType>` | `prepend(MathString<ElementType> former)` Returns a MathString that has had the provided MathString concatenated on to the beginning of this string.
`MathString<ElementType>` | `reverse()` Get the reverse of this MathString
`java.util.Vector<MathString<ElementType>>` | `split(int elemNum)` Returns two seperate MathStrings that this MathString split after the specified element number.
`java.lang.String` | `toHTMLString()` In case the toString() function includes character that would not properly display in HTML, this string returns an HTML compliant version.
`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

### prepend

    public MathString<ElementType> prepend(MathString<ElementType> former)

  Returns a MathString that has had the provided MathString concatenated on to the beginning of this string.

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

### prepend

    public MathString<ElementType> prepend(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.

  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.

### compareElement

    public boolean compareElement(int index,
                                  ElementType compare)

  Checks the provided [ElementType] and the element of the string at 'index' for equality.

  Parameters:
    `index` - Index of the element we want to compare the provided [ElementType] to.
    `compare` - the [ElementType] to compare to
  Returns:
    result of the comparison

### 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.

### reverse

    public MathString<ElementType> reverse()

  Get the reverse of this MathString

  Returns:
    MathString who's contents is reversed from this MathString

### isSuffix

    public boolean isSuffix(MathString<ElementType> suffix)

  Checks to see if the provided MathString is contained at the end of this MathString.

  Parameters:
    `suffix` - MathString to check for
  Returns:
    `true` if suffix is present at the end `false` otherwise

### elementAt

    public ElementType elementAt(int index)

  Returns the element in the string at the specified index. Index is 0-based.

  Parameters:
    `index` - 0-based index of element
  Returns:
    Element at index

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### toHTMLString

    public java.lang.String toHTMLString()

  Description copied from interface: `MathType`
  In case the toString() function includes character that would not properly display in HTML, this string returns an HTML compliant version. For example, '<' and '>' are not rendered in HTML since they represent opening and closing a tag. To show these as text, you must use `<` and `>`.

  Specified by:
    `toHTMLString` in interface `MathType`
  Returns:
    HTML compliant version of the toString() string.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD