Top Description Fields Constructors Methods
org.glassfish.grizzly.http.util

public Class BufferChunk

extends Object
implements Chunk
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http.util.Chunk
Imports
java.nio.charset.Charset, org.glassfish.grizzly.Buffer, org.glassfish.grizzly.memory.Buffers

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

Field Summary

Modifier and TypeField and Description
private Buffer
pack-priv String
pack-priv Charset
private static final Charset
DEFAULT_CHARSET

Default encoding used to convert to strings.

private int
private int
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
allocate(final int size)

public void
append(final BufferChunk bc)

public int
compare(int start, int end, String compareTo)

Returns: -1, 0 or +1 if inferior, equal, or superior to the String.

public int
compareIgnoreCase(int start, int end, String compareTo)

Returns: -1, 0 or +1 if inferior, equal, or superior to the String.

public void
delete(final int start, final int end)

Implements org.glassfish.grizzly.http.util.Chunk.delete.

public boolean
equals(final Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public boolean
public boolean

Returns:

true if the comparison succeeded, false otherwise
equals
(final byte[]
the byte[] to compare
b
)

Compares the message Buffer to the specified byte array.

public boolean

Returns:

true if the comparison succeeded, false otherwise
equals
(final byte[]
the byte[] to compare
b
,
int
the offset in the array
offset
,
final int
number of bytes to check
len
)

Compares the message Buffer to the specified byte array.

public static boolean
equals(final byte[] c, final int cOff, final int cLen, final Buffer t, final int tOff, final int tLen)

public boolean

Returns:

true if the comparison succeeded, false otherwise
equals
(final char[]
the char[] to compare
b
,
int
the offset in the array
offset
,
final int
number of chars to check
len
)

Compares the message Buffer to the specified char array.

public boolean
public boolean
public boolean
equalsIgnoreCase(final byte[] b)

public boolean
equalsIgnoreCase(final byte[] b, final int offset, final int len)

public boolean

Returns:

true if the comparison succeeded, false otherwise
equalsIgnoreCase
(final char[]
the char[] to compare
b
,
int
the offset in the array
offset
,
final int
number of chars to check
len
)

Compares the message Buffer to the specified char array ignoring case considerations.

public boolean

Returns:

true if the comparison succeeded, false otherwise
equalsIgnoreCaseLowerCase
(final byte[]
the byte[] to compare
b
)

Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.

public static boolean

Returns:

true if the comparison succeeded, false otherwise
equalsIgnoreCaseLowerCase
(final Buffer
the byte[] to compare
buffer
,
final int
buffer start
start
,
final int
buffer end
end
,
final byte[]
byte[] to compare against
cmpTo
)

Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.

public int

Returns:

the starting index of the specified byte sequence within this Buffer
findBytesAscii
(byte[]
byte sequence to search for.
b
)

Returns the starting index of the specified byte sequence within this Buffer.

public Buffer
public int
public final int
public int
public int
hash()

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final int
indexOf(final char c, final int fromIndex)

Implements org.glassfish.grizzly.http.util.Chunk.indexOf.

public final int
indexOf(final String s, final int fromIndex)

Implements org.glassfish.grizzly.http.util.Chunk.indexOf.

public static int
indexOf(final Buffer buffer, int off, final int end, final char qq)

public static int
indexOf(final Buffer buffer, int off, final int end, final CharSequence s)

public final boolean
protected void
notifyDirectUpdate()

Notify the Chunk that its content is going to be changed directly

public final void
protected final void
protected final void
public void
setBuffer(Buffer buffer)

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

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

public void
public void
pack-priv boolean
startsWith(String s, int pos)

public static boolean
startsWith(final Buffer buffer, final int start, final int end, final byte[] cmpTo)

public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
toString(Charset charset)

public String
toString(final int start, final int end)

Implements org.glassfish.grizzly.http.util.Chunk.toString.

public void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

bufferback to summary
private Buffer buffer
cachedStringback to summary
pack-priv String cachedString
cachedStringCharsetback to summary
pack-priv Charset cachedStringCharset
DEFAULT_CHARSETback to summary
private static final Charset DEFAULT_CHARSET

Default encoding used to convert to strings. It should be UTF8, as most standards seem to converge, but the servlet API requires 8859_1, and this object is used mostly for servlets.

endback to summary
private int end
limitback to summary
private int limit
startback to summary
private int start

Constructor Detail

BufferChunkback to summary
public BufferChunk()

Method Detail

allocateback to summary
public void allocate(final int size)
appendback to summary
public void append(final BufferChunk bc)
compareback to summary
public int compare(int start, int end, String compareTo)
Returns:int

-1, 0 or +1 if inferior, equal, or superior to the String.

compareIgnoreCaseback to summary
public int compareIgnoreCase(int start, int end, String compareTo)
Returns:int

-1, 0 or +1 if inferior, equal, or superior to the String.

deleteback to summary
public void delete(final int start, final int end)

Implements org.glassfish.grizzly.http.util.Chunk.delete.

Annotations
@Override
equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
equalsback to summary
public boolean equals(CharSequence s)
equalsback to summary
public boolean equals(final byte[] b)

Compares the message Buffer to the specified byte array.

Parameters
b:byte[]

the byte[] to compare

Returns:boolean

true if the comparison succeeded, false otherwise

Since
2.3
equalsback to summary
public boolean equals(final byte[] b, int offset, final int len)

Compares the message Buffer to the specified byte array.

Parameters
b:byte[]

the byte[] to compare

offset:int

the offset in the array

len:int

number of bytes to check

Returns:boolean

true if the comparison succeeded, false otherwise

Since
2.3
equalsback to summary
public static boolean equals(final byte[] c, final int cOff, final int cLen, final Buffer t, final int tOff, final int tLen)
equalsback to summary
public boolean equals(final char[] b, int offset, final int len)

Compares the message Buffer to the specified char array.

Parameters
b:char[]

the char[] to compare

offset:int

the offset in the array

len:int

number of chars to check

Returns:boolean

true if the comparison succeeded, false otherwise

Since
2.3
equalsIgnoreCaseback to summary
public boolean equalsIgnoreCase(final Object o)
equalsIgnoreCaseback to summary
public boolean equalsIgnoreCase(CharSequence s)
equalsIgnoreCaseback to summary
public boolean equalsIgnoreCase(final byte[] b)
equalsIgnoreCaseback to summary
public boolean equalsIgnoreCase(final byte[] b, final int offset, final int len)
equalsIgnoreCaseback to summary
public boolean equalsIgnoreCase(final char[] b, int offset, final int len)

Compares the message Buffer to the specified char array ignoring case considerations.

Parameters
b:char[]

the char[] to compare

offset:int

the offset in the array

len:int

number of chars to check

Returns:boolean

true if the comparison succeeded, false otherwise

Since
2.3
equalsIgnoreCaseLowerCaseback to summary
public boolean equalsIgnoreCaseLowerCase(final byte[] b)

Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.

Parameters
b:byte[]

the byte[] to compare

Returns:boolean

true if the comparison succeeded, false otherwise

Since
2.1.2
equalsIgnoreCaseLowerCaseback to summary
public static boolean equalsIgnoreCaseLowerCase(final Buffer buffer, final int start, final int end, final byte[] cmpTo)

Compares the buffer chunk to the specified byte array representing lower-case ASCII characters.

Parameters
buffer:Buffer

the byte[] to compare

start:int

buffer start

end:int

buffer end

cmpTo:byte[]

byte[] to compare against

Returns:boolean

true if the comparison succeeded, false otherwise

Since
2.1.2
findBytesAsciiback to summary
public int findBytesAscii(byte[] b)

Returns the starting index of the specified byte sequence within this Buffer.

Parameters
b:byte[]

byte sequence to search for.

Returns:int

the starting index of the specified byte sequence within this Buffer

getBufferback to summary
public Buffer getBuffer()
getEndback to summary
public int getEnd()

Implements org.glassfish.grizzly.http.util.Chunk.getEnd.

Annotations
@Override
getLengthback to summary
public final int getLength()

Implements org.glassfish.grizzly.http.util.Chunk.getLength.

Annotations
@Override
getStartback to summary
public int getStart()

Implements org.glassfish.grizzly.http.util.Chunk.getStart.

Annotations
@Override
hashback to summary
public int hash()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
indexOfback to summary
public final int indexOf(final char c, final int fromIndex)

Implements org.glassfish.grizzly.http.util.Chunk.indexOf.

Annotations
@Override
indexOfback to summary
public final int indexOf(final String s, final int fromIndex)

Implements org.glassfish.grizzly.http.util.Chunk.indexOf.

Annotations
@Override
indexOfback to summary
public static int indexOf(final Buffer buffer, int off, final int end, final char qq)
indexOfback to summary
public static int indexOf(final Buffer buffer, int off, final int end, final CharSequence s)
isNullback to summary
public final boolean isNull()
notifyDirectUpdateback to summary
protected void notifyDirectUpdate()

Notify the Chunk that its content is going to be changed directly

recycleback to summary
public final void recycle()
resetback to summary
protected final void reset()
resetStringCacheback to summary
protected final void resetStringCache()
setBufferback to summary
public void setBuffer(Buffer buffer)
setBufferChunkback to summary
public void setBufferChunk(final Buffer buffer, final int start, final int end)
setBufferChunkback to summary
public void setBufferChunk(final Buffer buffer, final int start, final int end, final int limit)
setEndback to summary
public void setEnd(int end)

Implements org.glassfish.grizzly.http.util.Chunk.setEnd.

Annotations
@Override
setStartback to summary
public void setStart(int start)

Implements org.glassfish.grizzly.http.util.Chunk.setStart.

Annotations
@Override
startsWithback to summary
pack-priv boolean startsWith(String s, int pos)
startsWithback to summary
public static boolean startsWith(final Buffer buffer, final int start, final int end, final byte[] cmpTo)
startsWithIgnoreCaseback to summary
public boolean startsWithIgnoreCase(String s, int pos)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
toStringback to summary
public String toString(Charset charset)
toStringback to summary
public String toString(final int start, final int end)

Implements org.glassfish.grizzly.http.util.Chunk.toString.

Annotations
@Override
trimLeftback to summary
public void trimLeft()