Package net.ssehub.easy.dslCore.test
Class StringWithPosition
- java.lang.Object
-
- net.ssehub.easy.dslCore.test.StringWithPosition
-
class StringWithPosition extends java.lang.ObjectA helper class for string comparisons.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Constructor Description StringWithPosition(java.lang.String string)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charat()Returns the character at the actual position.charat(int inc)Returns the character at the actual position including the incrementinc.voidconsumeLine()Consumes the line including the line end starting at the current position.voidconsumeLineEnd()Consumes the line end starting at the current position.voidconsumeLineUntilEnd()Consumes the line until the line end starting at the current position.voidinc()Increments the actual position by 1.voidinc(int inc)Increments the actual position byinc.booleaninRange()Returns whether the actual position is in range.booleaninRange(int inc)Returns whether the actual position including the incrementincis in range.private booleanisLineEnd()Returns whether the actual character is a line end character.intpos()Returns the actual position.
-
-
-
Method Detail
-
pos
public int pos()
Returns the actual position.- Returns:
- the actual position
-
at
public char at()
Returns the character at the actual position.- Returns:
- the character at the actual position
- Throws:
java.lang.IndexOutOfBoundsException- in case that the position is invalid
-
inRange
public boolean inRange()
Returns whether the actual position is in range.- Returns:
trueif the actual position is in range,falseelse
-
inc
public void inc()
Increments the actual position by 1.
-
inc
public void inc(int inc)
Increments the actual position byinc.- Parameters:
inc- the increment
-
inRange
public boolean inRange(int inc)
Returns whether the actual position including the incrementincis in range.- Parameters:
inc- the increment- Returns:
trueif the specified position is in range,falseelse
-
at
public char at(int inc)
Returns the character at the actual position including the incrementinc.- Parameters:
inc- the increment- Returns:
- the character at the actual position
- Throws:
java.lang.IndexOutOfBoundsException- in case that the specified position is invalid
-
consumeLineEnd
public void consumeLineEnd()
Consumes the line end starting at the current position.
-
consumeLineUntilEnd
public void consumeLineUntilEnd()
Consumes the line until the line end starting at the current position.
-
consumeLine
public void consumeLine()
Consumes the line including the line end starting at the current position.
-
isLineEnd
private boolean isLineEnd()
Returns whether the actual character is a line end character.- Returns:
trueif it is a line end character,falseelse
-
-