Class CharLiteralExpr

All Implemented Interfaces:
NodeWithRange<Node>, NodeWithTokenRange<Node>, Observable, Visitable, HasParentNode<Node>, Cloneable

public class CharLiteralExpr extends LiteralStringValueExpr
A literal character.
'a'
'\t'
'Ω'
'\177'
'💩'
Author:
Julio Vilmar Gesser
  • Constructor Details

    • CharLiteralExpr

      public CharLiteralExpr()
    • CharLiteralExpr

      public CharLiteralExpr(String value)
    • CharLiteralExpr

      public CharLiteralExpr(char value)
      Constructs a CharLiteralExpr with given escaped character.
      Parameters:
      value - a char
    • CharLiteralExpr

      public CharLiteralExpr(TokenRange tokenRange, String value)
      This constructor is used by the parser and is considered private.
  • Method Details

    • escape

      public static CharLiteralExpr escape(String string)
      Utility method that creates a new StringLiteralExpr. Escapes EOL characters.
    • accept

      public <R,​ A> R accept(GenericVisitor<R,​A> v, A arg)
      Description copied from interface: Visitable
      Accept method for visitor support.
      Type Parameters:
      R - the type of the return value of the visitor
      A - the type the user argument passed to the visitor
      Parameters:
      v - the visitor implementation
      arg - the argument passed to the visitor (of type A)
      Returns:
      the result of the visit (of type R)
    • accept

      public <A> void accept(VoidVisitor<A> v, A arg)
      Description copied from interface: Visitable
      Accept method for visitor support.
      Type Parameters:
      A - the type the argument passed for the visitor
      Parameters:
      v - the visitor implementation
      arg - any value relevant for the visitor (of type A)
    • asChar

      public char asChar()
      Returns:
      the unescaped value character of this literal
    • setChar

      public CharLiteralExpr setChar(char value)
      Sets the given char as the literal value
      Parameters:
      value - a char
      Returns:
      this expression
    • clone

      public CharLiteralExpr clone()
      Overrides:
      clone in class LiteralStringValueExpr
    • getMetaModel

      public CharLiteralExprMetaModel getMetaModel()
      Overrides:
      getMetaModel in class LiteralStringValueExpr
      Returns:
      get JavaParser specific node introspection information.
    • isCharLiteralExpr

      public boolean isCharLiteralExpr()
      Overrides:
      isCharLiteralExpr in class Expression
    • asCharLiteralExpr

      public CharLiteralExpr asCharLiteralExpr()
      Overrides:
      asCharLiteralExpr in class Expression
    • ifCharLiteralExpr

      public void ifCharLiteralExpr(Consumer<CharLiteralExpr> action)
      Overrides:
      ifCharLiteralExpr in class Expression
    • toCharLiteralExpr

      public Optional<CharLiteralExpr> toCharLiteralExpr()
      Overrides:
      toCharLiteralExpr in class Expression