Class VariableElement
Object
com.owenfeehan.pathpatternfinder.patternelements.PatternElement
com.owenfeehan.pathpatternfinder.patternelements.resolved.ResolvedPatternElement
com.owenfeehan.pathpatternfinder.patternelements.resolved.VariableElement
public abstract class VariableElement extends ResolvedPatternElement
A
PatternElement
that is resolved and varies across the list of values.- Author:
- Owen Feehan
-
Constructor Summary
Constructors Modifier Constructor Description protected
VariableElement(List<String> values)
Creates for a list of values. -
Method Summary
Modifier and Type Method Description boolean
equals(Object obj)
protected List<String>
getValues()
The values that describe the variable element, identical to those passed to the constructor.boolean
hasConstantValue()
Does the element never vary?int
hashCode()
void
reverse()
Reverses the current element.String
valueAt(int index)
The value of the element for a particular string used during pattern extraction.Methods inherited from class com.owenfeehan.pathpatternfinder.patternelements.resolved.ResolvedPatternElement
isResolved, resolve
Methods inherited from class com.owenfeehan.pathpatternfinder.patternelements.PatternElement
describe, extractElementFrom, reverseReturn, toString
-
Constructor Details
-
VariableElement
Creates for a list of values.- Parameters:
values
- the varying values, respectively corresponding to each string from which the pattern was extracted.
-
-
Method Details
-
hasConstantValue
public boolean hasConstantValue()Description copied from class:PatternElement
Does the element never vary?- Specified by:
hasConstantValue
in classPatternElement
- Returns:
- true iff this element have a constant value. Otherwise the element has multiple
possible values. Iff true,
PatternElement.describe(int)
should return this constant value
-
reverse
public void reverse()Description copied from class:PatternElement
Reverses the current element.i.e. if the string was previously applied from left to right it is now, right to left and vice-versa
- Specified by:
reverse
in classPatternElement
-
equals
- Overrides:
equals
in classPatternElement
-
hashCode
public int hashCode()- Overrides:
hashCode
in classPatternElement
-
valueAt
Description copied from class:PatternElement
The value of the element for a particular string used during pattern extraction.When {
PatternElement.hasConstantValue()
is true, theindex
is irrelevant, as the same value will always be returned.The value exists when {
PatternElement.isResolved()
is true, and should only be called on elements in this state. Otherwise, anIllegalStateException
will be thrown.- Specified by:
valueAt
in classPatternElement
- Parameters:
index
- the index (zero-valued) of the corresponding string (as passed during pattern extraction to initialize elements) for which we wish to establish a value.- Returns:
- the established value.
-
getValues
The values that describe the variable element, identical to those passed to the constructor.- Returns:
- the values.
-