public abstract class Message
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Message.Type
enumeration for the different message types
|
Modifier and Type | Field and Description |
---|---|
private java.util.Date |
created
the point in time the message was generated
|
private static java.util.Map<java.lang.String,Message.Type> |
elementToTypeMap
map from the XML element's local name to the type
|
private java.lang.String |
messageID
the message ID
|
private Message.Type |
type
the type of the message
|
Constructor and Description |
---|
Message() |
Modifier and Type | Method and Description |
---|---|
abstract <R> R |
accept(MessageFuncVisitor<R> visitor)
call the suitable method of the given visitor
|
abstract void |
accept(MessageVisitor visitor)
call the suitable method of the given visitor
|
protected static Message |
createMessage(Message.Type type)
factory for the various message types
|
protected abstract void |
dataFromList(KVList list)
setups the object's data from the given list.
|
protected abstract void |
dataFromXml(org.w3c.dom.Element el)
set up the object's data from the given XML element.
|
static Message |
fromList(KVList list)
initialize the instance from the given key-value multi-list
|
static Message |
fromXml(org.w3c.dom.Element el)
create an instance from the given XML element
|
java.util.Date |
getCreationDate()
return the point in time at which the message was generated
|
java.lang.String |
getMessageID()
return the message ID
|
Message.Type |
getType()
return the type of the message
|
protected void |
setData(java.lang.String theID,
Message.Type theType,
java.util.Date theCreationDate)
set the member variables of this base class
|
java.lang.String |
toString()
return a string representation for debugging purposes
|
private java.lang.String messageID
private Message.Type type
private java.util.Date created
private static final java.util.Map<java.lang.String,Message.Type> elementToTypeMap
protected void setData(java.lang.String theID, Message.Type theType, java.util.Date theCreationDate)
theID
- the message IDtheType
- the typetheCreationDate
- the dateprotected static Message createMessage(Message.Type type)
type
- the type, may be null
(which behaves as an unknown type)java.lang.IllegalArgumentException
- if the given type is unknown
or unsupportedpublic static Message fromXml(org.w3c.dom.Element el) throws org.w3c.dom.DOMException, ResponseParseException
el
- the elementorg.w3c.dom.DOMException
- on DOM exceptionsResponseParseException
- if the data was not recognisedprotected abstract void dataFromXml(org.w3c.dom.Element el) throws org.w3c.dom.DOMException, ResponseParseException
el
- the elementorg.w3c.dom.DOMException
- on DOM exceptionsResponseParseException
- if the data was not recognisedpublic static Message fromList(KVList list) throws ResponseParseException
list
- the listResponseParseException
- if the list does not contain the
expected contentprotected abstract void dataFromList(KVList list) throws ResponseParseException
list
- the listResponseParseException
- if the list does not contain the
expected contentpublic java.lang.String getMessageID()
public Message.Type getType()
public java.util.Date getCreationDate()
public abstract void accept(MessageVisitor visitor)
visitor
- the visitorpublic abstract <R> R accept(MessageFuncVisitor<R> visitor)
R
- the return value type of the visitorvisitor
- the visitorpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005-2013 Knipp Medien und Kommunikation GmbH