org.glassfish.grizzly.http.util
Class BufferChunk

java.lang.Object
  extended by org.glassfish.grizzly.http.util.BufferChunk
Direct Known Subclasses:
CacheableBufferChunk

public class BufferChunk
extends Object

Buffer chunk representation. Helps HTTP module to avoid redundant String creation.

Author:
Alexey Stashok

Constructor Summary
protected BufferChunk()
           
 
Method Summary
 int compare(int start, int end, String compareTo)
           
 int compareIgnoreCase(int start, int end, String compareTo)
           
 boolean equals(String s)
          Compares the message bytes to the specified String object.
 boolean equalsIgnoreCase(String s)
          Compares the message bytes to the specified String object.
 int findBytesAscii(byte[] b)
          Returns the starting index of the specified byte sequence within this Buffer.
 Buffer getBuffer()
           
 int getEnd()
           
 int getStart()
           
 boolean hasBuffer()
           
 boolean hasString()
           
 int indexOf(char c, int fromIndex)
          Returns true if the message bytes starts with the specified string.
 int indexOf(String s, int fromIndex)
          Returns true if the message bytes starts with the specified string.
 boolean isNull()
           
protected  void lock()
           
static BufferChunk newInstance()
           
protected  void onContentChanged()
           
 void recycle()
           
protected  void reset()
           
protected  void resetBuffer()
           
protected  void resetString()
           
protected  void resetStringCache()
           
 void set(BufferChunk value)
           
 void setBuffer(Buffer buffer)
           
 void setBuffer(Buffer buffer, int start, int end)
           
 void setEnd(int end)
           
 void setStart(int start)
           
 void setString(String string)
           
 int size()
          Returns the BufferChunk length.
 boolean startsWith(String s, int pos)
          Returns true if the BufferChunk starts with the specified string.
 boolean startsWithIgnoreCase(String s, int pos)
          Returns true if the BufferChunk starts with the specified string.
 String toString()
           
 String toString(Charset charset)
           
protected  void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferChunk

protected BufferChunk()
Method Detail

newInstance

public static BufferChunk newInstance()

set

public void set(BufferChunk value)

getBuffer

public Buffer getBuffer()

setBuffer

public void setBuffer(Buffer buffer)

setBuffer

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

getStart

public int getStart()

setStart

public void setStart(int start)

getEnd

public int getEnd()

setEnd

public void setEnd(int end)

setString

public void setString(String string)

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(Charset charset)

onContentChanged

protected void onContentChanged()

size

public int size()
Returns the BufferChunk length.

Returns:
the BufferChunk length.

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

indexOf

public int indexOf(char c,
                   int fromIndex)
Returns true if the message bytes starts with the specified string.

Parameters:
c - the character
fromIndex - The start position

indexOf

public int indexOf(String s,
                   int fromIndex)
Returns true if the message bytes starts with the specified string.

Parameters:
s - the string
fromIndex - The start position

equals

public boolean equals(String s)
Compares the message bytes to the specified String object.

Parameters:
s - the String to compare
Returns:
true if the comparison succeeded, false otherwise

equalsIgnoreCase

public boolean equalsIgnoreCase(String s)
Compares the message bytes to the specified String object.

Parameters:
s - the String to compare
Returns:
true if the comparison succeeded, false otherwise

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.

startsWithIgnoreCase

public boolean startsWithIgnoreCase(String s,
                                    int pos)
Returns true if the BufferChunk starts with the specified string.

Parameters:
s - the string
pos - The start position
Returns:
true if the BufferChunk starts with the specified string.

startsWith

public boolean startsWith(String s,
                          int pos)
Returns true if the BufferChunk starts with the specified string.

Parameters:
s - the string
pos - The start position
Returns:
true if the BufferChunk starts with the specified string.

hasBuffer

public final boolean hasBuffer()

hasString

public final boolean hasString()

isNull

public final boolean isNull()

resetBuffer

protected final void resetBuffer()

resetString

protected final void resetString()

resetStringCache

protected final void resetStringCache()

reset

protected void reset()

lock

protected void lock()

unlock

protected void unlock()

recycle

public void recycle()


Copyright © 2010 Oracle Corpration. All Rights Reserved.