Class StringBuilders.Repeat

java.lang.Object
org.apache.sis.util.StringBuilders.Repeat
All Implemented Interfaces:
CharSequence
Enclosing class:
StringBuilders

private static final class StringBuilders.Repeat extends Object implements CharSequence
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

    Fields
    Modifier and Type
    Field
    Description
    private 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
    Constructor
    Description
    Repeat(char c, int n)
    Creates a new sequence of constant character.
  • Method Summary

    Modifier and Type
    Method
    Description
    char
    charAt(int i)
    Returns the constant character, regardless the index.
    int
    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

      static final StringBuilders.Repeat ZERO
      An infinite sequence of '0' character.
    • c

      private final char c
      The character to repeat.
    • n

      private final int n
      Number 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 interface CharSequence
    • charAt

      public char charAt(int i)
      Returns the constant character, regardless the index.
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Returns a sequence of the same constant character but different length.
      Specified by:
      subSequence in interface CharSequence