Class CharBucket


  • class CharBucket
    extends java.lang.Object
    A buffer of characters.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) char[] data
      The bucket data
      (package private) int length
      The number of characters this bucket contain.
    • Constructor Summary

      Constructors 
      Constructor Description
      CharBucket​(int bucketSize)
      Creates a bucket capable of holding a fixed number of characters
      CharBucket​(int bucketSize, char fillWith)
      Creates a bucket capable of holding a fixed number of characters
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int fill​(java.io.Reader reader)
      Fills the bucket with the characters take from a Reader
      boolean isEmpty()
      Returns true if the bucket is empty (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • data

        final char[] data
        The bucket data
      • length

        int length
        The number of characters this bucket contain. It is modified every time fill(Reader) is called.
    • Constructor Detail

      • CharBucket

        public CharBucket​(int bucketSize)
        Creates a bucket capable of holding a fixed number of characters
        Parameters:
        bucketSize - the maximum capacity of the bucket
      • CharBucket

        public CharBucket​(int bucketSize,
                          char fillWith)
        Creates a bucket capable of holding a fixed number of characters
        Parameters:
        bucketSize - the maximum capacity of the bucket
        fillWith - a character used to fill all positions of the bucket.
    • Method Detail

      • fill

        public int fill​(java.io.Reader reader)
                 throws java.io.IOException
        Fills the bucket with the characters take from a Reader

        The length attribute will be updated with the number of characters extracted

        Parameters:
        reader - the source of characters used to fill the bucket
        Returns:
        the number of characters extracted from the reader
        Throws:
        java.io.IOException - if any error occurs while extracting characters from the reader
      • isEmpty

        public boolean isEmpty()
        Returns true if the bucket is empty (i.e. length <= 0), false otherwise.
        Returns:
        true if the bucket is empty (i.e. length <= 0), false otherwise.