Class StringPiece
java.lang.Object
net.diversionmc.parser.util.Pointable
net.diversionmc.parser.expression.ExpressionPiece
net.diversionmc.parser.expression.StringPiece
Reads a string with escape sequences until it meets an end character (typically double or single quote).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontent()Get content of the string stored in this piece.static Stringescape(char c) Escape a character (replace by an associated code with escape prefix, for example '\n' -> "\\n").static StringEscape characters in the string.read(char c, FilePointer ptr) Parse a character by this piece.toString()Content wrapped with start and end characters.Methods inherited from class net.diversionmc.parser.expression.ExpressionPiece
replace
-
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
Get content of the string stored in this piece.- Returns:
- String value.
-
toString
Content wrapped with start and end characters.- Overrides:
toStringin classObject- Returns:
- start +
escape(CharSequence)+ end
-
escape
Escape a character (replace by an associated code with escape prefix, for example '\n' -> "\\n").- Parameters:
c- Character to escape.- Returns:
- Escaped character.
-
escape
Escape characters in the string.- Parameters:
s- String to escape.- Returns:
- Escaped string.
-