Class BufferChunk

  • All Implemented Interfaces:
    Chunk

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

      • BufferChunk

        public BufferChunk()
    • Method Detail

      • setBufferChunk

        public void setBufferChunk​(org.glassfish.grizzly.Buffer buffer,
                                   int start,
                                   int end)
      • setBufferChunk

        public void setBufferChunk​(org.glassfish.grizzly.Buffer buffer,
                                   int start,
                                   int end,
                                   int limit)
      • getBuffer

        public org.glassfish.grizzly.Buffer getBuffer()
      • setBuffer

        public void setBuffer​(org.glassfish.grizzly.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​(String s,
                                 int fromIndex)
        Specified by:
        indexOf in interface Chunk
      • startsWithIgnoreCase

        public boolean startsWithIgnoreCase​(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 Object
      • hash

        public int hash()
      • 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,
                                     org.glassfish.grizzly.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​(Object o)
      • equalsIgnoreCase

        public boolean equalsIgnoreCase​(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 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​(org.glassfish.grizzly.Buffer buffer,
                                  int off,
                                  int end,
                                  char qq)
      • indexOf

        public static int indexOf​(org.glassfish.grizzly.Buffer buffer,
                                  int off,
                                  int end,
                                  CharSequence s)
      • compareIgnoreCase

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

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

        public static boolean equalsIgnoreCaseLowerCase​(org.glassfish.grizzly.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​(org.glassfish.grizzly.Buffer buffer,
                                         int start,
                                         int end,
                                         byte[] cmpTo)
      • trimLeft

        public void trimLeft()