Class StringLiteralExpr

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

public class StringLiteralExpr extends LiteralStringValueExpr
A literal string.
"Hello World!"
"\"\n"
"™"
"™"
"💩"
Author:
Julio Vilmar Gesser
  • Constructor Details

    • StringLiteralExpr

      public StringLiteralExpr()
    • StringLiteralExpr

      public StringLiteralExpr(String value)
      Creates a string literal expression from given string. Escapes EOL characters.
      Parameters:
      value - the value of the literal
    • StringLiteralExpr

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

    • 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)
    • setEscapedValue

      public StringLiteralExpr setEscapedValue(String value)
      Sets the content of this expressions to given value. Escapes EOL characters.
      Parameters:
      value - the new literal value
      Returns:
      self
    • asString

      public String asString()
      Returns:
      the unescaped literal value
    • setString

      public StringLiteralExpr setString(String value)
      Escapes the given string from special characters and uses it as the literal value.
      Parameters:
      value - unescaped string
      Returns:
      this literal expression
    • clone

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

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

      public boolean isStringLiteralExpr()
      Overrides:
      isStringLiteralExpr in class Expression
    • asStringLiteralExpr

      public StringLiteralExpr asStringLiteralExpr()
      Overrides:
      asStringLiteralExpr in class Expression
    • ifStringLiteralExpr

      public void ifStringLiteralExpr(Consumer<StringLiteralExpr> action)
      Overrides:
      ifStringLiteralExpr in class Expression
    • toStringLiteralExpr

      public Optional<StringLiteralExpr> toStringLiteralExpr()
      Overrides:
      toStringLiteralExpr in class Expression