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 booleanequals(java.lang.Object o)intgetPos()Returns the character position within the line of this position@NotNull java.lang.StringgetStringValue()Returns the internal value as string.chargetValue()Returns the value of this char.inthashCode()booleanis(char test)Checks if the internal value is equal to the given characterbooleanis(char... tests)Checks if the internal value is one of the given charactersbooleanisAlphaNumeric()Determines if the value is an alphanumeric identifier (0..9, a..z, A..Z, -)booleanisDigit()Determines if the value is a digit (0..9)booleanisEndOfInput()Determines if this instance represents the end of input indicatorbooleanisLetter()Determines if the value is a letter (a..z, A..Z)java.lang.StringtoString()
-
-
-
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:
trueif the value is equal to the give characters,falseotherwise
-
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:
trueif the value equals to one of the give characters,falseotherwise
-
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:
trueif the internal value is a letter,falseotherwise
-
isDigit
public boolean isDigit()
Determines if the value is a digit (0..9)- Returns:
trueif the internal value is a digit,falseotherwise
-
isLetter
public boolean isLetter()
Determines if the value is a letter (a..z, A..Z)- Returns:
trueif the internal value is a letter,falseotherwise
-
isEndOfInput
public boolean isEndOfInput()
Determines if this instance represents the end of input indicator- Returns:
trueif this instance represents the end of the underlying input,falseotherwise
-
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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-