Home » apache-tomcat-6.0.26-src » org.apache » tomcat » util » buf » [javadoc | source]
org.apache.tomcat.util.buf
public final class: MessageBytes [javadoc | source]
java.lang.Object
   org.apache.tomcat.util.buf.MessageBytes

All Implemented Interfaces:
    Cloneable, java$io$Serializable

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:
public static class  MessageBytes.MessageBytesFactory   
Field Summary
public static final  int T_NULL     
public static final  int T_STR    getType() is T_STR if the the object used to create the MessageBytes was a String 
public static final  int T_BYTES    getType() is T_STR if the the object used to create the MessageBytes was a byte[] 
public static final  int T_CHARS    getType() is T_STR if the the object used to create the MessageBytes was a char[] 
Constructor:
 public MessageBytes() 
    Method from org.apache.tomcat.util.buf.MessageBytes Summary:
    duplicate,   equals,   equals,   equalsIgnoreCase,   getByteChunk,   getCharChunk,   getClone,   getInt,   getLength,   getLong,   getString,   getTime,   getType,   hashCode,   indexOf,   indexOf,   indexOf,   indexOf,   indexOfIgnoreCase,   isNull,   newInstance,   recycle,   resetStringValue,   setBytes,   setCaseSenitive,   setChars,   setEncoding,   setFactory,   setInt,   setLong,   setString,   setTime,   setTime,   startsWith,   startsWithIgnoreCase,   toBytes,   toChars,   toString
    Methods from java.lang.Object:
    clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
    Method from org.apache.tomcat.util.buf.MessageBytes Detail:
     public  void duplicate(MessageBytes src) throws IOException 
      Copy the src into this MessageBytes, allocating more space if needed
     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. Valid only if T_BYTES or after a conversion was made.
     public CharChunk getCharChunk() 
      Returns the char chunk, representing the char[] and offset/length. Valid only if T_CHARS or after a conversion was made.
     public MessageBytes getClone() 
     public int getInt() 
      Convert the buffer to an int, cache the value
     public int getLength() 
      Returns the length of the original buffer. Note that the length in bytes may be different from the length in chars.
     public long getLong() 
      Convert the buffer to an long, cache the value
     public String getString() 
      Returns the string value. Valid only if T_STR or after a conversion was made.
     public long getTime() 
    Deprecated! The - buffer are general purpose, caching for headers should be done in headers

     public int getType() 
      Return the type of the original content. Can be T_STR, T_BYTES, T_CHARS or T_NULL
     public int hashCode() 
     public int indexOf(char c) 
     public int indexOf(String s) 
     public int indexOf(String s,
        int starting) 
     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() 
      Construct a new MessageBytes instance
     public  void recycle() 
      Resets the message bytes to an uninitialized (NULL) state.
     public  void resetStringValue() 
      Remove the cached string value. Use it after a conversion on the byte[] or after the encoding is changed XXX Is this needed ?
     public  void setBytes(byte[] b,
        int off,
        int len) 
      Sets the content to the specified subarray of bytes.
     public  void setCaseSenitive(boolean b) 
      Configure the case sensitivity
     public  void setChars(char[] c,
        int off,
        int len) 
      Sets the content to be a char[]
     public  void setEncoding(String enc) 
      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.
     public static  void setFactory(MessageBytesFactory mbf) 
     public  void setInt(int i) 
      Set the buffer to the representation of an int
     public  void setLong(long l) 
      Set the buffer to the representation of an long
     public  void setString(String s) 
      Set the content to be a string
     public  void setTime(long t) 
    Deprecated!
     public  void setTime(long t,
        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.

     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. Do a char->byte conversion.
     public  void toChars() 
      Convert to char[] and fill the CharChunk. XXX Not optimized - it converts to String first.
     public String toString() 
      Compute the string value