org.glassfish.grizzly.http.util
Class DataChunk

java.lang.Object
  extended by org.glassfish.grizzly.http.util.DataChunk
Direct Known Subclasses:
CacheableDataChunk

public class DataChunk
extends java.lang.Object

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

Author:
Alexey Stashok

Nested Class Summary
static class DataChunk.Type
           
 
Constructor Summary
protected DataChunk()
           
protected DataChunk(BufferChunk bufferChunk, CharChunk charChunk, java.lang.String stringValue)
           
 
Method Summary
 void delete(int from, int to)
           
 void duplicate(DataChunk src)
          Copy the src into this DataChunk, allocating more space if needed
 boolean equals(java.lang.String s)
          Compares the message bytes to the specified String object.
 boolean equalsIgnoreCase(byte[] b)
          Compares the message bytes to the specified String object.
 boolean equalsIgnoreCase(java.lang.String s)
          Compares the message bytes to the specified String object.
 boolean equalsIgnoreCaseLowerCase(byte[] b)
          Compares the data chunk to the specified byte array representing lower-case ASCII characters.
 BufferChunk getBufferChunk()
           
 CharChunk getCharChunk()
           
 int getEnd()
          Returns the DataChunk end position.
 int getLength()
          Returns the DataChunk length.
 int getStart()
          Returns the DataChunk start position.
 DataChunk.Type getType()
           
 int hashCode()
          Returns DataChunk hash code.
 int indexOf(char c, int fromIndex)
          Returns true if the message bytes starts with the specified string.
 int indexOf(java.lang.String s, int fromIndex)
          Returns true if the message bytes starts with the specified string.
 boolean isNull()
           
static DataChunk newInstance()
           
static DataChunk newInstance(BufferChunk bufferChunk, CharChunk charChunk, java.lang.String stringValue)
           
 void notifyDirectUpdate()
           
protected  void onContentChanged()
           
 void recycle()
           
protected  void reset()
           
protected  void resetBuffer()
           
protected  void resetCharChunk()
           
protected  void resetString()
           
 void set(DataChunk value)
           
 void setBuffer(Buffer buffer)
           
 void setBuffer(Buffer buffer, boolean disposeOnRecycle)
           
 void setBuffer(Buffer buffer, int position, int limit)
           
 void setChars(char[] chars, int position, int limit)
           
 void setString(java.lang.String string)
           
 boolean startsWith(java.lang.String s, int pos)
          Returns true if the DataChunk starts with the specified string.
 boolean startsWithIgnoreCase(java.lang.String s, int pos)
          Returns true if the DataChunk starts with the specified string.
 void toChars(java.nio.charset.Charset charset)
           
 DataChunk toImmutable()
           
 java.lang.String toString()
           
 java.lang.String toString(java.nio.charset.Charset charset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataChunk

protected DataChunk()

DataChunk

protected DataChunk(BufferChunk bufferChunk,
                    CharChunk charChunk,
                    java.lang.String stringValue)
Method Detail

newInstance

public static DataChunk newInstance()

newInstance

public static DataChunk newInstance(BufferChunk bufferChunk,
                                    CharChunk charChunk,
                                    java.lang.String stringValue)

toImmutable

public DataChunk toImmutable()

getType

public DataChunk.Type getType()

set

public void set(DataChunk value)

notifyDirectUpdate

public void notifyDirectUpdate()

getBufferChunk

public BufferChunk getBufferChunk()

setBuffer

public void setBuffer(Buffer buffer,
                      int position,
                      int limit)

setBuffer

public void setBuffer(Buffer buffer)

setBuffer

public void setBuffer(Buffer buffer,
                      boolean disposeOnRecycle)

getCharChunk

public CharChunk getCharChunk()

setChars

public void setChars(char[] chars,
                     int position,
                     int limit)

setString

public void setString(java.lang.String string)

duplicate

public void duplicate(DataChunk src)
Copy the src into this DataChunk, allocating more space if needed


toChars

public void toChars(java.nio.charset.Charset charset)
             throws java.io.CharConversionException
Throws:
java.io.CharConversionException

toString

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

toString

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

onContentChanged

protected void onContentChanged()

getLength

public int getLength()
Returns the DataChunk length.

Returns:
the DataChunk length.

getStart

public int getStart()
Returns the DataChunk start position.

Returns:
the DataChunk start position.

getEnd

public int getEnd()
Returns the DataChunk end position.

Returns:
the DataChunk end position.

indexOf

public final 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 final int indexOf(java.lang.String s,
                         int fromIndex)
Returns true if the message bytes starts with the specified string.

Parameters:
s - the string
fromIndex - The start position

delete

public final void delete(int from,
                         int to)

equals

public boolean equals(java.lang.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

hashCode

public int hashCode()
Returns DataChunk hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
DataChunk hash code.

equalsIgnoreCase

public boolean equalsIgnoreCase(java.lang.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 final boolean equalsIgnoreCase(byte[] b)
Compares the message bytes to the specified String object.

Parameters:
b - the byte[] to compare
Returns:
true if the comparison succeeded, false otherwise
Since:
2.1.2

equalsIgnoreCaseLowerCase

public final boolean equalsIgnoreCaseLowerCase(byte[] b)
Compares the data 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

startsWith

public final boolean startsWith(java.lang.String s,
                                int pos)
Returns true if the DataChunk starts with the specified string.

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

startsWithIgnoreCase

public final boolean startsWithIgnoreCase(java.lang.String s,
                                          int pos)
Returns true if the DataChunk starts with the specified string.

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

isNull

public final boolean isNull()

resetBuffer

protected void resetBuffer()

resetCharChunk

protected void resetCharChunk()

resetString

protected void resetString()

reset

protected void reset()

recycle

public void recycle()


Copyright © 2011 Oracle Corpration. All Rights Reserved.