Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.ajp
Class Ajp13Packet  view Ajp13Packet download Ajp13Packet.java

java.lang.Object
  extended byorg.apache.ajp.Ajp13Packet

public class Ajp13Packet
extends java.lang.Object

A single packet for communication between the web server and the container. Designed to be reused many times with no creation of garbage. Understands the format of data types for these packets. Can be used (somewhat confusingly) for both incoming and outgoing packets. See Ajp14/Ajp13Packet.


Field Summary
static int AJP13_SW_HEADER
           
static int AJP13_WS_HEADER
           
(package private)  byte[] buff
          Holds the bytes of the packet
static java.lang.String DEFAULT_CHAR_ENCODING
           
(package private)  java.lang.String encoding
          encoding to use when converting byte[] <-> string
(package private)  int len
          This actually means different things depending on whether the packet is read or write.
private static org.apache.commons.logging.Log log
           
(package private)  int pos
          The current read or write position in the buffer
 
Constructor Summary
Ajp13Packet(byte[] b)
          Create a new packet with given bytes
Ajp13Packet(int size)
          Create a new packet with an internal buffer of given size.
 
Method Summary
 org.apache.tomcat.util.buf.MessageBytes addHeader(org.apache.tomcat.util.http.MimeHeaders headers)
           
 void appendBool(boolean val)
           
 void appendByte(byte val)
           
 void appendBytes(byte[] b, int off, int numBytes)
          Copy a chunk of bytes into the packet, starting at the current write position.
 void appendInt(int val)
           
 void appendLongInt(int val)
           
 void appendString(java.lang.String str)
          Write a String out at the current write position.
 void appendXBytes(byte[] b, int off, int numBytes)
          Copy a chunk of bytes into the packet, starting at the current write position.
 int checkIn()
          Parse the packet header for a packet sent from the web server to the container.
 void dump(java.lang.String msg)
           
 void end()
          For a packet to be sent to the web server, finish the process of accumulating data and write the length of the data payload into the header.
 boolean getBool()
           
 byte[] getBuff()
          Get the internal buffer
 byte getByte()
           
 int getByteOff()
          Get offset into internal buffer.
 int getBytes(byte[] dest)
          Copy a chunk of bytes from the packet into an array and advance the read position past the chunk.
 java.lang.String getEncoding()
          Get the encoding used for byte[] <-> string conversions.
 int getInt()
          Read an integer from packet, and advance the read position past it.
 int getLen()
          Get length.
 int getLongInt()
          Read a 32 bits integer from packet, and advance the read position past it.
 void getMessageBytes(org.apache.tomcat.util.buf.MessageBytes mb)
           
 java.lang.String getString()
          Read a String from the packet, and advance the read position past it.
 int getXBytes(byte[] dest, int length)
          Copy a chunk of bytes from the packet into an array and advance the read position past the chunk.
private  java.lang.String hex(int x)
           
private  void hexLine(int start)
           
 byte peekByte()
           
 int peekInt()
          Read an integer from the packet, but don't advance the read position past it.
 int peekLongInt()
          Read a 32 bits integer from the packet, but don't advance the read position past it.
 void reset()
          Prepare this packet for accumulating a message from the container to the web server.
 void setByteOff(int c)
          Set offset into internal buffer.
 void setEncoding(java.lang.String encoding)
          Set the encoding to use for byte[] <-> string conversions.
private  void setInt(int bPos, int val)
          Write an 32 bit integer at an arbitrary position in the packet,but don't change the write position.
private  void setLongInt(int bPos, int val)
          Write a 32 bits integer at an arbitrary position in the packet, but don't change the write position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

DEFAULT_CHAR_ENCODING

public static final java.lang.String DEFAULT_CHAR_ENCODING
See Also:
Constant Field Values

AJP13_WS_HEADER

public static final int AJP13_WS_HEADER
See Also:
Constant Field Values

AJP13_SW_HEADER

public static final int AJP13_SW_HEADER
See Also:
Constant Field Values

encoding

java.lang.String encoding
encoding to use when converting byte[] <-> string


buff

byte[] buff
Holds the bytes of the packet


pos

int pos
The current read or write position in the buffer


len

