|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdbrown.Variable
public class Variable
Recognizes and stores simple variables for mathematical expressions.
| Field Summary | |
|---|---|
private java.lang.String |
variable
|
private static java.util.regex.Pattern |
variablePattern
A pattern for matching single-letter variables using the regular expression "^[a-zA-Z][0-9]". |
| Constructor Summary | |
|---|---|
Variable(java.lang.String variable)
Create a variable object. |
|
| Method Summary | |
|---|---|
static java.util.regex.MatchResult |
getMatchResult(java.lang.String s)
Returns the result of attempting to match the variable pattern against the input string. |
static boolean |
isVariable(java.lang.String s)
Determines whether or not the input string is an variable. |
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 variablePattern
A pattern for matching single-letter variables using the regular
expression "^[a-zA-Z][0-9]". The expression has two sections:
^ : attempts to match the expression against only the
beginning of a string.[a-zA-Z][0-9] attempts to match the any one of the upper
or lower case letters followed by a single digit.A few changes in this pattern could allow it to match longer multi-character variables as well.
private java.lang.String variable
| Constructor Detail |
|---|
public Variable(java.lang.String variable)
variable - The string to treat as an variable.| Method Detail |
|---|
public static java.util.regex.MatchResult getMatchResult(java.lang.String s)
s - The string to compare against the variable pattern.
java.util.InputMismatchException - -
if the next token in the input string is not an variablepublic static boolean isVariable(java.lang.String s)
s - The string to compare against the variable pattern.
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 | ||||||||