|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectnet.zortrium.p2proto.Msg
public final class Msg
The main class representing a message to be sent over the network. Every
message contains a numeric type (defined by the user) and optionally
arbitrary binary content. The suggested usage pattern is to encapsulate a
user-defined protocol buffer message in the content, in which the
encapsulated message class is indicated by the message type. The encapsulated
message can then be extracted by checking the message type. See
PeerListener for an example of this.
| Constructor Summary | |
|---|---|
Msg(int type)
Construct a new message with the given type and no content. |
|
Msg(int type,
byte[] content)
Construct a new message with the given type and binary content. |
|
Msg(int type,
byte[] content,
int offset,
int size)
Construct a new message with the given type and binary content (of the given size at the given offset). |
|
Msg(int type,
com.google.protobuf.ByteString content)
Construct a new message with the given type and content. |
|
Msg(int type,
com.google.protobuf.Message.Builder content)
Convenience constructor that builds the given protocol buffer message, then calls Msg(int, Message). |
|
Msg(int type,
com.google.protobuf.Message content)
Construct a new message with the given type and the given protocol buffer message as content. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object obj)
Two messages are equal if their type and content are identical. |
com.google.protobuf.ByteString |
getContent()
Get the binary content of the message (or null if the message has no content). |
int |
getType()
Get the type of the message. |
boolean |
hasContent()
Check whether this message contains any content. |
int |
hashCode()
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Msg(int type,
com.google.protobuf.ByteString content)
Msg(int). The given
type must be nonnegative.
type - The type of the message.content - The content of the message (or null).
IllegalArgumentException - If the given type is negative.public Msg(int type)
type - The type of the message.
IllegalArgumentException - If the given type is negative.
public Msg(int type,
byte[] content)
type - The type of the message.content - The content of the message.
IllegalArgumentException - If the given type is negative.
public Msg(int type,
byte[] content,
int offset,
int size)
type - The type of the message.content - The content byte array.offset - Offset into the content array.size - Number of bytes to read in the content array.
public Msg(int type,
com.google.protobuf.Message content)
type - The type of the message.content - The content of the message.
public Msg(int type,
com.google.protobuf.Message.Builder content)
Msg(int, Message).
type - The type of the message.content - The content of the message.| Method Detail |
|---|
public int getType()
public com.google.protobuf.ByteString getContent()
parseFrom in
the appropriate protocol buffer class (as determined by the value of
getType()).
public boolean hasContent()
public String toString()
toString in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||