|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectproper.core.ProperObject
proper.remote.messages.Message
public class Message
This class encapsulates the standard behaviour and methods for all messages.
A message looks like this:
<?xml version="1.0" encoding="UTF-8"?> <message> <head> <from> <ip>some ip</ip> <port>some port</port> </from> <type>type of the message</type> </head> <body> the actual data of the message... </body> </message>
Field Summary | |
---|---|
static java.lang.String |
BODY
the body node (the actual payload) |
static java.lang.String |
FROM
the from node in the header |
static java.lang.String |
HEADER
the header node |
static java.lang.String |
IP
the ip node in the from node |
static java.lang.String |
MESSAGE
the xml root node |
static java.lang.String |
PORT
the port node in the from node |
static java.lang.String |
TYPE
the type of the message node in the header |
Fields inherited from interface proper.core.ProperInterface |
---|
VERSION |
Constructor Summary | |
---|---|
Message()
initializes the object |
|
Message(int port)
initializes the object with the given Port, IP/Hostname is determined automatically |
|
Message(Message msg)
initializes the object with the given Message |
|
Message(java.io.Reader reader)
initializes the object with the given xml data |
|
Message(java.lang.String ip,
int port)
initializes the object with the given IP and Port |
Method Summary | |
---|---|
void |
clear()
creates an empty message with header and body, derived classes only need to override clearBody() |
void |
clearBody()
sets the body back to standard |
Element |
getBody()
returns the body element |
java.lang.String |
getBodyContent()
returns the content of the body element, can be NULL |
java.lang.String |
getContent(Element node)
returns the content of the specified node, can be NULL (e.g. |
java.lang.String |
getContent(Element node,
boolean returnEmptyIfNull)
returns the content of the specified node, can be NULL (e.g. |
java.util.Vector |
getContent(Element node,
java.lang.String path)
returns all the contents of nodes found according to the path from starting from the given node |
java.util.Vector |
getContent(Element node,
java.lang.String path,
boolean returnEmptyIfNull)
returns all the contents of nodes found according to the path from starting from the given node |
java.util.Vector |
getContent(java.lang.String path)
returns all the contents of nodes found according to the path from starting from the root node |
Element |
getHeader()
returns the header element |
java.lang.String |
getIP()
returns the content of the IP node |
int |
getPort()
returns the content of the PORT node, -1 if not successful |
java.lang.String |
getType()
returns the type of the message |
static void |
main(java.lang.String[] args)
for testing only |
void |
setBodyContent(java.lang.String content)
sets the content of the body element, can be NULL |
void |
setContent(Element node,
java.lang.Object content)
sets the content of the specified node, but only if the node is not NULL |
void |
setIP(java.lang.String ip)
sets the IP |
void |
setPort(int port)
sets the port |
void |
setType(java.lang.String type)
sets the type of the message |
java.lang.String |
toString()
the message in string representation, i.e. |
Methods inherited from class proper.core.ProperObject |
---|
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MESSAGE
public static final java.lang.String HEADER
public static final java.lang.String FROM
public static final java.lang.String IP
public static final java.lang.String PORT
public static final java.lang.String TYPE
public static final java.lang.String BODY
Constructor Detail |
---|
public Message()
public Message(java.io.Reader reader)
public Message(Message msg)
public Message(int port)
public Message(java.lang.String ip, int port)
Method Detail |
---|
public Element getHeader()
public Element getBody()
public java.lang.String getBodyContent()
public void setBodyContent(java.lang.String content)
public java.lang.String getContent(Element node)
public java.lang.String getContent(Element node, boolean returnEmptyIfNull)
node
- the node to return it's content fromreturnEmptyIfNull
- if this is TRUE we return an empty String
instead of nullpublic void setContent(Element node, java.lang.Object content)
public java.util.Vector getContent(java.lang.String path)
path
- the search path
public java.util.Vector getContent(Element node, java.lang.String path)
node
- the node to start the search frompath
- the search path
public java.util.Vector getContent(Element node, java.lang.String path, boolean returnEmptyIfNull)
node
- the node to start the search frompath
- the search pathreturnEmptyIfNull
- returns an empty string instead of null in the
result vector
public void clear()
MESSAGE
,
HEADER
,
BODY
,
clearBody()
public void clearBody()
public java.lang.String getIP()
public void setIP(java.lang.String ip)
public int getPort()
public void setPort(int port)
public java.lang.String getType()
public void setType(java.lang.String type)
public java.lang.String toString()
toString
in class ProperObject
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |