Class NamePiece


public class NamePiece extends ExpressionPiece
Reads letters, digits, and some predefined characters.
  • Constructor Details

    • NamePiece

      public NamePiece(FilePointer ptr, String specialChars)
      Construct a name piece at a position.
      Parameters:
      ptr - Creation position.
      specialChars - Additional characters to read.
  • Method Details

    • read

      public PieceResult read(char c, FilePointer ptr)
      Description copied from class: ExpressionPiece
      Parse a character by this piece.
      Specified by:
      read in class ExpressionPiece
      Parameters:
      c - Character to parse.
      ptr - Character position in file.
      Returns:
      PieceResult
    • name

      public String name()
      Get parsed value of the name piece.
      Returns:
      Name piece value.
    • toString

      public String toString()
      Get parsed value of the name piece.
      Overrides:
      toString in class Object
      Returns:
      name()
    • check

      public static boolean check(char c, String specialChars)
      Check whether a character can be read by a name piece with given special chars.
      Parameters:
      c - Character to check.
      specialChars - Additional characters to read.
      Returns:
      True if character is a letter, digit, or in the specialChars supplied.