Class StringLiteral

All Implemented Interfaces:
ExportAgent, Locatable, IdentityComparable, Traceable

public class StringLiteral extends Literal
Subclass of Literal used specifically for string literals, as this is a common case
  • Constructor Details

    • StringLiteral

      public StringLiteral(StringValue value)
      Create a StringLiteral that wraps a StringValue
      Parameters:
      value - the StringValue
    • StringLiteral

      public StringLiteral(UnicodeString value)
      Create a StringLiteral that wraps any UnicodeString
      Parameters:
      value - the UnicodeString to be wrapped
    • StringLiteral

      public StringLiteral(String value)
      Create a StringLiteral that wraps a String
      Parameters:
      value - the String to be wrapped
  • Method Details

    • getGroundedValue

      public StringValue getGroundedValue()
      Get the value represented by this Literal
      Overrides:
      getGroundedValue in class Literal
      Returns:
      the constant value
    • getUnicodeString

      public UnicodeString getUnicodeString()
      Get the string represented by this StringLiteral, as a UnicodeString
      Returns:
      the underlying string
    • stringify

      public String stringify()
      Get the string represented by this StringLiteral, as a String
      Returns:
      the underlying string
    • copy

      public Expression copy(RebindingMap rebindings)
      Description copied from class: Literal
      Copy an expression. This makes a deep copy.
      Overrides:
      copy in class Literal
      Parameters:
      rebindings - variables that need to be re-bound
      Returns:
      a copy of the original literal. Note that the underlying value is not copied; the code relies on the caller treating the underlying value as immutable.
    • isInstance

      public boolean isInstance(SequenceType req, TypeHierarchy th)
      Test whether the value is an instance of a supplied type
      Overrides:
      isInstance in class Literal
      Parameters:
      req - the required type
      th - the type hierarchy cache
      Returns:
      true if the value is (strictly) an instance of the type, in the sense of the "instance of" operator
    • toShortString

      public String toShortString()
      Produce a short string identifying the expression for use in error messages
      Overrides:
      toShortString in class Literal
      Returns:
      a short string, sufficient to identify the expression