Simple specialization of a
Var for StringBuilders.
Provides a few convenience helper methods.-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new StringVar with a null initial value.StringBuilderVar(StringBuilder value) Initializes a new StringBuilderVar with the given initial StringBuilder instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanappend(char c) Appends the given char.booleanAppends the given string.appended(char c) Appends the given char.Appends the given string.booleanClears the contents of the wrapped StringBuilder.Clears the contents of the wrapped StringBuilder.char[]getChars()booleanisEmpty()Returns true if the wrapped string is either null or empty.Methods inherited from class org.parboiled.support.Var
enterFrame, exitFrame, getLevel, getName, setName, toString
-
Constructor Details
-
StringBuilderVar
public StringBuilderVar()Initializes a new StringVar with a null initial value. -
StringBuilderVar
Initializes a new StringBuilderVar with the given initial StringBuilder instance.- Parameters:
value- the initial value
-
-
Method Details
-
isEmpty
Returns true if the wrapped string is either null or empty.- Returns:
- true if the wrapped string is either null or empty
-
getString
- Returns:
- the String representation of the underlying StringBuilder.
-
getChars
- Returns:
- the char[] representation of the underlying StringBuilder.
-
append
Appends the given string. If this instance is currently uninitialized the given string is used for initialization.- Parameters:
text- the text to append- Returns:
- true
-
appended
Appends the given string. If this instance is currently uninitialized the given string is used for initialization.- Parameters:
text- the text to append- Returns:
- this instance
-
append
Appends the given char. If this instance is currently uninitialized the given char is used for initialization.- Parameters:
c- the char to append- Returns:
- true
-
appended
Appends the given char. If this instance is currently uninitialized the given char is used for initialization.- Parameters:
c- the char to append- Returns:
- this instance
-
clearContents
Clears the contents of the wrapped StringBuilder. If the instance is currently unintialized this method does nothing.- Returns:
- true
-
contentsCleared
Clears the contents of the wrapped StringBuilder. If the instance is currently unintialized this method does nothing.- Returns:
- this instance
-