Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk.debugger
Class Packet

    java.lang.Object
      com.sun.squawk.debugger.Packet

Direct Known Subclasses:
  CommandPacket, ReplyPacket

    public abstract class Packet

extends Object

A `Packet` encapsulates a JDWP command or reply packet.

Field Summary
`static short` | `FLAG_NEEDS_REPLY` Indicates a packet for which no reply is expected.
`static short` | `FLAG_REPLY` The flag bit value indicating a reply packet.

Constructor Summary
`Packet(int id)` Creates a Packet for a new JDWP request.
`Packet(int id, int dataLength, DataInputStream data)` Creates a Packet to encapsulate a received JDWP packet.

Method Summary
`protected void` | `appendData(StringBuffer buf)` Appends a textualized form of this packet's data to a given StringBuffer.
`abstract int` | `getFlags()` Gets the value for the 'flags' field in the header of this packet.
`int` | `getID()` Gets the ID that is used to pair this packet with its associated command or reply packet (if any).
`PacketInputStream` | `getInputStream()` Gets a DataInputStream to read the data in this packet.
`PacketOutputStream` | `getOutputStream()` Gets a PacketOutputStream to write some data to this packet.
`int` | `getSize()` Gets the size (in bytes) of the entire packet.
`abstract String` | `toString()` Returns a string representation of the object.
`void` | `write(DataOutputStream dos)` Writes this packet to a given output stream.
`protected abstract void` | `writeFields(DataOutputStream dos)` Hook for sublasses to write their specific fields to a packet being sent.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### FLAG_REPLY

    public static final short FLAG_REPLY

  The flag bit value indicating a reply packet.

  See Also:
    Constant Field Values

### FLAG_NEEDS_REPLY

    public static final short FLAG_NEEDS_REPLY

  Indicates a packet for which no reply is expected.

  See Also:
    Constant Field Values

Constructor Detail

### Packet

    public Packet(int id)

  Creates a Packet for a new JDWP request.

  Parameters:
    `id` - the identifier of the new packet

### Packet

    public Packet(int id,
                  int dataLength,
                  DataInputStream data)
           throws IOException

  Creates a Packet to encapsulate a received JDWP packet.

  Parameters:
    `owner` - the JDWPListener that received the packet
    `id` - the identifier in the packet
    `dataLength` - the length of the data to read from `data`
    `data` - the contents of the data field of the packet
  Throws:
    `IOException`

Method Detail

### getInputStream

    public PacketInputStream getInputStream()

  Gets a DataInputStream to read the data in this packet.

  Returns:
    a DataInputStream to read the data in this packet

### getOutputStream

    public PacketOutputStream getOutputStream()

  Gets a PacketOutputStream to write some data to this packet. This cannot be called on a packet that was initialized with some received data.

  Returns:
    a PacketOutputStream to write the data in this packet

### getID

    public final int getID()

  Gets the ID that is used to pair this packet with its associated command or reply packet (if any).

  Returns:
    the ID that is unique to this command and reply packet pair this packet belongs to (if any)

### toString

    public abstract String toString()

  Returns a string representation of the object. In general, the `toString` method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

  The `toString` method for class `Object` returns a string consisting of the name of the class of which the object is an instance, the at-sign character ``@`', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

  >      getClass().getName() + '@' + Integer.toHexString(hashCode())

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of the object.

### appendData

    protected void appendData(StringBuffer buf)

  Appends a textualized form of this packet's data to a given StringBuffer.

  Parameters:
    `buf` - the buffer to extend

### getFlags

    public abstract int getFlags()

  Gets the value for the 'flags' field in the header of this packet.

### writeFields

    protected abstract void writeFields(DataOutputStream dos)
                                 throws IOException

  Hook for sublasses to write their specific fields to a packet being sent.

  Parameters:
    `dos` - the stream to write the fields to
  Throws:
    `IOException` - if an IO error occurs

### getSize

    public final int getSize()

  Gets the size (in bytes) of the entire packet. This value may change if there is currently an output stream adding data to the packet.

  Returns:
    the size (in bytes) of the packets (include the header fields)

### write

    public final void write(DataOutputStream dos)
                     throws IOException

  Writes this packet to a given output stream. No further data can be added to this packet once this operation is completed.

  Parameters:
    `dos` - where to write the packet
  Throws:
    `IOException` - if an IO error occurs

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"