|
Project 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 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 from multiple threads will produce unexpected results.
MessageElement
,
EndpointAddress
,
EndpointService
,
InputPipe
,
OutputPipe
,
PipeService
,
Serialized FormNested Class Summary | |
---|---|
protected static class |
Message.element
holds an element and its namespace |
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 memeber 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 |
elements
List of the elements. |
protected static boolean |
GLOBAL_TRACKING_ELEMENT
If true, then a tracking element is added to the message. |
protected List |
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 |
modHistory
The history of modifications this message. |
boolean |
modifiable
Deprecated. You really should not depend on this feature. |
protected Map |
namespaces
the namespaces in this message and the elements in each. |
protected Map |
properties
Message properties HashMap keys are Object
values are Object
|
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 |
clear()
Removes all of the elements in all namespaces from the message. |
Object |
clone()
Duplicates the Message. |
boolean |
equals(Object target)
Compare this Message against another. |
long |
getByteLength()
Returns the aggregate size of all the memeber elements. |
protected String |
getDefaultNamespace()
Return the default Namespace of this message. |
MessageElement |
getMessageElement(String name)
Retrieve a element by name from the message without regard to namespace. |
MessageElement |
getMessageElement(String namespace,
String name)
Retrieve a 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 an list iterator of all of the elements contained in this message which match the specified namespace. |
Iterator |
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 |
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. |
protected static int |
getNextMessageNumber()
Returns the next message number in sequence. |
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 occurance of the provided MessageElement from the message. |
boolean |
removeMessageElement(String namespace,
MessageElement remove)
Remove the first occurance 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()
Displays the lineage of the message including its own message number. |
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
and
recompile.
protected static final boolean GLOBAL_TRACKING_ELEMENT
true
and recompile.
protected final String defaultNamespace
protected transient Map namespaces
String
List
MessageElement
protected transient List elements
Message.element
protected transient Map properties
protected transient List 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.
protected transient volatile int modCount
protected transient long cachedByteLength
getByteLength()
protected transient int cachedByteLengthModCount
getByteLength()
public boolean modifiable
protected transient List modHistory
Throwable
with the description field
formatted as timeInAbsoluteMillis : threadName
.
Constructor Detail |
---|
public Message()
protected Message(String defaultNamespace)
defaultNamespace
- the namespace which is assumed when calls are
made that don't include a namespace specification.Method Detail |
---|
protected static int getNextMessageNumber()
public Object clone()
clone
in class Object
public boolean equals(Object target)
equals
in class Object
target
- The to compare against.
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 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 getMessageNamespaces()
public MessageElement getMessageElement(String name)
name
- The name of the element to attept 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
- contains the name of the element to get
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.
The iterator returned is not synchronized with the message and will
throw 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.
public Message.ElementIterator getMessageElements(String namespace, String name)
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.name
- contains the name of the elements to get
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 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
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |