Class BufferChunk

java.lang.Object
org.glassfish.grizzly.http.util.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 Details

    • BufferChunk

      public BufferChunk()
  • Method Details

    • 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
    • append

      public void append(BufferChunk bc)
    • 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(Object o)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(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, 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()
      Overrides:
      toString in class Object
    • toString

      public String toString(Charset charset)
    • 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)
    • endsWithValidDelimitedTokenIgnoreCaseLowerCase

      public static boolean endsWithValidDelimitedTokenIgnoreCaseLowerCase(org.glassfish.grizzly.Buffer buffer, int start, int end, byte[] cmpTo, byte delimiter)
      Checks whether the specified byte range ends with the expected token and contains only non-empty delimiter-separated tokens, ignoring ASCII case.

      Optional whitespace (SP or HTAB) before the final token and around preceding tokens are ignored when validating tokens. The expected token must either be the entire range or be preceded by the specified delimiter, optionally followed by SP or HTAB.

      Each token in the range must contain at least one non-whitespace byte.

      The cmpTo must contain only lowercase ASCII characters.

      Parameters:
      buffer - the byte array containing the value to inspect
      start - the inclusive start index of the range to inspect
      end - the exclusive end index of the range to inspect
      cmpTo - the lowercase ASCII token expected at the end of the range
      delimiter - the byte that separates tokens
      Returns:
      true if the range contains only non-empty delimited tokens and ends with cmpTo; otherwise false
    • trimLeft

      public void trimLeft()