Class ReaderCharSequence

  • All Implemented Interfaces:
    CharSequence

    public class ReaderCharSequence
    extends Object
    implements CharSequence
    Adapter of reader class to CharSequence interface. Due to behavior differences CharSequence is not implemented perfectly.
    Author:
    loomchild
    • Field Detail

      • INFINITE_LENGTH

        public static final int INFINITE_LENGTH
        Value to be used as length when it is unknown. It must be less than Integer.MAX_VALUE because some code may add something to length.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ReaderCharSequence

        public ReaderCharSequence​(Reader reader,
                                  int bufferLength,
                                  int length,
                                  int lookahead)
        Create.
        Parameters:
        reader - reader from which char sequence will be read
        bufferLength - size of the character buffer
        length - length of the input; when it cannot be determined it can be set to INFINITE_LENGTH (max value); cannot be set to Integer.MAX_VALUE because it may cause overflow.
        lookahead - number of characters to read after current position
      • ReaderCharSequence

        public ReaderCharSequence​(Reader reader,
                                  int bufferLength,
                                  int length)
      • ReaderCharSequence

        public ReaderCharSequence​(Reader reader,
                                  int bufferLength)
      • ReaderCharSequence

        public ReaderCharSequence​(Reader reader)
    • Method Detail

      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface CharSequence
      • subSequence

        public CharSequence subSequence​(int start,
                                        int end)
        The length of returned subsequence can be smaller than (end - start) when the end of stream is reached.
        Specified by:
        subSequence in interface CharSequence