Class TextManager


  • public class TextManager
    extends Object
    Represents text manager. Responsible for managing current text, reading more text from the reader and checking if there is more text left.
    Author:
    loomchild
    • Constructor Detail

      • TextManager

        public TextManager​(CharSequence text)
        Creates text manager containing given text. Reading more text is not possible when using this constructor.
        Parameters:
        text -
      • TextManager

        public TextManager​(Reader reader,
                           int bufferLength)
        Creates text manager reading text from given reader. Only specified amount of memory for buffer will be used. Managed text will never be longer than given buffer size. Text is not actually read until required (lazy initialization).
        Parameters:
        reader -
        bufferLength - read buffer size
    • Method Detail

      • getBufferLength

        public int getBufferLength()
      • getText

        public CharSequence getText()
        Returns:
        current text
      • hasMoreText

        public boolean hasMoreText()
        Returns:
        true if more text can be read
      • readText

        public void readText​(int amount)
        Deletes given amount of characters from current character buffer and tries to read up to given amount of new characters and stores them in current character buffer.
        Parameters:
        amount - amount of characters to read
        Throws:
        IllegalArgumentException - if hasMoreText() returns false or amount is greater than buffer size