org.glassfish.grizzly.http.util
Class BufferChunk

java.lang.Object
  extended by org.glassfish.grizzly.http.util.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
BufferChunk()
           
 
Method Summary
 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(java.lang.CharSequence s)
           
 boolean equalsIgnoreCase(byte[] b)
           
 boolean equalsIgnoreCase(java.lang.CharSequence s)
           
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.
 boolean equalsIgnoreCaseLowerCase(byte[] b)
          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()
           
static int indexOf(Buffer buffer, int off, int end, char qq)
           
static int indexOf(Buffer buffer, int off, int end, java.lang.CharSequence s)
           
 int indexOf(char c, int fromIndex)
           
 int indexOf(java.lang.String s, int fromIndex)
           
 boolean isNull()
           
 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, boolean disposeOnRecycle)
           
 void setBufferChunk(Buffer buffer, int start, int end, int limit)
           
 void setBufferChunk(Buffer buffer, int start, int end, int limit, boolean disposeOnRecycle)
           
 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)
           
 CharChunk toChars(CharChunk cc, java.nio.charset.Charset encoding)
          Convert a BufferChunk using the specified encoding.
 java.lang.String toString()
           
 java.lang.String toString(java.nio.charset.Charset charset)
           
 java.lang.String toString(int start, int end)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferChunk

public BufferChunk()
Method Detail

setBufferChunk

public void setBufferChunk(Buffer buffer,
                           int start,
                           int end,
                           boolean disposeOnRecycle)

setBufferChunk

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

setBufferChunk

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

setBufferChunk

public void setBufferChunk(Buffer buffer,
                           int start,
                           int end,
                           int limit,
                           boolean disposeOnRecycle)

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

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(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

hash

public int hash()

equals

public boolean equals(java.lang.CharSequence s)

equalsIgnoreCase

public boolean equalsIgnoreCase(java.lang.CharSequence s)

equalsIgnoreCase

public boolean equalsIgnoreCase(byte[] b)

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

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

Specified by:
notifyDirectUpdate in interface Chunk

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.

toChars

public CharChunk toChars(CharChunk cc,
                         java.nio.charset.Charset encoding)
                  throws java.io.CharConversionException
Convert a BufferChunk using the specified encoding.

Parameters:
cc - char array to put result to.
encoding - the encoding value
Throws:
java.lang.Exception
java.io.CharConversionException

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)


Copyright © 2011 Oracle Corpration. All Rights Reserved.