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

## org.codehaus.activemq.message
Class WireFormat

    java.lang.Object
      org.codehaus.activemq.message.WireFormat

Direct Known Subclasses:
  DefaultWireFormat, JabberWireFormat

public abstract class WireFormat
extends java.lang.Object

Represents a strategy of encoding packets on the wire or on disk using some kind of serialization or wire format.

We use a default efficient format for Java to Java communication but other formats to other systems can be used, such as using simple text strings when talking to JavaScript or coming up with other formats for talking to C / C# languages or proprietary messaging systems we wish to interface with at the wire level etc.

Version:
  $Revision: 1.9 $

Constructor Summary
`WireFormat()`

Method Summary
`abstract WireFormat` | `copy()` Creates a new copy of this wire format so it can be used in another thread/context
`Packet` | `fromBytes(byte[] bytes)` Reads the packet from the given byte[]
`Packet` | `fromBytes(byte[] bytes, int offset, int length)` Reads the packet from the given byte[]
`abstract Packet` | `readPacket(java.io.DataInput in)` Reads a packet from the given input stream
`abstract Packet` | `readPacket(int firstByte, java.io.DataInput in)` A helper method for working with sockets where the first byte is read first, then the rest of the message is read.
`Packet` | `readPacket(java.lang.String channelID, java.net.DatagramPacket dpacket)` Read a packet from a Datagram packet from the given channelID.
`byte[]` | `toBytes(Packet packet)` A helper method which converts a packet into a byte array
`abstract void` | `writePacket(Packet packet, java.io.DataOutput out)` Writes the packet to the given output stream
`java.net.DatagramPacket` | `writePacket(java.lang.String channelID, Packet packet)` Writes the given package to a new datagram

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

Constructor Detail

### WireFormat

    public WireFormat()

Method Detail

### readPacket

    public abstract Packet readPacket(java.io.DataInput in)
                               throws java.io.IOException

  Reads a packet from the given input stream

  Parameters:
    `in` -
  Returns:
  Throws:
    `java.io.IOException`

### readPacket

    public abstract Packet readPacket(int firstByte,
                                      java.io.DataInput in)
                               throws java.io.IOException

  A helper method for working with sockets where the first byte is read first, then the rest of the message is read.

  Its common when dealing with sockets to have different timeout semantics until the first non-zero byte is read of a message, after which time a zero timeout is used.

  Parameters:
    `firstByte` - the first byte of the packet
    `in` - the rest of the packet
  Returns:
  Throws:
    `java.io.IOException`

### readPacket

    public Packet readPacket(java.lang.String channelID,
                             java.net.DatagramPacket dpacket)
                      throws java.io.IOException

  Read a packet from a Datagram packet from the given channelID. If the packet is from the same channel ID as it was sent then we have a loop-back so discard the packet

  Parameters:
    `channelID` - is the unique channel ID
    `dpacket` -
  Returns:
    the packet read from the datagram or null if it should be discarded
  Throws:
    `java.io.IOException`

### writePacket

    public abstract void writePacket(Packet packet,
                                     java.io.DataOutput out)
                              throws java.io.IOException,
                                     JMSException

  Writes the packet to the given output stream

  Parameters:
    `packet` -
    `out` -
  Throws:
    `java.io.IOException`
    `JMSException`

### writePacket

    public java.net.DatagramPacket writePacket(java.lang.String channelID,
                                               Packet packet)
                                        throws java.io.IOException,
                                               JMSException

  Writes the given package to a new datagram

  Parameters:
    `channelID` - is the unique channel ID
    `packet` - is the packet to write
  Throws:
    `java.io.IOException`
    `JMSException`

### fromBytes

    public Packet fromBytes(byte[] bytes,
                            int offset,
                            int length)
                     throws java.io.IOException

  Reads the packet from the given byte[]

  Throws:
    `java.io.IOException`

### fromBytes

    public Packet fromBytes(byte[] bytes)
                     throws java.io.IOException

  Reads the packet from the given byte[]

  Throws:
    `java.io.IOException`

### toBytes

    public byte[] toBytes(Packet packet)
                   throws java.io.IOException,
                          JMSException

  A helper method which converts a packet into a byte array

  Parameters:
    `packet` -
  Returns:
    a byte array representing the packet using some wire protocol
  Throws:
    `java.io.IOException`
    `JMSException`

### copy

    public abstract WireFormat copy()

  Creates a new copy of this wire format so it can be used in another thread/context

  Returns:

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

Copyright © 2004 Protique, Ltd.. All Rights Reserved.