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 char
The character to repeat.private final int
Number of times the character is repeated.(package private) static final StringBuilders.Repeat
An infinite sequence of'0'
character. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int i) Returns the constant character, regardless the index.int
length()
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, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty, 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:
length
in interfaceCharSequence
-
charAt
public char charAt(int i) Returns the constant character, regardless the index.- Specified by:
charAt
in interfaceCharSequence
-
subSequence
Returns a sequence of the same constant character but different length.- Specified by:
subSequence
in interfaceCharSequence
-