Class CharArrayWrapperSequence

  • All Implemented Interfaces:
    java.lang.CharSequence, java.lang.Cloneable

    public final class CharArrayWrapperSequence
    extends java.lang.Object
    implements java.lang.CharSequence, java.lang.Cloneable

    Wrapper class that allows the use of char[] objects as CharSequences, without the need to duplicate the char[] contents in memory (as would happen if a String was created from the char[]).

    Note that a reference to the original char[] is kept, so modifying this char[] outside this object will result in this object's contents being modified too.

    Objects of this class are thread-safe.

    Since:
    2.0.15
    • Field Detail

      • buffer

        private final char[] buffer
      • offset

        private final int offset
      • len

        private final int len
    • Constructor Detail

      • CharArrayWrapperSequence

        public CharArrayWrapperSequence​(char[] array)
      • CharArrayWrapperSequence

        public CharArrayWrapperSequence​(char[] buffer,
                                        int offset,
                                        int len)
    • Method Detail

      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • length

        public int length()
        Specified by:
        length in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence​(int start,
                                                  int end)
        Specified by:
        subSequence in interface java.lang.CharSequence
      • clone

        protected CharArrayWrapperSequence clone()
                                          throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object