Package cruise.umple.parser.rules
Class RepeatableRule
java.lang.Object
cruise.umple.parser.rules.ChoiceRule
cruise.umple.parser.rules.RepeatableRule
public class RepeatableRule extends ChoiceRule
name: [[rule]](option)
Repeatable rules are rules that are repeated sequencially one after the other in some form
option: ? means either the rule does not parse or it does once and only once, i.e. that it is made optional
means either the rule does not parse or it does any number of times
+ means the rule must parse at least once, and can parse any number of times after
-
Constructor Summary
Constructors Constructor Description RepeatableRule(java.lang.String aName, int aMin, int aMax)
RepeatableRule(java.lang.String name, int min, int max, ChoiceRule rule)
Takes one rule and the minimum number of repeats as well as the maximum -
Method Summary
Modifier and Type Method Description void
delete()
java.lang.String
getFirstValue()
The size of a repeatable rule can be 0 or 1 and, therefore can have the value of either "" or the value of it's one and only ruleint
getMax()
the maximum number of times the subrule should be considered to be able to parse(a max of 1 will not repeat more than once)int
getMin()
the minimum number of times the subrule can be parsed for this rule to be successfulboolean
isOptional()
returns true if optional, i.e.boolean
optimizeCondition()
For optimization, this object will be removed if it has no sub rules.int
parse(Token token, int from, int stop, java.lang.String input, ParserDataPackage data)
Tries to parse the subrule min<=times<=max.boolean
setMax(int aMax)
boolean
setMin(int aMin)
java.lang.StringBuilder
toDeclareString(java.lang.StringBuilder builder)
java.lang.String
toString()
Methods inherited from class cruise.umple.parser.rules.ChoiceRule
add, add, addAllTokens, addRule, addToken, dontCare, findPosition, get, getAction, getDeclared, getDontDelete, getFirstValueBuilder, getName, getNegate, getNoSpaces, getOptional, getParent, getReset, getRule, getRules, hasRules, indexOf, indexOfRule, isNoSpaces, numberOfRules, optimize, remove, remove, removeRule, resetDeclare, setAction, setDeclared, setDontDelete, setFirstValueBuilder, setName, setNegate, setNoSpaces, setOptional, setParent, setReset, setSubrules, size, toCannotBeString, toRedoRegexString
-
Constructor Details
-
RepeatableRule
public RepeatableRule(java.lang.String aName, int aMin, int aMax) -
RepeatableRule
Takes one rule and the minimum number of repeats as well as the maximum
-
-
Method Details
-
setMin
public boolean setMin(int aMin) -
setMax
public boolean setMax(int aMax) -
getMin
public int getMin()the minimum number of times the subrule can be parsed for this rule to be successful -
getMax
public int getMax()the maximum number of times the subrule should be considered to be able to parse(a max of 1 will not repeat more than once) -
delete
public void delete()- Overrides:
delete
in classChoiceRule
-
parse
Tries to parse the subrule min<=times<=max.- Overrides:
parse
in classChoiceRule
-
isOptional
public boolean isOptional()returns true if optional, i.e. if the min is 0 or the sub rule is optional- Overrides:
isOptional
in classChoiceRule
-
optimizeCondition
public boolean optimizeCondition()For optimization, this object will be removed if it has no sub rules.- Overrides:
optimizeCondition
in classChoiceRule
-
getFirstValue
public java.lang.String getFirstValue()The size of a repeatable rule can be 0 or 1 and, therefore can have the value of either "" or the value of it's one and only rule- Overrides:
getFirstValue
in classChoiceRule
-
toDeclareString
public java.lang.StringBuilder toDeclareString(java.lang.StringBuilder builder)- Overrides:
toDeclareString
in classChoiceRule
-
toString
public java.lang.String toString()- Overrides:
toString
in classChoiceRule
-