Class StringPiece
java.lang.Object
net.diversionmc.parser.util.Pointable
net.diversionmc.parser.expression.ExpressionPiece
net.diversionmc.parser.expression.StringPiece
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.Stringcontent()Get content of the string stored in this piece.static charescape(char c)Escape a character (replace by an associated code, for example '\n' -> 'n').static java.lang.Stringescape(java.lang.CharSequence s)Escape characters in the string.PieceResultread(char c, FilePointer ptr)Parse a character by this piece.java.lang.StringtoString()Content wrapped with start and end characters.Methods inherited from class net.diversionmc.parser.expression.ExpressionPiece
replaceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
StringPiece
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
Description copied from class:ExpressionPieceParse a character by this piece.- Specified by:
readin classExpressionPiece- 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:
toStringin classjava.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.
-