int len
This actually means different things depending on whether the packet is read or write. For read, it's the length of the payload (excluding the header). For write, it's the length of the packet as a whole (counting the header). Oh, well.

Constructor Detail

Ajp13Packet

public Ajp13Packet(int size)
Create a new packet with an internal buffer of given size.


Ajp13Packet

public Ajp13Packet(byte[] b)
Create a new packet with given bytes

Method Detail

setEncoding

public void setEncoding(java.lang.String encoding)
Set the encoding to use for byte[] <-> string conversions.


getEncoding

public java.lang.String getEncoding()
Get the encoding used for byte[] <-> string conversions.


getBuff

public byte[] getBuff()
Get the internal buffer


getLen

public int getLen()
Get length.


getByteOff

public int getByteOff()
Get offset into internal buffer.


setByteOff

public void setByteOff(int c)
Set offset into internal buffer.


checkIn

public int checkIn()
Parse the packet header for a packet sent from the web server to the container. Set the read position to immediately after the header.


reset

public void reset()
Prepare this packet for accumulating a message from the container to the web server. Set the write position to just after the header (but leave the length unwritten, because it is as yet unknown).


end

public void end()
For a packet to be sent to the web server, finish the process of accumulating data and write the length of the data payload into the header.


setInt

private void setInt(int bPos,
                    int val)
Write an 32 bit integer at an arbitrary position in the packet,but don't change the write position.


appendInt

public void appendInt(int val)

appendByte

public void appendByte(byte val)

appendBool

public void appendBool(boolean val)

appendString

public void appendString(java.lang.String str)
                  throws java.io.UnsupportedEncodingException
Write a String out at the current write position. Strings are encoded with the length in two bytes first, then the string, and then a terminating \0 (which is not included in the encoded length). The terminator is for the convenience of the C code, where it saves a round of copying. A null string is encoded as a string with length 0.


appendBytes

public void appendBytes(byte[] b,
                        int off,
                        int numBytes)
Copy a chunk of bytes into the packet, starting at the current write position. The chunk of bytes is encoded with the length in two bytes first, then the data itself, and finally a terminating \0 (which is not included in the encoded length).


setLongInt

private void setLongInt(int bPos,
                        int val)
Write a 32 bits integer at an arbitrary position in the packet, but don't change the write position.


appendLongInt

public void appendLongInt(int val)

appendXBytes

public void appendXBytes(byte[] b,
                         int off,
                         int numBytes)
Copy a chunk of bytes into the packet, starting at the current write position. The chunk of bytes IS NOT ENCODED with ANY length header.


getInt

public int getInt()
Read an integer from packet, and advance the read position past it. Integers are encoded as two unsigned bytes with the high-order byte first, and, as far as I can tell, in little-endian order within each byte.


peekInt

public int peekInt()
Read an integer from the packet, but don't advance the read position past it.


getByte

public byte getByte()

peekByte

public byte peekByte()

getBool

public boolean getBool()

getMessageBytes

public void getMessageBytes(org.apache.tomcat.util.buf.MessageBytes mb)

addHeader

public org.apache.tomcat.util.buf.MessageBytes addHeader(org.apache.tomcat.util.http.MimeHeaders headers)

getString

public java.lang.String getString()
                           throws java.io.UnsupportedEncodingException
Read a String from the packet, and advance the read position past it. See appendString for details on string encoding.


getBytes

public int getBytes(byte[] dest)
Copy a chunk of bytes from the packet into an array and advance the read position past the chunk. See appendBytes() for details on the encoding.


getLongInt

public int getLongInt()
Read a 32 bits integer from packet, and advance the read position past it. Integers are encoded as four unsigned bytes with the high-order byte first, and, as far as I can tell, in little-endian order within each byte.


getXBytes

public int getXBytes(byte[] dest,
                     int length)
Copy a chunk of bytes from the packet into an array and advance the read position past the chunk. See appendXBytes() for details on the encoding.


peekLongInt

public int peekLongInt()
Read a 32 bits integer from the packet, but don't advance the read position past it.


hex

private java.lang.String hex(int x)

hexLine

private void hexLine(int start)

dump

public void dump(java.lang.String msg)