Package net.ssehub.easy.dslCore.test
Class StringWithPosition
java.lang.Object
net.ssehub.easy.dslCore.test.StringWithPosition
A helper class for string comparisons.
- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncharat()Returns the character at the actual position.charat(int inc) Returns the character at the actual position including the incrementinc.voidConsumes the line including the line end starting at the current position.voidConsumes the line end starting at the current position.voidConsumes 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 booleanReturns whether the actual character is a line end character.intpos()Returns the actual position.
-
Field Details
-
string
private char[] string -
pos
private int pos
-
-
Constructor Details
-
StringWithPosition
Creates a new instance.- Parameters:
string- the string to be stored
-
-
Method Details
-
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:
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:
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
-