|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdbrown.Operand
public class Operand
Recognizes and stores simple mathematical operands.
| Field Summary | |
|---|---|
(package private) java.lang.String |
operand
|
private static java.util.regex.Pattern |
operandPattern
A pattern for matching operands using the regular expression "^-?[0-9]+". |
| Constructor Summary | |
|---|---|
Operand(java.lang.String operand)
Create an operand object. |
|
| Method Summary | |
|---|---|
static java.util.regex.MatchResult |
getMatchResult(java.lang.String s)
Returns the result of attempting to match the operand pattern against the input string. |
static boolean |
isOperand(java.lang.String s)
Determines whether or not the input string is an operand. |
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 operandPattern
A pattern for matching operands using the regular expression
"^-?[0-9]+". The expression has four sections:
^ : attempts to match the expression against only the
beginning of a string.-? : attempts to match a minus sign prefix, if one
exists. (Thus if the string begins with a minus sign the pattern is
considered to match; if there is no minus sign the pattern is considered
to match - so far.)[0-9] attempts to match the digits 0 through 9.Thus the pattern can match both positive and negative integers at the beginning of the target string.
A few changes in this pattern could allow it to match floating point values as well.
java.lang.String operand
| Constructor Detail |
|---|
public Operand(java.lang.String operand)
operand - The string to treat as an operand.| Method Detail |
|---|
public static java.util.regex.MatchResult getMatchResult(java.lang.String s)
s - The string to compare against the operand pattern.
java.util.InputMismatchException - -
if the next token in the input string is not an operandpublic static boolean isOperand(java.lang.String s)
s - The string to compare against the operand pattern.
public java.lang.String toString()
toString in class java.lang.ObjectString
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||