Package org.apache.sis.util
Class StringBuilders.Repeat
java.lang.Object
org.apache.sis.util.StringBuilders.Repeat
- All Implemented Interfaces:
CharSequence
- Enclosing class:
- StringBuilders
A sequence of a constant character. This implementation does not perform any argument
check since it is for
StringBuilder.append(CharSequence, int, int) usage only.
The intent is to allow StringBuilder to append the characters in one operation
instead of looping on StringBuilder.insert(int, char) (which would require
memory move on each call).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final charThe character to repeat.private final intNumber of times the character is repeated.(package private) static final StringBuilders.RepeatAn infinite sequence of'0'character. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int i) Returns the constant character, regardless the index.intlength()Returns the number of times the character is repeated.subSequence(int start, int end) Returns a sequence of the same constant character but different length.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, toString
-
Field Details
-
ZERO
An infinite sequence of'0'character. -
c
private final char cThe character to repeat. -
n
private final int nNumber of times the character is repeated.
-
-
Constructor Details
-
Repeat
Repeat(char c, int n) Creates a new sequence of constant character.
-
-
Method Details
-
length
public int length()Returns the number of times the character is repeated.- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int i) Returns the constant character, regardless the index.- Specified by:
charAtin interfaceCharSequence
-
subSequence
Returns a sequence of the same constant character but different length.- Specified by:
subSequencein interfaceCharSequence
-