Package li.selman.jpbe.dsl.position
Class ConstantPosition
java.lang.Object
li.selman.jpbe.dsl.position.ConstantPosition
- All Implemented Interfaces:
DslElement
,Position
Denotes a constant index of a string.
If
constant
is positive, the index is counted from the left —
just like String.charAt(int)
.
If the constant is negative, the index is counted from the right.
In that case the last index of a string is denoted with the value in LAST_POSITION_INDEX
as
0 is already reserved for the "positive" index way of counting.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Given an input, dynamically evaluate to an index inside for string manipulation operations.int
The weight can be used to find an optimal program in a set of valid programs.int
hashCode()
static ConstantPosition
toString()
-
Constructor Details
-
ConstantPosition
public ConstantPosition(int constant) - Parameters:
constant
- signed integer denoting the index on any string
-
-
Method Details
-
lastPosition
-
evalToPosition
Description copied from interface:Position
Given an input, dynamically evaluate to an index inside for string manipulation operations.- Specified by:
evalToPosition
in interfacePosition
- Parameters:
s
- input- Returns:
- the index
-
getDslWeight
public int getDslWeight()Description copied from interface:DslElement
The weight can be used to find an optimal program in a set of valid programs. "Optimal" is subjective and can go into different directions. Some examples include:- Weight by how expensive a DSL element is to execute.
-
Weight by how likely a DSL element is to be part of a generic full program.
A ConstantPosition generally is less generic.
Thus, the user has to specify their intent more often to finish their wrangling task.
- Specified by:
getDslWeight
in interfaceDslElement
- Returns:
- the weight of the DSL element
-
equals
-
hashCode
public int hashCode() -
toString
-