|
Purple Code | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.purpletech.message.Message
A Message is passed between peers
| Field Summary | |
static int |
ALL
peer id number meaning "all clients" |
protected java.lang.String |
classname
|
protected java.lang.Object |
data
contents of message |
protected int |
from
transient id for source of message |
static int |
MAGIC
|
static int |
NONE
peer id number meaning "no client" |
protected int |
to
transient id for destination of message |
protected short |
type
type of message (determines which class to use to deserialize it) |
static short |
TYPE_BOOLEAN
the data object contains a Boolean |
static short |
TYPE_BYTE
the data object contains a Byte |
static short |
TYPE_BYTES
the data object contains a byte array |
static short |
TYPE_CHAR
the data object contains a Character |
static short |
TYPE_DOUBLE
the data object contains a Double |
static short |
TYPE_FLOAT
the data object contains a Float |
static short |
TYPE_HASHED
the data object contains a Writeable, but the name of the writeable is encoded for efficiency (not yet implemented) |
static short |
TYPE_INT
the data object contains a Integer |
static short |
TYPE_LONG
the data object contains a Long |
static short |
TYPE_SHORT
the data object contains a Short |
static short |
TYPE_STRING
the data object contains a String |
static short |
TYPE_SYSTEM
the data object contains a SystemData object |
static short |
TYPE_WRITEABLE
the data object contains a Writeable |
protected long |
whenCreated
msec since epoch when it was created |
| Constructor Summary | |
|
Message(java.io.DataInputStream in)
|
|
Message(java.io.InputStream in)
|
|
Message(int from,
int to,
byte[] data)
Initialize this object. |
|
Message(int from,
int to,
java.lang.Number data)
|
|
Message(int from,
int to,
java.lang.String data)
|
|
Message(int from,
int to,
SystemData data)
|
|
Message(int from,
int to,
Writeable data)
|
|
Message(Message m)
copy constructor |
|
Message(Message m,
boolean copyWhenCreated)
copy constructor |
protected |
Message(short type,
int from,
int to,
java.lang.String classname,
java.lang.Object data)
standard constructor |
| Method Summary | |
java.lang.String |
getClassName()
|
java.lang.Object |
getData()
|
java.io.DataInputStream |
getDataInputStream()
only makes sense with TYPE_BYTES |
java.io.DataOutputStream |
getDataOutputStream()
returns a DataOutputStream that stores its bytes into this Message's data property. |
int |
getFrom()
|
java.io.InputStream |
getInputStream()
|
int |
getInt()
Alternate accessor -- get data as int |
java.io.OutputStream |
getOutputStream()
returns an OutputStream that stores its bytes into this Message's data property. |
java.lang.String |
getString()
Alternate accessor -- get data as string |
int |
getTo()
|
short |
getType()
|
long |
getWhenCreated()
returns the time the message was constructed, in the local time of the local machine |
protected static short |
numberToType(java.lang.Number data)
|
void |
read(java.io.DataInputStream in)
Read a message from a stream. |
protected void |
read(java.io.InputStream in)
Read a message from a stream. |
static Message |
readMessage(java.io.DataInputStream in)
Factory method. |
void |
setData(int x)
Alternate mutator -- set data as int |
void |
setData(java.lang.Object data)
|
void |
setFrom(int from)
|
void |
setTo(int to)
|
java.lang.String |
toString()
|
void |
write(java.io.DataOutputStream out)
Write this message to a stream |
void |
write(java.io.OutputStream out)
Write this message to a stream |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int ALL
public static final int NONE
public static final int MAGIC
public static final short TYPE_BYTES
public static final short TYPE_BOOLEAN
public static final short TYPE_BYTE
public static final short TYPE_SHORT
public static final short TYPE_CHAR
public static final short TYPE_INT
public static final short TYPE_LONG
public static final short TYPE_FLOAT
public static final short TYPE_DOUBLE
public static final short TYPE_STRING
public static final short TYPE_WRITEABLE
public static final short TYPE_HASHED
public static final short TYPE_SYSTEM
protected short type
protected java.lang.String classname
protected int from
protected int to
protected java.lang.Object data
protected long whenCreated
| Constructor Detail |
protected Message(short type,
int from,
int to,
java.lang.String classname,
java.lang.Object data)
public Message(Message m)
public Message(Message m,
boolean copyWhenCreated)
public Message(int from,
int to,
byte[] data)
public Message(int from,
int to,
java.lang.String data)
public Message(int from,
int to,
java.lang.Number data)
public Message(int from,
int to,
SystemData data)
public Message(int from,
int to,
Writeable data)
public Message(java.io.DataInputStream in)
throws java.io.IOException
public Message(java.io.InputStream in)
throws java.io.IOException
| Method Detail |
protected static short numberToType(java.lang.Number data)
public short getType()
public int getFrom()
public void setFrom(int from)
from - which (transient, server-specific) peer created this messagepublic int getTo()
public void setTo(int to)
to - which (transient, server-specific) peer will receive this messagepublic java.lang.Object getData()
public void setData(java.lang.Object data)
public long getWhenCreated()
public java.lang.String getString()
public int getInt()
public void setData(int x)
public java.io.InputStream getInputStream()
public java.io.DataInputStream getDataInputStream()
public java.io.DataOutputStream getDataOutputStream()
public java.io.OutputStream getOutputStream()
public java.lang.String toString()
toString in class java.lang.Object
public void write(java.io.OutputStream out)
throws java.io.IOException
java.io.IOException
public void write(java.io.DataOutputStream out)
throws java.io.IOException
write in interface Writeablejava.io.IOException
protected void read(java.io.InputStream in)
throws java.io.IOException
java.io.IOExceptionreadMessage(java.io.DataInputStream)
public void read(java.io.DataInputStream in)
throws java.io.IOException
read in interface Writeablejava.io.IOExceptionreadMessage(java.io.DataInputStream)public java.lang.String getClassName()
getClassName in interface Writeable
public static Message readMessage(java.io.DataInputStream in)
throws java.io.IOException
java.io.IOException
|
Documentation generated March 5 2003 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||