Class Char
- java.lang.Object
-
- ca.solostudios.strata.parser.tokenizer.Char
-
- All Implemented Interfaces:
Position
public class Char extends java.lang.Object implements Position
Represents a single character read from aLookaheadReader
.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
-
-
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 characterboolean
is(char... tests)
Checks if the internal value is one of the given charactersboolean
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 indicatorboolean
isLetter()
Determines if the value is a letter (a..z, A..Z)java.lang.String
toString()
-
-
-
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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-