Class StringPiece

java.lang.Object

public class StringPiece
extends ExpressionPiece
Reads a string with escape sequences until it meets an end character (typically double or single quote).
  • Constructor Summary

    Constructors
    Constructor Description
    StringPiece​(FilePointer ptr, char end)
    Construct a String Piece.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String content()
    Get content of the string stored in this piece.
    static char escape​(char c)
    Escape a character (replace by an associated code, for example '\n' -> 'n').
    static java.lang.String escape​(java.lang.CharSequence s)
    Escape characters in the string.
    PieceResult read​(char c, FilePointer ptr)
    Parse a character by this piece.
    java.lang.String toString()
    Content wrapped with start and end characters.

    Methods inherited from class net.diversionmc.parser.expression.ExpressionPiece

    replace

    Methods inherited from class net.diversionmc.parser.util.Pointable

    pointer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • StringPiece

      public StringPiece​(FilePointer ptr, char end)
      Construct a String Piece.
      Parameters:
      ptr - Creation pointer.
      end - Character that the string will end with. Does not have to be same as opening character.
  • 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
    • content

      public java.lang.String content()
      Get content of the string stored in this piece.
      Returns:
      String value.
    • toString

      public java.lang.String toString()
      Content wrapped with start and end characters.
      Overrides:
      toString in class java.lang.Object
      Returns:
      start + escape(CharSequence) + end
    • escape

      public static char escape​(char c)
      Escape a character (replace by an associated code, for example '\n' -> 'n').
      Parameters:
      c - Character to escape.
      Returns:
      Escaped character.
    • escape

      public static java.lang.String escape​(java.lang.CharSequence s)
      Escape characters in the string.
      Parameters:
      s - String to escape.
      Returns:
      Escaped string.