Class GroupingSymbol

java.lang.Object
  |
  +--GroupingSymbol

public class GroupingSymbol
extends java.lang.Object

This class represents a grouping symbol in an equation. Grouping symbols are used to change the order in which an infix equation is solved. Normally an equation is solved it is solved left to right and according to the order of operations. Grouping symbols allow one to specify that certain operations which would normally occur later in the solving can occur earlier.

Parentheses are common grouping symbols for instance. The use of parentheses allows one to change the meaning of 3 + 4 / 14 from 3 2/7 to (3 + 4) / 14 which is 7.

I am thinking that no further explanation is needed. This should have been covered in fifth grade or so.


Field Summary
 java.lang.String closeToken
          Symbol representing that a group has been closed
 boolean openingSymbol
          flag telling whether or not this particular symbol instance was an open or a close
 java.lang.String openToken
          Symbol representing that a group has been begun
 
Constructor Summary
GroupingSymbol(java.lang.String o, java.lang.String c)
          Calls GroupingSymbol(String, String, boolean) with a default of the symbol being an opening symbol.
GroupingSymbol(java.lang.String o, java.lang.String c, boolean opening)
          A GroupingSymbol is created not simply with the actual token that it represents but also the close for that symbol.
 
Method Summary
 boolean isAClosingSymbol()
          Tells if the current symbol represents the close of a group
 boolean isAnOpeningSymbol()
          Tells if the current symbol represents the beginning of a group
 boolean isCloseFor(GroupingSymbol o)
          Tells whether o is the opposing symbol for this symbol.
 java.lang.String token()
          Returns the appropriate token representing this grouping symbol.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

openToken

public java.lang.String openToken
Symbol representing that a group has been begun

closeToken

public java.lang.String closeToken
Symbol representing that a group has been closed

openingSymbol

public boolean openingSymbol
flag telling whether or not this particular symbol instance was an open or a close
Constructor Detail

GroupingSymbol

public GroupingSymbol(java.lang.String o,
                      java.lang.String c)
Calls GroupingSymbol(String, String, boolean) with a default of the symbol being an opening symbol.
Parameters:
o - the opening symbol
c - the closing symbol

GroupingSymbol

public GroupingSymbol(java.lang.String o,
                      java.lang.String c,
                      boolean opening)
A GroupingSymbol is created not simply with the actual token that it represents but also the close for that symbol. This is done because a grouping symbol is worthless unless its close is known.
Parameters:
o - the opening symbol
c - the closing symbol
opening - flag telling whether this particular symbol represents the open or the close for this pair
Method Detail

isCloseFor

public boolean isCloseFor(GroupingSymbol o)
Tells whether o is the opposing symbol for this symbol.
Parameters:
o - the grouping symbol to be checked against

token

public java.lang.String token()
Returns the appropriate token representing this grouping symbol. If the symbol is an open then openToken is returned otherwise closeToken is returned.
Returns:
the token for the current symbol

toString

public java.lang.String toString()
Returns:
returns the value of token()
Overrides:
toString in class java.lang.Object

isAnOpeningSymbol

public boolean isAnOpeningSymbol()
Tells if the current symbol represents the beginning of a group
Returns:
true if the symbol begins a group

isAClosingSymbol

public boolean isAClosingSymbol()
Tells if the current symbol represents the close of a group
Returns:
true if the symbol closes a group