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

## things.thinger.service.actor
Class ActorMessage

    java.lang.Object
      things.thinger.service.actor.ActorMessage

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  ActorDisposition

    public class ActorMessage

extends java.lang.Object
implements java.io.Serializable

A message.

MESSAGE = SEQUENCE,TYPE,NUMBER.PARAMETERS,NUMBER.ATTRIBUTES,PARAMETERS,ATTRIBUTES
SEQUENCE = int (4-byte, jvm ordered)
NUMBER.PARAMETERS = int (4-byte, jvm ordered), number of at PAIRs
NUMBER.ATTRIBUTES = int (4-byte, jvm ordered), number of at PAIRs
TYPE = STRING (for the message type)

PARAMETERS = PAIR.1,PAIR.N
NUMBER = int (4-byte, jvm ordered) representing the number of pairs
PAIR.x = STRING,STRING (representing name/value)
STRING = SIZE,BYTES
SIZE = int (4-byte, jvm ordered)
BYTES = byte[SIZE]

This is not entirely thread safe. You should add a parameter during load or save which could cause the messages to get munged. I'm not sure this would ever be used across multiple threads, so I won't synchronize it.

Version:
  1.0

  Version History

      EPG - Initial - 11 MAY 07

Author:
  Erich P. Gatejen
See Also:
  Serialized Form

Field Summary
`int` | `sequence` The sequence number.

Constructor Summary
`ActorMessage()` Default constructor.
`ActorMessage(int theSequence)` This is the convenience constructor.

Method Summary
`void` | `addAttribute(NVImmutable p)` Add an attribute.
`void` | `addAttribute(java.lang.String name, java.lang.String value)` Add an attribute.
`void` | `addParamter(NVImmutable p)` Add a parameter.
`void` | `addParamter(java.lang.String name, java.lang.String value)` Add a parameter.
`java.lang.String` | `getAttribute(java.lang.String name)` Get a parameter by name.
`java.lang.String` | `getParameter(java.lang.String name)` Get a parameter by name.
`java.lang.String` | `getType()` Get type.
`void` | `load(java.io.InputStream is)` Load this message from a stream.
`void` | `save(java.io.OutputStream os)` Save this message to a stream.
`void` | `setType(java.lang.String messageType)` Set type.

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

Field Detail

### sequence

    public int sequence

  The sequence number.

Constructor Detail

### ActorMessage

    public ActorMessage()

  Default constructor.

### ActorMessage

    public ActorMessage(int theSequence)

  This is the convenience constructor.

  Parameters:
    `theSequence` - A sequence number. This should be incremented for every order.

Method Detail

### addParamter

    public void addParamter(NVImmutable p)
                     throws java.lang.Throwable

  Add a parameter. It will be encoded into a PAIR.

  Parameters:
    `p` - A ready made parameter. It will be treated as a single value.
  Throws:
    `java.lang.Throwable`

### addParamter

    public void addParamter(java.lang.String name,
                            java.lang.String value)
                     throws java.lang.Throwable

  Add a parameter. It will be encoded into a PAIR. There are practical and safety limits to the name and value String sizes. Try to keep them under 2k. If they are too big, they will be rejected by the distant end.

  Parameters:
    `name` - The parameter name.
    `value` - The parameter value.
  Throws:
    `java.lang.Throwable`

### getParameter

    public java.lang.String getParameter(java.lang.String name)

  Get a parameter by name.

  Parameters:
    `name` - The parameter's name. If null it will return null;
  Returns:
    The parameter's value or null (ActorConstants.NO_PARAMETER) if it isn't set.

### addAttribute

    public void addAttribute(NVImmutable p)
                      throws java.lang.Throwable

  Add an attribute. It will be encoded into a PAIR.

  Parameters:
    `p` - A ready made attribute. It will be treated as a single value.
  Throws:
    `java.lang.Throwable`

### addAttribute

    public void addAttribute(java.lang.String name,
                             java.lang.String value)
                      throws java.lang.Throwable

  Add an attribute. It will be encoded into a PAIR. There are practical and safety limits to the name and value String sizes. Try to keep them under 2k. If they are too big, they will be rejected by the distant end.

  Parameters:
    `name` - The attribute name.
    `value` - The attribute value.
  Throws:
    `java.lang.Throwable`

### getAttribute

    public java.lang.String getAttribute(java.lang.String name)

  Get a parameter by name.

  Parameters:
    `name` - The parameter's name. If null., it will return null;
  Returns:
    The parameter's value or null (ActorConstants.NO_PARAMETER) if it isn't set.

### load

    public void load(java.io.InputStream is)
              throws java.lang.Throwable

  Load this message from a stream.

  Parameters:
    `is` - The stream.
  Throws:
    `java.lang.Throwable`

### save

    public void save(java.io.OutputStream os)
              throws java.lang.Throwable

  Save this message to a stream.

  Parameters:
    `os` - The stream.
  Throws:
    `java.lang.Throwable`

### setType

    public void setType(java.lang.String messageType)

  Set type.

  Parameters:
    `messageType` - The type. Try to keep them under 2k. If they are too big, they will be rejected by the distant end.

### getType

    public java.lang.String getType()

  Get type.

  Returns:
    the type.

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

Things.