|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.AbstractSimpleSelectable
net.jxta.endpoint.Message
public class Message
Messages are abstract containers for protocol messages within JXTA. Services
and applications are expected to use Messages as the basis for any protocols
implemented within JXTA. Messages are exchanged through the
EndpointService
or
PipeService
.
MessageElements
. Each
MessageElement
is associated with a namespace at
the time it is added to the message. Duplicate
MessageElements
are permitted.
Messages are not synchronized. All of the iterators returned by this
implementation are "fail-fast". Concurrent modification of messages from
multiple threads will produce unexpected results and
ConcurrentModificationException
.
MessageElement
,
EndpointAddress
,
EndpointService
,
InputPipe
,
OutputPipe
,
PipeService
,
Serialized FormNested Class Summary | |
---|---|
protected static class |
Message.element
Holds an element, its namespace and optionally an override signature element. |
class |
Message.ElementIterator
A ListIterator for MessageElements which also provides the ability to determine the namespace of the current message element. |
Nested classes/interfaces inherited from interface net.jxta.util.SimpleSelectable |
---|
SimpleSelectable.IdentityReference |
Field Summary | |
---|---|
protected long |
cachedByteLength
cached aggregate size of all the member elements. |
protected int |
cachedByteLengthModCount
modcount at the time the message length was last calculated. |
protected String |
defaultNamespace
This string identifies the namespace which is assumed when calls are made that don't include a namespace specification. |
protected List<Message.element> |
elements
List of the elements. |
protected static boolean |
GLOBAL_TRACKING_ELEMENT
If true , then a special tracking element is added to every
message. |
protected List<Integer> |
lineage
A list of Integer which details the lineage (history
of cloning) that produced this message. |
protected static boolean |
LOG_MODIFICATIONS
If true , then modification logging be activated. |
protected int |
modCount
Modification count of this message. |
protected List<Throwable> |
modHistory
If LOG_MODIFICATIONS is true then this will contain
the history of modifications this message. |
boolean |
modifiable
Deprecated. You really should not depend on this feature. |
protected Map<String,List<MessageElement>> |
namespaces
the namespaces in this message and the elements in each. |
protected Map<Object,Object> |
properties
Message properties HashMap |
Fields inherited from class net.jxta.util.AbstractSimpleSelectable |
---|
identityReference |
Constructor Summary | |
---|---|
|
Message()
Standard Constructor for messages. |
protected |
Message(String defaultNamespace)
Standard Constructor for messages. |
Method Summary | |
---|---|
void |
addMessageElement(MessageElement add)
Add a MessageElement into the message. |
void |
addMessageElement(String namespace,
MessageElement add)
Add a MessageElement into the message using the specified namespace. |
void |
addMessageElement(String namespace,
MessageElement add,
MessageElement signature)
Add a MessageElement into the Message using the specified namespace. |
void |
clear()
Removes all of the elements in all namespaces from the message. |
Message |
clone()
Duplicates the Message. |
boolean |
equals(Object target)
Compare this Message against another. |
long |
getByteLength()
Returns the aggregate size of all the member elements. |
protected String |
getDefaultNamespace()
Return the default Namespace of this message. |
MessageElement |
getMessageElement(String name)
Retrieve a message element by name from the message without regard to namespace. |
MessageElement |
getMessageElement(String namespace,
String name)
Retrieve a message element by name in the specified namespace from the message. |
Message.ElementIterator |
getMessageElements()
Returns a list iterator of all of the elements contained in this message. |
Message.ElementIterator |
getMessageElements(MimeMediaType type)
Returns a list iterator of all of the elements contained in this message whose mime-type matchs the given in the order they were added to the message. |
Message.ElementIterator |
getMessageElements(String name)
Returns a list iterator of all of the elements contained in this message who's name matches the specified name. |
Message.ElementIterator |
getMessageElements(String namespace,
MimeMediaType type)
Returns a list iterator of all of the elements contained in this message whose type matches the given in the order they were added to the message. |
Message.ElementIterator |
getMessageElements(String namespace,
String name)
Returns a list iterator of all of the elements contained in the specified namespace who's name matches the specified name in the order in which they were added to the Message. |
Message.ElementIterator |
getMessageElementsOfNamespace(String namespace)
Returns a list iterator of all of the elements contained in this message which match the specified namespace. |
Iterator<Integer> |
getMessageLineage()
Returns an iterator which describes the lineage of this message. |
int |
getMessageModCount()
Returns the modification count of this message. |
String |
getMessageModHistory()
Returns a String containing the modification history for this message |
Iterator<String> |
getMessageNamespaces()
Returns an iterator of the namespaces present in this message. |
int |
getMessageNumber()
Returns the message number of this message. |
Object |
getMessageProperty(Object key)
Retrieves a transient property from the set for this message. |
int |
hashCode()
|
protected int |
incMessageModCount()
Returns the modification count of this message. |
void |
itemChanged(SimpleSelectable o)
This method is invoked when the given selectable object has changed. |
boolean |
removeMessageElement(MessageElement remove)
Remove an the first occurrence of the provided MessageElement from the message. |
boolean |
removeMessageElement(String namespace,
MessageElement remove)
Remove the first occurrence of the provided MessageElement within the specified namespace from the message. |
MessageElement |
replaceMessageElement(MessageElement replacement)
Replace a MessageElement in the message. |
MessageElement |
replaceMessageElement(String namespace,
MessageElement replacement)
Replace a MessageElement in the message using the specified
namespace. |
Object |
setMessageProperty(Object key,
Object value)
Associate a transient property with this message. if there was a previous value for the key provided then it is returned. |
String |
toString()
This implementation is intended to assist debugging. |
Methods inherited from class net.jxta.util.AbstractSimpleSelectable |
---|
getIdentityReference, haveListeners, notifyChange, register, registerListener, unregister, unregisterListener |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final boolean LOG_MODIFICATIONS
true
, then modification logging be activated. This is a very
expensive option as it causes a stack crawl to be captured for every
message modification.
To enable modification tracking, set to true
and recompile.
protected static final boolean GLOBAL_TRACKING_ELEMENT
true
, then a special tracking element is added to every
message. This provides the ability to follow messages throughout the
network. If a message has a tracking element then it will be used in
the toString()
representation.
The element is currently named "Tracking UUID" and is stored in the
"jxta" namespace. The element contains an IETF version 1 UUID in string
form.
To enable addition of a tracking element to every message, set the
Java System Property net.jxta.endpoint.Message.globalTracking
to
true
and restart your JXTA application.
System.setProperty(String,String)
protected final String defaultNamespace
protected transient Map<String,List<MessageElement>> namespaces
protected transient List<Message.element> elements
protected transient Map<Object,Object> properties
protected transient List<Integer> lineage
Integer
which details the lineage (history
of cloning) that produced this message. This message's number is index
0, all of the ancestors are in order at higher indexes.
Message numbers are not part of the message content and are only
stored locally. The are useful for following messages throughout their
lifetime and is normally shown as part of the toString()
display for Messages.
protected transient volatile int modCount
toString()
display for
Messages.
protected transient long cachedByteLength
getByteLength()
protected transient int cachedByteLengthModCount
getByteLength()
@Deprecated public boolean modifiable
protected transient List<Throwable> modHistory
LOG_MODIFICATIONS
is true
then this will contain
the history of modifications this message.
Throwable
with the description
field formatted as timeInAbsoluteMillis : threadName
.
Constructor Detail |
---|
public Message()
protected Message(String defaultNamespace)
defaultNamespace
- the namespace which is assumed by methods which
do not require a namespace specification.Method Detail |
---|
public Message clone()
clone
in class Object
public boolean equals(Object target)
true
if all of the
elements are identical and in the same order. Message properties
(setProperty()/getProperty()) are not considered in the calculation.
equals
in class Object
target
- The Message to compare against.
true
if the elements are identical otherwise
false
.public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
protected String getDefaultNamespace()
public void addMessageElement(MessageElement add)
add
- the Element to add to the message.public void addMessageElement(String namespace, MessageElement add)
namespace
- contains the namespace of the element to add. You can
specify null as a shorthand for the default namespace.add
- the MessageElement to add to the message.public void addMessageElement(String namespace, MessageElement add, MessageElement signature)
namespace
- contains the namespace of the element to add. You can
specify null as a shorthand for the default namespace.add
- the MessageElement to add to the message.signature
- The signature MessageElement associated with the
MessageElement. This allows for an alternate signature element to the
signature element associated with the message element.public MessageElement replaceMessageElement(MessageElement replacement)
MessageElement
in the message. This
method will remove all MessageElement instances in the default namespace
which match the specified name (if any) and then insert the replacement
element. The existing version of the element is returned, if more than
one matching element was removed, a random matching element is returned.
For greatest control over element replacement, use the
ListIterator.set(java.lang.Object)
method as returned
by getMessageElements()
,
getMessageElements(java.lang.String)
or
getMessageElementsOfNamespace(java.lang.String)
replacement
- the Element to be inserted into to the message.
public MessageElement replaceMessageElement(String namespace, MessageElement replacement)
MessageElement
in the message using the specified
namespace. This method will remove all MessageElement instances which
match the specified name (if any) and then insert the replacement
element. The existing version of the element is returned, if more than
one matching element was removed, a random matching element is returned.
For greatest control over element replacement, use the
ListIterator.set(java.lang.Object)
method as returned
by getMessageElements()
,
getMessageElements(java.lang.String)
or
getMessageElementsOfNamespace(java.lang.String)
namespace
- contains the namespace of the element to be replaced.
You can specify null as a shorthand for the default namespace.replacement
- the Element to be inserted into to the message.
public Iterator<String> getMessageNamespaces()
public MessageElement getMessageElement(String name)
name
- The name of the message element to attempt to retrieve.
public MessageElement getMessageElement(String namespace, String name)
namespace
- contains the namespace of the element to get. You can
specify null
as a shorthand for the default namespace.name
- The name of the message element to retrieve.
null
if no matching message
element could be found.public Message.ElementIterator getMessageElements()
ConcurrentModificationException
if the
message is modified.
public Message.ElementIterator getMessageElements(String name)
ConcurrentModificationException
if the
message is modified.
name
- the name of the elements to match against
public Message.ElementIterator getMessageElementsOfNamespace(String namespace)
next()
or
previous()
is called.
namespace
- contains the namespace which must be matched in the
elements returned. You can specify null
as a shorthand for the
default namespace.
public Message.ElementIterator getMessageElements(String namespace, String name)
ConcurrentModificationException
if the message
is modified.
namespace
- The namespace which must be matched in the elements
returned. You can specify null
as a shorthand for the default
namespace.name
- The name of the elements to retrieve.
public Message.ElementIterator getMessageElements(MimeMediaType type)
ConcurrentModificationException
if the
message is modified.
type
- contains the type of the elements to get
public Message.ElementIterator getMessageElements(String namespace, MimeMediaType type)
ConcurrentModificationException
if the
message is modified.
namespace
- contains the namespace which must be matched in the
elements returned. You can specify null as a shorthand for the default
namespace.type
- contains the type of the elements to get
public boolean removeMessageElement(MessageElement remove)
remove
- the Element to remove from the message.
public boolean removeMessageElement(String namespace, MessageElement remove)
namespace
- the namespace from which the element is to be removed.remove
- the Element to remove from the message.
public void clear()
public long getByteLength()
public int getMessageModCount()
protected int incMessageModCount()
public String getMessageModHistory()
public int getMessageNumber()
public Iterator<Integer> getMessageLineage()
Integer
Message Number. The first entry is
this message's number, following entries are the ancestors of this
message.
Integer
. Each entry is a
message number.public Object setMessageProperty(Object key, Object value)
key
- the property keyvalue
- the value for the property
public Object getMessageProperty(Object key)
key
- the property key.
public void itemChanged(SimpleSelectable o)
SimpleSelector
will report the change to
SimpleSelector.select()
and invoke
AbstractSimpleSelectable.notifyChange()
thereby reporting its own
change to cascaded selectors. Other implementations may only invoke
AbstractSimpleSelectable.notifyChange()
or may perform more
complex tasks.
itemChanged
in interface SimpleSelectable
o
- the object that has changed.AbstractSimpleSelectable
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |