public class OffsetEquation
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static OffsetEquation |
NEG_1 |
static OffsetEquation |
ONE |
static OffsetEquation |
ZERO |
Modifier and Type | Method and Description |
---|---|
OffsetEquation |
copyAdd(char op,
OffsetEquation other)
Adds or subtracts the other equation to a copy of this one.
|
static OffsetEquation |
createOffsetForInt(int value)
Creates an offset equation that is only the int value specified.
|
static OffsetEquation |
createOffsetFromJavaExpression(java.lang.String expressionEquation)
Creates an offset equation from the expressionEquation.
|
static OffsetEquation |
createOffsetFromNode(Node node,
AnnotationProvider factory,
char op)
Creates an offset equation from the Node.
|
static OffsetEquation |
createOffsetFromNodesValue(Node node,
ValueAnnotatedTypeFactory factory,
char op)
If node is an int value known at compile time, then the returned equation is just the int
value or if op is '-', the return equation is the negation of the int value.
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getError() |
int |
getInt()
Returns the int value associated with this equation.
|
static OffsetEquation |
getIntOffsetEquation(java.util.Set<OffsetEquation> equationSet)
Returns the offset equation that is an int value or null if there isn't one.
|
boolean |
hasError() |
int |
hashCode() |
boolean |
isInt()
Returns true if this equation is a single int value.
|
boolean |
isNegativeOrZero()
Returns true if this equation is negative or zero.
|
boolean |
isNegOne()
Returns true if this equation is exactly -1.
|
boolean |
isNonNegative()
Returns true if this equation non-negative.
|
boolean |
lessThanOrEqual(OffsetEquation other)
Returns whether or not this equation is known to be less than or equal to the other equation.
|
OffsetEquation |
removeSequenceLengths(java.util.List<java.lang.String> sequences)
Makes a copy of this offset and removes any added terms that are accesses to the length of
the listed sequences.
|
void |
standardizeAndViewpointAdaptExpressions(FlowExpressionParseUtil.FlowExpressionContext context,
TreePath scope,
boolean useLocalScope)
Standardizes and viewpoint-adapts the string terms based us the supplied context.
|
java.lang.String |
toString() |
public static final OffsetEquation ZERO
public static final OffsetEquation NEG_1
public static final OffsetEquation ONE
public boolean hasError()
public java.lang.String getError()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public OffsetEquation removeSequenceLengths(java.util.List<java.lang.String> sequences)
sequences
- list of sequences (arrays or strings)public OffsetEquation copyAdd(char op, OffsetEquation other)
If subtraction is specified, then every term in other is subtracted.
op
- '-' for subtraction or '+' for additionother
- equation to add or subtractpublic boolean lessThanOrEqual(OffsetEquation other)
other
- equationpublic boolean isInt()
public int getInt()
The equation may or may not have other terms. Use isInt()
to determine if the
equation is only this int value.
public boolean isNegOne()
public boolean isNonNegative()
public boolean isNegativeOrZero()
public void standardizeAndViewpointAdaptExpressions(FlowExpressionParseUtil.FlowExpressionContext context, TreePath scope, boolean useLocalScope) throws FlowExpressionParseUtil.FlowExpressionParseException
context
- FlowExpressionContextscope
- local scopeuseLocalScope
- whether or not local scope is usedFlowExpressionParseUtil.FlowExpressionParseException
- if any term isn't able to be parsed this exception is
thrown. If this happens, no string terms are changed.public static OffsetEquation getIntOffsetEquation(java.util.Set<OffsetEquation> equationSet)
equationSet
- a set of offset equationspublic static OffsetEquation createOffsetForInt(int value)
value
- int value of the equationpublic static OffsetEquation createOffsetFromJavaExpression(java.lang.String expressionEquation)
expressionEquation
- a Java expression made up of sums and differencespublic static OffsetEquation createOffsetFromNodesValue(Node node, ValueAnnotatedTypeFactory factory, char op)
Otherwise, null is returned.
node
- the Node from which to create an offset equationfactory
- AnnotationTypeFactoryop
- '+' or '-'public static OffsetEquation createOffsetFromNode(Node node, AnnotationProvider factory, char op)
If node is an addition or subtracted node, then this method is called recursively on the left and right hand nodes and the two equations are added/subtracted to each other depending on the value of op.
Otherwise the return equation is created by converting the node to a FlowExpressions.Receiver
and then added as a term to the returned equation. If op is '-'
then it is a subtracted term.
node
- the Node from which to create an offset equationfactory
- AnnotationTypeFactoryop
- '+' or '-'