|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdbrown.Operator
public class Operator
Recognizes, stores, and executes simple mathematical operations.
| Field Summary | |
|---|---|
private static java.util.regex.Pattern |
operatorPattern
A pattern for matching operators using the regular expression "^[+-/*%()]". |
private char |
symbol
The character representation of the operator. |
| Constructor Summary | |
|---|---|
Operator(char c)
Constructs a new operator based upon the character passed in. |
|
Operator(java.lang.String s)
Constructs a new operator based upon the character passed in. |
|
| Method Summary | |
|---|---|
static java.util.regex.MatchResult |
getMatchResult(java.lang.String s)
Returns the result of attempting to match the operator pattern against the input string. |
static boolean |
isOperator(java.lang.String s)
Determines whether or not the input string is an operator. |
char |
toChar()
Returns the character symbol of the operator. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.regex.Pattern operatorPattern
A pattern for matching operators using the regular expression
"^[+-/*%()]". The expression has two sections:
^ : attempts to match the expression against only the
beginning of a string.[+-/*%()] attempts to match the any one of the
operator symbols.A few changes in this pattern could allow it to match longer operators as well.
private char symbol
| Constructor Detail |
|---|
public Operator(char c)
c - an operator characterpublic Operator(java.lang.String s)
s - a string whose first character is an operator character| Method Detail |
|---|
public static java.util.regex.MatchResult getMatchResult(java.lang.String s)
s - The string to compare against the operator pattern.
java.util.InputMismatchException - -
if the next token in the input string is not an operatorpublic static boolean isOperator(java.lang.String s)
s - The string to compare against the operator pattern.
public char toChar()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||