org.glassfish.grizzly.http.util
Class DataChunk

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

public class DataChunk
extends Object
implements Chunk

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(ByteChunk byteChunk, BufferChunk bufferChunk, CharChunk charChunk, 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(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(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()
           
 ByteChunk getByteChunk()
           
 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(String s, int fromIndex)
          Returns true if the message bytes starts with the specified string.
 boolean isNull()
           
static DataChunk newInstance()
           
static DataChunk newInstance(ByteChunk byteChunk, BufferChunk bufferChunk, CharChunk charChunk, String stringValue)
           
 void notifyDirectUpdate()
          Notify the Chunk that its content is going to be changed directly
protected  void onContentChanged()
           
 void recycle()
           
protected  void reset()
           
protected  void resetBuffer()
           
protected  void resetByteChunk()
           
protected  void resetCharChunk()
           
protected  void resetString()
           
 void set(DataChunk value)
           
 void set(DataChunk value, int start, int end)
           
 void setBuffer(Buffer buffer)
           
 void setBuffer(Buffer buffer, int position, int limit)
           
 void setBytes(byte[] bytes)
           
 void setBytes(byte[] bytes, int position, int limit)
           
 void setChars(char[] chars, int position, int limit)
           
 void setEnd(int end)
          Sets the DataChunk end position.
 void setStart(int start)
          Sets the DataChunk start position.
 void setString(String string)
           
 boolean startsWith(String s, int pos)
          Returns true if the DataChunk starts with the specified string.
 boolean startsWithIgnoreCase(String s, int pos)
          Returns true if the DataChunk starts with the specified string.
 void toChars(Charset charset)
           
 DataChunk toImmutable()
           
 String toString()
           
 String toString(Charset charset)
           
 String toString(int start, int end)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataChunk

protected DataChunk()

DataChunk

protected DataChunk(ByteChunk byteChunk,
                    BufferChunk bufferChunk,
                    CharChunk charChunk,
                    String stringValue)
Method Detail

newInstance

public static DataChunk newInstance()

newInstance

public static DataChunk newInstance(ByteChunk byteChunk,
                                    BufferChunk bufferChunk,
                                    CharChunk charChunk,
                                    String stringValue)

toImmutable

public DataChunk toImmutable()

getType

public DataChunk.Type getType()

set

public void set(DataChunk value)

set

public void set(DataChunk value,
                int start,
                int end)

notifyDirectUpdate

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


getBufferChunk

public BufferChunk getBufferChunk()

setBuffer

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

setBuffer

public void setBuffer(Buffer buffer)

getCharChunk

public CharChunk getCharChunk()

setChars

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

getByteChunk

public ByteChunk getByteChunk()

setBytes

public void setBytes(byte[] bytes)

setBytes

public void setBytes(byte[] bytes,
                     int position,
                     int limit)

setString

public void setString(String string)

duplicate

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


toChars

public void toChars(Charset charset)
             throws CharConversionException
Throws:
CharConversionException

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(Charset charset)

onContentChanged

protected void onContentChanged()

getLength

public int getLength()
Returns the DataChunk length.

Specified by:
getLength in interface Chunk
Returns:
the DataChunk length.

getStart

public int getStart()
Returns the DataChunk start position.

Specified by:
getStart in interface Chunk
Returns:
the DataChunk start position.

setStart

public void setStart(int start)
Sets the DataChunk start position.

Specified by:
setStart in interface Chunk
Parameters:
start - the DataChunk start position.

getEnd

public int getEnd()
Returns the DataChunk end position.

Specified by:
getEnd in interface Chunk
Returns:
the DataChunk end position.

setEnd

public void setEnd(int end)
Sets the DataChunk end position.

Specified by:
setEnd in interface Chunk
Parameters:
end - the DataChunk end position.

indexOf

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

Specified by:
indexOf in interface Chunk
Parameters:
c - the character
fromIndex - The start position

indexOf

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

Specified by:
indexOf in interface Chunk
Parameters:
s - the string
fromIndex - The start position

delete

public final void delete(int from,
                         int to)
Specified by:
delete in interface Chunk

toString

public String toString(int start,
                       int end)

Specified by:
toString in interface Chunk

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

hashCode

public int hashCode()
Returns DataChunk hash code.

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

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

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

resetByteChunk

protected void resetByteChunk()

resetString

protected void resetString()

reset

protected void reset()

recycle

public void recycle()


Copyright © 2013 Oracle Corporation. All Rights Reserved.