Class BufferChunk

  • All Implemented Interfaces:
    Chunk

    public class BufferChunk
    extends java.lang.Object
    implements Chunk
    Buffer chunk representation. Helps HTTP module to avoid redundant String creation.
    Author:
    Alexey Stashok
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferChunk()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void allocate​(int size)  
      void append​(BufferChunk bc)  
      int compare​(int start, int end, java.lang.String compareTo)  
      int compareIgnoreCase​(int start, int end, java.lang.String compareTo)  
      void delete​(int start, int end)  
      boolean equals​(byte[] b)
      Compares the message Buffer to the specified byte array.
      boolean equals​(byte[] b, int offset, int len)
      Compares the message Buffer to the specified byte array.
      static boolean equals​(byte[] c, int cOff, int cLen, Buffer t, int tOff, int tLen)  
      boolean equals​(char[] b, int offset, int len)
      Compares the message Buffer to the specified char array.
      boolean equals​(java.lang.CharSequence s)  
      boolean equals​(java.lang.Object o)  
      boolean equalsIgnoreCase​(byte[] b)  
      boolean equalsIgnoreCase​(byte[] b, int offset, int len)  
      boolean equalsIgnoreCase​(char[] b, int offset, int len)
      Compares the message Buffer to the specified char array ignoring case considerations.
      boolean equalsIgnoreCase​(java.lang.CharSequence s)  
      boolean equalsIgnoreCase​(java.lang.Object o)  
      boolean equalsIgnoreCaseLowerCase​(byte[] b)
      Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.
      static boolean equalsIgnoreCaseLowerCase​(Buffer buffer, int start, int end, byte[] cmpTo)
      Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.
      int findBytesAscii​(byte[] b)
      Returns the starting index of the specified byte sequence within this Buffer.
      Buffer getBuffer()  
      int getEnd()  
      int getLength()  
      int getStart()  
      int hash()  
      int hashCode()  
      int indexOf​(char c, int fromIndex)  
      int indexOf​(java.lang.String s, int fromIndex)  
      static int indexOf​(Buffer buffer, int off, int end, char qq)  
      static int indexOf​(Buffer buffer, int off, int end, java.lang.CharSequence s)  
      boolean isNull()  
      protected void notifyDirectUpdate()
      Notify the Chunk that its content is going to be changed directly
      void recycle()  
      protected void reset()  
      protected void resetStringCache()  
      void setBuffer​(Buffer buffer)  
      void setBufferChunk​(Buffer buffer, int start, int end)  
      void setBufferChunk​(Buffer buffer, int start, int end, int limit)  
      void setEnd​(int end)  
      void setStart​(int start)  
      static boolean startsWith​(Buffer buffer, int start, int end, byte[] cmpTo)  
      boolean startsWithIgnoreCase​(java.lang.String s, int pos)  
      java.lang.String toString()  
      java.lang.String toString​(int start, int end)  
      java.lang.String toString​(java.nio.charset.Charset charset)  
      void trimLeft()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BufferChunk

        public BufferChunk()
    • Method Detail

      • setBufferChunk

        public void setBufferChunk​(Buffer buffer,
                                   int start,
                                   int end)
      • setBufferChunk

        public void setBufferChunk​(Buffer buffer,
                                   int start,
                                   int end,
                                   int limit)
      • getBuffer

        public Buffer getBuffer()
      • setBuffer

        public void setBuffer​(Buffer buffer)
      • getStart

        public int getStart()
        Specified by:
        getStart in interface Chunk
      • setStart

        public void setStart​(int start)
        Specified by:
        setStart in interface Chunk
      • getEnd

        public int getEnd()
        Specified by:
        getEnd in interface Chunk
      • setEnd

        public void setEnd​(int end)
        Specified by:
        setEnd in interface Chunk
      • getLength

        public final int getLength()
        Specified by:
        getLength in interface Chunk
      • isNull

        public final boolean isNull()
      • allocate

        public void allocate​(int size)
      • delete

        public void delete​(int start,
                           int end)
        Specified by:
        delete in interface Chunk
      • indexOf

        public final int indexOf​(char c,
                                 int fromIndex)
        Specified by:
        indexOf in interface Chunk
      • indexOf

        public final int indexOf​(java.lang.String s,
                                 int fromIndex)
        Specified by:
        indexOf in interface Chunk
      • startsWithIgnoreCase

        public boolean startsWithIgnoreCase​(java.lang.String s,
                                            int pos)
      • findBytesAscii

        public int findBytesAscii​(byte[] b)
        Returns the starting index of the specified byte sequence within this Buffer.
        Parameters:
        b - byte sequence to search for.
        Returns:
        the starting index of the specified byte sequence within this Buffer
      • hashCode

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

        public int hash()
      • equals

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

        public boolean equals​(java.lang.CharSequence s)
      • equals

        public boolean equals​(byte[] b)
        Compares the message Buffer to the specified byte array.
        Parameters:
        b - the byte[] to compare
        Returns:
        true if the comparison succeeded, false otherwise
        Since:
        2.3
      • equals

        public boolean equals​(byte[] b,
                              int offset,
                              int len)
        Compares the message Buffer to the specified byte array.
        Parameters:
        b - the byte[] to compare
        offset - the offset in the array
        len - number of bytes to check
        Returns:
        true if the comparison succeeded, false otherwise
        Since:
        2.3
      • equals

        public static boolean equals​(byte[] c,
                                     int cOff,
                                     int cLen,
                                     Buffer t,
                                     int tOff,
                                     int tLen)
      • equals

        public boolean equals​(char[] b,
                              int offset,
                              int len)
        Compares the message Buffer to the specified char array.
        Parameters:
        b - the char[] to compare
        offset - the offset in the array
        len - number of chars to check
        Returns:
        true if the comparison succeeded, false otherwise
        Since:
        2.3
      • equalsIgnoreCase

        public boolean equalsIgnoreCase​(java.lang.Object o)
      • equalsIgnoreCase

        public boolean equalsIgnoreCase​(java.lang.CharSequence s)
      • equalsIgnoreCase

        public boolean equalsIgnoreCase​(byte[] b)
      • equalsIgnoreCase

        public boolean equalsIgnoreCase​(byte[] b,
                                        int offset,
                                        int len)
      • equalsIgnoreCase

        public boolean equalsIgnoreCase​(char[] b,
                                        int offset,
                                        int len)
        Compares the message Buffer to the specified char array ignoring case considerations.
        Parameters:
        b - the char[] to compare
        offset - the offset in the array
        len - number of chars to check
        Returns:
        true if the comparison succeeded, false otherwise
        Since:
        2.3
      • equalsIgnoreCaseLowerCase

        public boolean equalsIgnoreCaseLowerCase​(byte[] b)
        Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.
        Parameters:
        b - the byte[] to compare
        Returns:
        true if the comparison succeeded, false otherwise
        Since:
        2.1.2
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public java.lang.String toString​(java.nio.charset.Charset charset)
      • toString

        public java.lang.String toString​(int start,
                                         int end)
        Specified by:
        toString in interface Chunk
      • resetStringCache

        protected final void resetStringCache()
      • reset

        protected final void reset()
      • recycle

        public final void recycle()
      • notifyDirectUpdate

        protected void notifyDirectUpdate()
        Notify the Chunk that its content is going to be changed directly
      • indexOf

        public static int indexOf​(Buffer buffer,
                                  int off,
                                  int end,
                                  char qq)
      • indexOf

        public static int indexOf​(Buffer buffer,
                                  int off,
                                  int end,
                                  java.lang.CharSequence s)
      • compareIgnoreCase

        public int compareIgnoreCase​(int start,
                                     int end,
                                     java.lang.String compareTo)
        Returns:
        -1, 0 or +1 if inferior, equal, or superior to the String.
      • compare

        public int compare​(int start,
                           int end,
                           java.lang.String compareTo)
        Returns:
        -1, 0 or +1 if inferior, equal, or superior to the String.
      • equalsIgnoreCaseLowerCase

        public static boolean equalsIgnoreCaseLowerCase​(Buffer buffer,
                                                        int start,
                                                        int end,
                                                        byte[] cmpTo)
        Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.
        Parameters:
        buffer - the byte[] to compare
        start - buffer start
        end - buffer end
        cmpTo - byte[] to compare against
        Returns:
        true if the comparison succeeded, false otherwise
        Since:
        2.1.2
      • startsWith

        public static boolean startsWith​(Buffer buffer,
                                         int start,
                                         int end,
                                         byte[] cmpTo)
      • trimLeft

        public void trimLeft()