| java.lang.Object org.apache.tomcat.util.buf.MessageBytes
MessageBytes | final public class MessageBytes implements Cloneable,Serializable(Code) | | 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.
author: dac@eng.sun.com author: James Todd [gonzo@eng.sun.com] author: Costin Manolache |
Inner Class :public static class MessageBytesFactory | |
Field Summary | |
final public static int | T_BYTES | final public static int | T_CHARS | final public static int | T_NULL | final public static int | T_STR |
Constructor Summary | |
public | MessageBytes() Creates a new, uninitialized MessageBytes object. |
Method Summary | |
public void | duplicate(MessageBytes src) | public boolean | equals(String s) Compares the message bytes to the specified String object. | public boolean | equals(MessageBytes mb) | public boolean | equalsIgnoreCase(String s) Compares the message bytes to the specified String object. | public ByteChunk | getByteChunk() Returns the byte chunk, representing the byte[] and offset/length. | public CharChunk | getCharChunk() Returns the char chunk, representing the char[] and offset/length. | public MessageBytes | getClone() | public int | getInt() | public int | getLength() Returns the length of the original buffer. | public long | getLong() | public String | getString() Returns the string value. | public long | getTime() | public int | getType() Return the type of the original content. | public int | hashCode() | public int | indexOf(char c) | public int | indexOf(String s, int starting) | public int | indexOf(String s) | public int | indexOf(char c, int starting) Returns true if the message bytes starts with the specified string. | public int | indexOfIgnoreCase(String s, int starting) | public boolean | isNull() | public static MessageBytes | newInstance() | public void | recycle() Resets the message bytes to an uninitialized (NULL) state. | public void | resetStringValue() Remove the cached string value. | public void | setBytes(byte[] b, int off, int len) Sets the content to the specified subarray of bytes. | public void | setCaseSenitive(boolean b) | public void | setChars(char[] c, int off, int len) | public void | setEncoding(String enc) Set the encoding. | public static void | setFactory(MessageBytesFactory mbf) | public void | setInt(int i) | public void | setLong(long l) | public void | setString(String s) | public void | setTime(long t, DateFormat df) | public void | setTime(long t) | public boolean | startsWith(String s) Returns true if the message bytes starts with the specified string. | public boolean | startsWithIgnoreCase(String s, int pos) Returns true if the message bytes starts with the specified string. | public void | toBytes() Unimplemented yet. | public void | toChars() Convert to char[] and fill the CharChunk. | public String | toString() |
T_BYTES | final public static int T_BYTES(Code) | | getType() is T_STR if the the object used to create the MessageBytes
was a byte[]
|
T_CHARS | final public static int T_CHARS(Code) | | getType() is T_STR if the the object used to create the MessageBytes
was a char[]
|
T_NULL | final public static int T_NULL(Code) | | |
T_STR | final public static int T_STR(Code) | | getType() is T_STR if the the object used to create the MessageBytes
was a String
|
MessageBytes | public MessageBytes()(Code) | | Creates a new, uninitialized MessageBytes object.
|
equals | public boolean equals(String s)(Code) | | Compares the message bytes to the specified String object.
Parameters: s - the String to compare true if the comparison succeeded, false otherwise |
equalsIgnoreCase | public boolean equalsIgnoreCase(String s)(Code) | | Compares the message bytes to the specified String object.
Parameters: s - the String to compare true if the comparison succeeded, false otherwise |
getByteChunk | public ByteChunk getByteChunk()(Code) | | Returns the byte chunk, representing the byte[] and offset/length.
Valid only if T_BYTES or after a conversion was made.
|
getCharChunk | public CharChunk getCharChunk()(Code) | | Returns the char chunk, representing the char[] and offset/length.
Valid only if T_CHARS or after a conversion was made.
|
getInt | public int getInt()(Code) | | Convert the buffer to an int, cache the value
|
getLength | public int getLength()(Code) | | Returns the length of the original buffer.
Note that the length in bytes may be different from the length
in chars.
|
getLong | public long getLong()(Code) | | Convert the buffer to an long, cache the value
|
getString | public String getString()(Code) | | Returns the string value.
Valid only if T_STR or after a conversion was made.
|
getTime | public long getTime()(Code) | | |
getType | public int getType()(Code) | | Return the type of the original content. Can be
T_STR, T_BYTES, T_CHARS or T_NULL
|
hashCode | public int hashCode()(Code) | | |
indexOf | public int indexOf(char c)(Code) | | |
indexOf | public int indexOf(char c, int starting)(Code) | | Returns true if the message bytes starts with the specified string.
Parameters: c - the character Parameters: starting - The start position |
indexOfIgnoreCase | public int indexOfIgnoreCase(String s, int starting)(Code) | | |
isNull | public boolean isNull()(Code) | | |
newInstance | public static MessageBytes newInstance()(Code) | | Construct a new MessageBytes instance
|
recycle | public void recycle()(Code) | | Resets the message bytes to an uninitialized (NULL) state.
|
resetStringValue | public void resetStringValue()(Code) | | Remove the cached string value. Use it after a conversion on the
byte[] or after the encoding is changed
XXX Is this needed ?
|
setBytes | public void setBytes(byte[] b, int off, int len)(Code) | | Sets the content to the specified subarray of bytes.
Parameters: b - the bytes Parameters: off - the start offset of the bytes Parameters: len - the length of the bytes |
setCaseSenitive | public void setCaseSenitive(boolean b)(Code) | | Configure the case sensitivity
|
setChars | public void setChars(char[] c, int off, int len)(Code) | | Sets the content to be a char[]
Parameters: c - the bytes Parameters: off - the start offset of the bytes Parameters: len - the length of the bytes |
setEncoding | public void setEncoding(String enc)(Code) | | Set the encoding. If the object was constructed from bytes[]. any
previous conversion is reset.
If no encoding is set, we'll use 8859-1.
|
setFactory | public static void setFactory(MessageBytesFactory mbf)(Code) | | |
setInt | public void setInt(int i)(Code) | | Set the buffer to the representation of an int
|
setLong | public void setLong(long l)(Code) | | Set the buffer to the representation of an long
|
setString | public void setString(String s)(Code) | | Set the content to be a string
|
setTime | public void setTime(long t)(Code) | | |
startsWith | public boolean startsWith(String s)(Code) | | Returns true if the message bytes starts with the specified string.
Parameters: s - the string |
startsWithIgnoreCase | public boolean startsWithIgnoreCase(String s, int pos)(Code) | | Returns true if the message bytes starts with the specified string.
Parameters: s - the string Parameters: pos - The start position |
toBytes | public void toBytes()(Code) | | Unimplemented yet. Do a char->byte conversion.
|
toChars | public void toChars()(Code) | | Convert to char[] and fill the CharChunk.
XXX Not optimized - it converts to String first.
|
toString | public String toString()(Code) | | Compute the string value
|
|
|