Class StringWithPosition

java.lang.Object
net.ssehub.easy.dslCore.test.StringWithPosition

class StringWithPosition extends Object
A helper class for string comparisons.
Author:
Holger Eichelberger
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private char[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    char
    at()
    Returns the character at the actual position.
    char
    at(int inc)
    Returns the character at the actual position including the increment inc.
    void
    Consumes the line including the line end starting at the current position.
    void
    Consumes the line end starting at the current position.
    void
    Consumes the line until the line end starting at the current position.
    void
    inc()
    Increments the actual position by 1.
    void
    inc(int inc)
    Increments the actual position by inc.
    boolean
    Returns whether the actual position is in range.
    boolean
    inRange(int inc)
    Returns whether the actual position including the increment inc is in range.
    private boolean
    Returns whether the actual character is a line end character.
    int
    pos()
    Returns the actual position.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • string

      private char[] string
    • pos

      private int pos
  • Constructor Details

    • StringWithPosition

      public StringWithPosition(String string)
      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:
      true if the actual position is in range, false else
    • inc

      public void inc()
      Increments the actual position by 1.
    • inc

      public void inc(int inc)
      Increments the actual position by inc.
      Parameters:
      inc - the increment
    • inRange

      public boolean inRange(int inc)
      Returns whether the actual position including the increment inc is in range.
      Parameters:
      inc - the increment
      Returns:
      true if the specified position is in range, false else
    • at

      public char at(int inc)
      Returns the character at the actual position including the increment inc.
      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:
      true if it is a line end character, false else