Class AbstractLengthLimitedStringBuilder
- java.lang.Object
-
- com.atlassian.confluence.search.v2.extractor.util.AbstractLengthLimitedStringBuilder
-
- Direct Known Subclasses:
StaticLengthLimitedStringBuilder
public abstract class AbstractLengthLimitedStringBuilder extends Object
This is a base class for string builders that limit their length.Instances of this class are not safe for use by multiple threads.
- Since:
- 8.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractLengthLimitedStringBuilder.LIMIT_BEHAVIOUR
Behaviour of the string builder when the limit is reached.
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilder
buffer
protected boolean
limitReached
protected AbstractLengthLimitedStringBuilder.LIMIT_BEHAVIOUR
throwWhenLimitReached
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AbstractLengthLimitedStringBuilder
append(char c)
AbstractLengthLimitedStringBuilder
append(char[] str, int offset, int len)
AbstractLengthLimitedStringBuilder
append(String s)
int
capacity()
boolean
isLimitReached()
int
length()
protected abstract int
limit()
protected boolean
limitReached(int length)
Checks if appending length characters to the string builder will reach the limit.protected int
remainingLength()
void
setLength(int l)
String
toString()
-
-
-
Field Detail
-
throwWhenLimitReached
protected final AbstractLengthLimitedStringBuilder.LIMIT_BEHAVIOUR throwWhenLimitReached
-
buffer
protected StringBuilder buffer
-
limitReached
protected boolean limitReached
-
-
Method Detail
-
setLength
public void setLength(int l)
-
length
public int length()
-
append
public AbstractLengthLimitedStringBuilder append(char[] str, int offset, int len)
-
append
public AbstractLengthLimitedStringBuilder append(char c)
-
append
public AbstractLengthLimitedStringBuilder append(String s)
-
remainingLength
protected int remainingLength()
-
limit
protected abstract int limit()
-
limitReached
protected boolean limitReached(int length)
Checks if appending length characters to the string builder will reach the limit.- Parameters:
length
-- Returns:
- true if the limit is reached, false otherwise
-
capacity
public int capacity()
-
isLimitReached
public boolean isLimitReached()
-
-