|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tomcat.util.buf.MessageBytes
public final class MessageBytes
This class is used to represent a subarray of bytes in an HTTP message. It represents all request/response elements. The byte/char conversions are delayed and cached. Everything is recyclable. The object can represent a byte[], a char[], or a (sub) String. All operations can be made in case sensitive mode or not.
Nested Class Summary | |
---|---|
static class |
MessageBytes.MessageBytesFactory
|
Field Summary | |
---|---|
static int |
T_BYTES
getType() is T_BYTES if the the object used to create the MessageBytes was a byte[] |
static int |
T_CHARS
getType() is T_CHARS if the the object used to create the MessageBytes was a char[] |
static int |
T_NULL
|
static int |
T_STR
getType() is T_STR if the the object used to create the MessageBytes was a String |
Constructor Summary | |
---|---|
MessageBytes()
Deprecated. Use static newInstance() in order to allow future hooks. |
Method Summary | |
---|---|
void |
duplicate(MessageBytes src)
Copy the src into this MessageBytes, allocating more space if needed |
boolean |
equals(MessageBytes mb)
|
boolean |
equals(java.lang.String s)
Compares the message bytes to the specified String object. |
boolean |
equalsIgnoreCase(java.lang.String s)
Compares the message bytes to the specified String object. |
ByteChunk |
getByteChunk()
Returns the byte chunk, representing the byte[] and offset/length. |
CharChunk |
getCharChunk()
Returns the char chunk, representing the char[] and offset/length. |
java.nio.charset.Charset |
getCharset()
Get the Charset used for string<->byte conversions. |
MessageBytes |
getClone()
|
int |
getInt()
Convert the buffer to an int, cache the value |
int |
getLength()
Returns the length of the original buffer. |
long |
getLong()
Convert the buffer to an long, cache the value |
java.lang.String |
getString()
Returns the string value. |
long |
getTime()
Deprecated. The buffer are general purpose, caching for headers should be done in headers |
int |
getType()
Return the type of the original content. |
int |
hashCode()
|
int |
indexOf(char c)
|
int |
indexOf(char c,
int starting)
Returns true if the message bytes starts with the specified string. |
int |
indexOf(java.lang.String s)
|
int |
indexOf(java.lang.String s,
int starting)
|
int |
indexOfIgnoreCase(java.lang.String s,
int starting)
|
boolean |
isNull()
|
static MessageBytes |
newInstance()
Construct a new MessageBytes instance |
void |
recycle()
Resets the message bytes to an uninitialized (NULL) state. |
void |
resetStringValue()
Remove the cached string value. |
void |
setBytes(byte[] b,
int off,
int len)
Sets the content to the specified subarray of bytes. |
void |
setCaseSenitive(boolean b)
Configure the case sensitivity |
void |
setChars(char[] c,
int off,
int len)
Sets the content to be a char[] |
void |
setCharset(java.nio.charset.Charset charset)
Set the Charset used for string<->byte conversions. |
static void |
setFactory(MessageBytes.MessageBytesFactory mbf)
|
void |
setInt(int i)
Set the buffer to the representation of an int |
void |
setLong(long l)
Set the buffer to the representation of an long |
void |
setString(java.lang.String s)
Set the content to be a string |
void |
setTime(long t)
Deprecated. |
void |
setTime(long t,
java.text.DateFormat df)
Deprecated. The buffer are general purpose, caching for headers should be done in headers. The second parameter allows us to pass a date format instance to avoid synchronization problems. |
boolean |
startsWith(java.lang.String s)
Returns true if the message bytes starts with the specified string. |
boolean |
startsWithIgnoreCase(java.lang.String s,
int pos)
Returns true if the message bytes starts with the specified string. |
void |
toBytes()
Do a char->byte conversion. |
void |
toChars()
Convert to char[] and fill the CharChunk. |
java.lang.String |
toString()
Compute the string value |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int T_NULL
public static final int T_STR
public static final int T_BYTES
public static final int T_CHARS
Constructor Detail |
---|
public MessageBytes()
Method Detail |
---|
public static MessageBytes newInstance()
public void setCaseSenitive(boolean b)
public MessageBytes getClone()
public boolean isNull()
public void recycle()
public void setBytes(byte[] b, int off, int len)
b
- the bytesoff
- the start offset of the byteslen
- the length of the bytespublic void setChars(char[] c, int off, int len)
c
- the bytesoff
- the start offset of the byteslen
- the length of the bytespublic void resetStringValue()
public void setString(java.lang.String s)
public java.lang.String toString()
toString
in class java.lang.Object
public int getType()
public ByteChunk getByteChunk()
public CharChunk getCharChunk()
public java.lang.String getString()
public java.nio.charset.Charset getCharset()
public void setCharset(java.nio.charset.Charset charset)
public void toBytes()
public void toChars()
public int getLength()
public boolean equals(java.lang.String s)
s
- the String to compare
public boolean equalsIgnoreCase(java.lang.String s)
s
- the String to compare
public boolean equals(MessageBytes mb)
public boolean startsWith(java.lang.String s)
s
- the stringpublic boolean startsWithIgnoreCase(java.lang.String s, int pos)
s
- the stringpos
- The start positionpublic int hashCode()
hashCode
in class java.lang.Object
public int indexOf(char c)
public int indexOf(java.lang.String s, int starting)
public int indexOf(java.lang.String s)
public int indexOfIgnoreCase(java.lang.String s, int starting)
public int indexOf(char c, int starting)
c
- the characterstarting
- The start positionpublic void duplicate(MessageBytes src) throws java.io.IOException
java.io.IOException
public void setTime(long t, java.text.DateFormat df)
public void setTime(long t)
public void setInt(int i)
public void setLong(long l)
public long getTime()
public int getInt()
public long getLong()
public static void setFactory(MessageBytes.MessageBytesFactory mbf)
|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |