Class Char

  • All Implemented Interfaces:
    Position

    public class Char
    extends java.lang.Object
    implements Position
    Represents a single character read from a LookaheadReader.

    Provides the value as well as an exact position of the character in the stream. Also some test methods are provided to determine the character class of the internal value.

    See Also:
    LookaheadReader
    • Field Summary

      • Fields inherited from interface ca.solostudios.strata.parser.tokenizer.Position

        UNKNOWN
    • Constructor Summary

      Constructors 
      Constructor Description
      Char​(char value, int pos)
      Constructs a new Char with the provided value and position
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      int getPos()
      Returns the character position within the line of this position
      @NotNull java.lang.String getStringValue()
      Returns the internal value as string.
      char getValue()
      Returns the value of this char.
      int hashCode()  
      boolean is​(char test)
      Checks if the internal value is equal to the given character
      boolean is​(char... tests)
      Checks if the internal value is one of the given characters
      boolean isAlphaNumeric()
      Determines if the value is an alphanumeric identifier (0..9, a..z, A..Z, -)
      boolean isDigit()
      Determines if the value is a digit (0..9)
      boolean isEndOfInput()
      Determines if this instance represents the end of input indicator
      boolean isLetter()
      Determines if the value is a letter (a..z, A..Z)
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Char

        public Char​(char value,
                    int pos)
        Constructs a new Char with the provided value and position
        Parameters:
        value - The value of this character.
        pos - The position of this character.
    • Method Detail

      • is

        public boolean is​(char test)
        Checks if the internal value is equal to the given character
        Parameters:
        test - the character to check against
        Returns:
        true if the value is equal to the give characters, false otherwise
      • is

        public boolean is​(char... tests)
        Checks if the internal value is one of the given characters
        Parameters:
        tests - the characters to check against
        Returns:
        true if the value equals to one of the give characters, false otherwise
      • getValue

        public char getValue()
        Returns the value of this char.
        Returns:
        the internal value read from the stream
      • isAlphaNumeric

        public boolean isAlphaNumeric()
        Determines if the value is an alphanumeric identifier (0..9, a..z, A..Z, -)
        Returns:
        true if the internal value is a letter, false otherwise
      • isDigit

        public boolean isDigit()
        Determines if the value is a digit (0..9)
        Returns:
        true if the internal value is a digit, false otherwise
      • isLetter

        public boolean isLetter()
        Determines if the value is a letter (a..z, A..Z)
        Returns:
        true if the internal value is a letter, false otherwise
      • isEndOfInput

        public boolean isEndOfInput()
        Determines if this instance represents the end of input indicator
        Returns:
        true if this instance represents the end of the underlying input, false otherwise
      • getStringValue

        @NotNull
        public @NotNull java.lang.String getStringValue()
        Returns the internal value as string.
        Returns:
        the internal character as string or "" if this is the end of input indicator
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getPos

        public int getPos()
        Description copied from interface: Position
        Returns the character position within the line of this position
        Specified by:
        getPos in interface Position
        Returns:
        the one-based character position of this