Package org.parboiled.support
Class StringBuilderVar
- java.lang.Object
-
- org.parboiled.common.Reference<T>
-
- org.parboiled.support.Var<StringBuilder>
-
- org.parboiled.support.StringBuilderVar
-
public class StringBuilderVar extends Var<StringBuilder>
Simple specialization of aVar
for StringBuilders. Provides a few convenience helper methods.
-
-
Constructor Summary
Constructors Constructor Description StringBuilderVar()
Initializes a new StringVar with a null initial value.StringBuilderVar(StringBuilder value)
Initializes a new StringBuilderVar with the given initial StringBuilder instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
append(char c)
Appends the given char.boolean
append(String text)
Appends the given string.StringBuilderVar
appended(char c)
Appends the given char.StringBuilderVar
appended(String text)
Appends the given string.boolean
clearContents()
Clears the contents of the wrapped StringBuilder.StringBuilderVar
contentsCleared()
Clears the contents of the wrapped StringBuilder.char[]
getChars()
String
getString()
boolean
isEmpty()
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 Detail
-
StringBuilderVar
public StringBuilderVar()
Initializes a new StringVar with a null initial value.
-
StringBuilderVar
public StringBuilderVar(StringBuilder value)
Initializes a new StringBuilderVar with the given initial StringBuilder instance.- Parameters:
value
- the initial value
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Returns true if the wrapped string is either null or empty.- Returns:
- true if the wrapped string is either null or empty
-
getString
public String getString()
- Returns:
- the String representation of the underlying StringBuilder.
-
getChars
public char[] getChars()
- Returns:
- the char[] representation of the underlying StringBuilder.
-
append
public boolean append(String text)
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
public StringBuilderVar appended(String text)
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
public boolean append(char c)
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
public StringBuilderVar appended(char c)
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
public boolean clearContents()
Clears the contents of the wrapped StringBuilder. If the instance is currently unintialized this method does nothing.- Returns:
- true
-
contentsCleared
public StringBuilderVar contentsCleared()
Clears the contents of the wrapped StringBuilder. If the instance is currently unintialized this method does nothing.- Returns:
- this instance
-
-