|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvec_math.Node<String>
vec_math.StringNode
public class StringNode
A node that is parseable from a string. Parentheses are used for changing
the normal precedence. The valid operators in a regime must be set
explicately with the setValidOperator(java.util.List method. For String
parsing the following rules must be met.
| Field Summary | |
|---|---|
private int |
operatorIndex
Position in parse string of node operator. |
private static List<Operator<String>> |
valid
Valid operators. |
| Constructor Summary | |
|---|---|
StringNode(String definition)
Constructs a root string node. |
|
StringNode(StringNode parent,
String definition,
int level)
Defines a fully qualified String node. |
|
| Method Summary | |
|---|---|
private static int |
checkParenthesis(String test)
Checks if all parenthesis opened are closed again. |
private static String |
getStripped(String def)
Strips the String from leading and trailing whitespaces. |
Set<String> |
getVariables()
It is difficult to assure proper replacement of variables. |
protected boolean |
isVariable(String sarg)
Only strings are considered to be variables. |
protected Operator<String> |
parseOperator(String def)
Parses the input string for the root-level operator with the highest precedence. |
protected StringNode[] |
parseSub(String def)
Parses the String for subnodes. |
static String |
replaceVariable(String target,
String variable,
Object map)
Returns a string where the occurence of a given variable's name is replaced with the actual value of the variable. |
static String |
replaceVariable(String target,
String variable,
Object map,
boolean quote)
Returns a string where the occurence of a given variable's name is replaced with the actual value of the variable. |
static void |
setValidOperator(List<Operator<String>> op)
Sets the allowed operators. |
| Methods inherited from class vec_math.Node |
|---|
equals, getLevel, getParent, getParseSource, getSub, getSubAt, getSubNodeNumber, getTie, getValue, isFinal, isParsed, isRoot, parse, parse, setParse, setParseSource, setSub, setTie, setValue, toString, traceVariable |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static List<Operator<String>> valid
private int operatorIndex
| Constructor Detail |
|---|
public StringNode(String definition)
public StringNode(StringNode parent,
String definition,
int level)
parseSub(java.lang.String)| Method Detail |
|---|
public static void setValidOperator(List<Operator<String>> op)
public static String replaceVariable(String target,
String variable,
Object map)
throws ParseException
sin(height) to sin(0.342956765).
Whenever the replacement object is not a string, the object's
string representation is used as the replacement. For string objects,
however, this string is put within double quotes.
target - The entire string to parse.variable - The name of the variable as found in the target.map - The replacement for the variable.
ParseException - If the variable cannot be found in the target.
public static String replaceVariable(String target,
String variable,
Object map,
boolean quote)
throws ParseException
sin(height) to sin(0.342956765).
Whenever the replacement object is not a string, the object's
string representation is used as the replacement. For string objects,
however, this string is put within double quotes if the qutoe flag is
set.
target - The entire string to parse.variable - The name of the variable as found in the target.map - The replacement for the variable.quote - If true, strings are wrapped in double quotes.
ParseException - If the variable cannot be found in the target.protected boolean isVariable(String sarg)
isVariable in class Node<String>private static String getStripped(String def)
private static int checkParenthesis(String test)
public Set<String> getVariables()
getVariables in class Node<String>
protected Operator<String> parseOperator(String def)
throws ParseException
setValidOperator(java.util.List>) a
ParseException is thrown.
parseOperator in class Node<String>ParseException
protected StringNode[] parseSub(String def)
throws ParseException
parseOperator(java.lang.String) has been called beforehand which should always
be the case in the normal line of execution, guaranteed by the
order of method calls in the superclass.Note that this class is able to produce subnodes of the same class type as itself if the constructor requirement is met.
parseSub in class Node<String>ParseException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||