Class OffsetEquation
java.lang.Object
org.checkerframework.checker.index.upperbound.OffsetEquation
An offset equation is 2 sets of Java expression strings, one set of added terms and one set of
 subtracted terms, and a single integer constant. The Java expression strings have been
 standardized and viewpoint-adapted.
 
An OffsetEquation is mutable.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final OffsetEquationThe equation for -1.static final OffsetEquationThe equation for 1.static final OffsetEquationThe equation for 0 (zero).
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedOffsetEquation(OffsetEquation other) Create a new OffsetEquation that is a copy of the given one.
- 
Method SummaryModifier and TypeMethodDescriptioncopyAdd(char op, OffsetEquation other) Adds or subtracts the other equation to a copy of this one.static OffsetEquationcreateOffsetForInt(int value) Creates an offset equation that is only the int value specified.static OffsetEquationcreateOffsetFromJavaExpression(String expressionEquation) Creates an offset equation from the expressionEquation.static OffsetEquationcreateOffsetFromNode(Node node, AnnotationProvider factory, char op) Creates an offset equation from the Node.static OffsetEquationcreateOffsetFromNodesValue(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.booleangetError()intgetInt()Returns the int value associated with this equation.static OffsetEquationgetIntOffsetEquation(Set<OffsetEquation> equationSet) Returns the offset equation that is an int value or null if there isn't one.booleanhasError()inthashCode()booleanisInt()Returns true if this equation is a single int value.booleanReturns true if this equation is negative or zero.booleanisNegOne()Returns true if this equation is exactly -1.booleanReturns true if this equation non-negative.booleanlessThanOrEqual(OffsetEquation other) Returns whether or not this equation is known to be less than or equal to the other equation.removeSequenceLengths(List<String> sequences) Makes a copy of this offset and removes any added terms that are accesses to the length of the listed sequences.toString()
- 
Field Details- 
ZEROThe equation for 0 (zero).
- 
NEG_1The equation for -1.
- 
ONEThe equation for 1.
 
- 
- 
Constructor Details- 
OffsetEquationCreate a new OffsetEquation that is a copy of the given one.- Parameters:
- other- the OffsetEquation to copy
 
 
- 
- 
Method Details- 
hasErrorpublic boolean hasError()
- 
getError
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
- 
removeSequenceLengthsMakes a copy of this offset and removes any added terms that are accesses to the length of the listed sequences. If any terms were removed, then the copy is returned. Otherwise, null is returned.- Parameters:
- sequences- list of sequences (arrays or strings)
- Returns:
- a copy of this equation with array.length and string.length() removed or null if no array.lengths or string.length() could be removed
 
- 
copyAddAdds or subtracts the other equation to a copy of this one.If subtraction is specified, then every term in other is subtracted. - Parameters:
- op- '-' for subtraction or '+' for addition
- other- equation to add or subtract
- Returns:
- a copy of this equation +/- other
 
- 
lessThanOrEqualReturns whether or not this equation is known to be less than or equal to the other equation.- Parameters:
- other- equation
- Returns:
- whether or not this equation is known to be less than or equal to the other equation
 
- 
isIntpublic boolean isInt()Returns true if this equation is a single int value.- Returns:
- true if this equation is a single int value
 
- 
getIntpublic int getInt()Returns the int value associated with this equation.The equation may or may not have other terms. Use isInt()to determine if the equation is only this int value.- Returns:
- the int value associated with this equation
 
- 
isNegOnepublic boolean isNegOne()Returns true if this equation is exactly -1.- Returns:
- true if this equation is exactly -1
 
- 
isNonNegativepublic boolean isNonNegative()Returns true if this equation non-negative.- Returns:
- true if this equation non-negative
 
- 
isNegativeOrZeropublic boolean isNegativeOrZero()Returns true if this equation is negative or zero.- Returns:
- true if this equation is negative or zero
 
- 
getIntOffsetEquationReturns the offset equation that is an int value or null if there isn't one.- Parameters:
- equationSet- a set of offset equations
- Returns:
- the offset equation that is an int value or null if there isn't one
 
- 
createOffsetForIntCreates an offset equation that is only the int value specified.- Parameters:
- value- int value of the equation
- Returns:
- an offset equation that is only the int value specified
 
- 
createOffsetFromJavaExpressionCreates an offset equation from the expressionEquation. The expressionEquation may be several Java expressions added or subtracted from each other. The expressionEquation may also start with + or -. If the expressionEquation is the empty string, then the offset equation returned is zero.- Parameters:
- expressionEquation- a Java expression made up of sums and differences
- Returns:
- an offset equation created from expressionEquation
 
- 
createOffsetFromNodesValuepublic 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.Otherwise, null is returned. - Parameters:
- node- the Node from which to create an offset equation
- factory- an AnnotationTypeFactory
- op- '+' or '-'
- Returns:
- an offset equation from value of known or null if the value isn't known
 
- 
createOffsetFromNodeCreates an offset equation from the Node.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 JavaExpressionand then added as a term to the returned equation. If op is '-' then it is a subtracted term.- Parameters:
- node- the Node from which to create an offset equation
- factory- an AnnotationTypeFactory
- op- '+' or '-'
- Returns:
- an offset equation from the Node
 
 
-