org.apache.tomcat.util.buf
Class MessageBytes

java.lang.Object
  |
  +--org.apache.tomcat.util.buf.MessageBytes
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public final class MessageBytes
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class is used to represent a subarray of bytes in an HTTP message.

Author:
dac@eng.sun.com, James Todd [gonzo@eng.sun.com], Costin Manolache
See Also:
Serialized Form

Inner Class Summary
static class MessageBytes.MessageBytesFactory
           
 
Field Summary
static int T_BYTES
           
static int T_CHARS
           
static int T_NULL
           
static int T_STR
           
 
Constructor Summary
MessageBytes()
          Creates a new, uninitialized MessageBytes object.
 
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 message bytes.
 CharChunk getCharChunk()
           
 MessageBytes getClone()
           
 int getInt()
          Deprecated. The buffer are general purpose, caching for headers should be done in headers
 int getLength()
          Returns the length of the buffer.
 java.lang.String getString()
           
 long getTime()
          Deprecated. The buffer are general purpose, caching for headers should be done in headers
 int getType()
           
 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()
           
 void recycle()
          Resets the message bytes to an uninitialized state.
 void resetStringValue()
          Remove the cached string value.
 void setBytes(byte[] b, int off, int len)
          Sets the message bytes to the specified subarray of bytes.
 void setCaseSenitive(boolean b)
           
 void setChars(char[] c, int off, int len)
           
 void setEncoding(java.lang.String enc)
           
static void setFactory(MessageBytes.MessageBytesFactory mbf)
           
 void setInt(int i)
          Deprecated. The buffer are general purpose, caching for headers should be done in headers
 void setString(java.lang.String s)
           
 void setTime(long t)
           
 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()
           
 void toChars()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

T_NULL

public static final int T_NULL

T_STR

public static final int T_STR

T_BYTES

public static final int T_BYTES

T_CHARS

public static final int T_CHARS
Constructor Detail

MessageBytes

public MessageBytes()
Creates a new, uninitialized MessageBytes object.
Method Detail

newInstance

public static MessageBytes newInstance()

setCaseSenitive

public void setCaseSenitive(boolean b)

getClone

public MessageBytes getClone()

isNull

public boolean isNull()

recycle

public void recycle()
Resets the message bytes to an uninitialized state.

setBytes

public void setBytes(byte[] b,
                     int off,
                     int len)
Sets the message bytes to the specified subarray of bytes.
Parameters:
b - the ascii bytes
off - the start offset of the bytes
len - the length of the bytes

setEncoding

public void setEncoding(java.lang.String enc)

setChars

public void setChars(char[] c,
                     int off,
                     int len)

resetStringValue

public void resetStringValue()
Remove the cached string value. Use it after a conversion on the byte[] or after the encoding is changed

setString

public void setString(java.lang.String s)

toString

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

getType

public int getType()

getByteChunk

public ByteChunk getByteChunk()
Returns the message bytes.

getCharChunk

public CharChunk getCharChunk()

getString

public java.lang.String getString()

toBytes

public void toBytes()

toChars

public void toChars()

getLength

public int getLength()
Returns the length of the buffer.

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

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

equals

public boolean equals(MessageBytes mb)

startsWith

public boolean startsWith(java.lang.String s)
Returns true if the message bytes starts with the specified string.
Parameters:
s - the string

startsWithIgnoreCase

public boolean startsWithIgnoreCase(java.lang.String s,
                                    int pos)
Returns true if the message bytes starts with the specified string.
Parameters:
s - the string

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

indexOf

public int indexOf(char c)

indexOf

public int indexOf(java.lang.String s,
                   int starting)

indexOf

public int indexOf(java.lang.String s)

indexOfIgnoreCase

public int indexOfIgnoreCase(java.lang.String s,
                             int starting)

indexOf

public int indexOf(char c,
                   int starting)
Returns true if the message bytes starts with the specified string.
Parameters:
s - the string

duplicate

public void duplicate(MessageBytes src)
               throws java.io.IOException
Copy the src into this MessageBytes, allocating more space if needed

setTime

public 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.


setTime

public void setTime(long t)

setInt

public void setInt(int i)
Deprecated. The buffer are general purpose, caching for headers should be done in headers

Set the buffer to the representation of an int

getTime

public long getTime()
Deprecated. The buffer are general purpose, caching for headers should be done in headers


getInt

public int getInt()
Deprecated. The buffer are general purpose, caching for headers should be done in headers

Convert the buffer to an int, cache the value

setFactory

public static void setFactory(MessageBytes.MessageBytesFactory mbf)


Copyright © 2001 Apache Software Foundation. All Rights Reserved.