Project JXTA

net.jxta.endpoint
Class NewMessage

java.lang.Object
  |
  +--net.jxta.endpoint.NewMessage
All Implemented Interfaces:
java.lang.Cloneable

Deprecated. Though new to this release, this class will be disappearing in the next stable release. Do not write code which imports this class!

public class NewMessage
extends java.lang.Object
implements java.lang.Cloneable

Messages are sent and received by peer endpoints and pipes. Applications are expected to use this class in order to exchange messages.

This class is synchronized. Using NewMesage from multiple threads may still create unpredicted behaviour. use getModCount() to verify the object has not changed.

Since:
JXTA 1.0
Version:
$Revision: 1.4 $
See Also:
EndpointAddress, InputPipe, OutputPipe, PipeService

Inner Class Summary
static class NewMessage.ElementIterator
          Deprecated. A List Iterator which also provides the ability to determine the namespace of the current element.
 
Constructor Summary
NewMessage()
          Deprecated. Standard Constructor for messages.
NewMessage(java.lang.String defaultNamespace)
          Deprecated. Standard Constructor for messages.
 
Method Summary
 void addElement(NewMessageElement add)
          Deprecated. Add a MessageElement into the message.
 void addElement(java.lang.String namespace, NewMessageElement add)
          Deprecated. Add a MessageElement into the message using the specified namespace.
 void clear()
          Deprecated. Removes all of the elements in all namespaces from the message.
 java.lang.Object clone()
          Deprecated. Duplicates the Message.
 boolean equals(java.lang.Object target)
          Deprecated. Compare this Message against another.
 long getByteLength()
          Deprecated. Returns the aggregate size of all the memeber elements.
 java.lang.String getDefaultNamespace()
          Deprecated. Return the default Namespace of this message.
 NewMessageElement getElement(java.lang.String name)
          Deprecated. Retrieve a element by name from the message without regard to namespace.
 NewMessageElement getElement(java.lang.String namespace, java.lang.String name)
          Deprecated. Retrieve a element by name in the specified namespace from the message.
 NewMessage.ElementIterator getElements()
          Deprecated. Returns a list iterator of all of the elements contained in this message.
 NewMessage.ElementIterator getElements(MimeMediaType type)
          Deprecated. 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.
 NewMessage.ElementIterator getElements(java.lang.String name)
          Deprecated. Returns a list iterator of all of the elements contained in this message who's name matches the specified name.
 java.util.ListIterator getElements(java.lang.String namespace, MimeMediaType type)
          Deprecated. Returns a list iterator of all of the elements contained in this message whose name's match the given in the order they were added.
 java.util.ListIterator getElements(java.lang.String namespace, java.lang.String name)
          Deprecated. Returns a list iterator of all of the elements contained in the specified namespace who's name matches the specified name.
 java.util.Iterator getMessageLineage()
          Deprecated. Returns the lineage of this message, the first item is this message's number.
 int getMessageNumber()
          Deprecated. Returns the number of this message
 java.lang.Object getMessageProperty(java.lang.Object key)
          Deprecated. retrieves a transient property from the set for this message.
 int getModCount()
          Deprecated. Returns the modification count of this message.
 java.util.ListIterator getNamespaceElements(java.lang.String namespace)
          Deprecated. Returns an list iterator of all of the elements contained in this message which match the specified namespace.
 java.util.Iterator getNamespaces()
          Deprecated. Returns an iterator of the namespaces present in this message.
 int hashCode()
          Deprecated. Returns a hash code value for the object.
 boolean removeElement(NewMessageElement remove)
          Deprecated. Remove an the first occurance of an element from the message.
 NewMessageElement replaceElement(NewMessageElement replacement)
          Deprecated. Replace a NewMessageElement in the message using the specified namespace.
 NewMessageElement replaceElement(java.lang.String namespace, NewMessageElement replacement)
          Deprecated. Replace a NewMessageElement in the message using the specified namespace.
 java.lang.Object setMessageProperty(java.lang.Object key, java.lang.Object value)
          Deprecated. Associate a transient property with this message.
 java.lang.String toString()
          Deprecated. {@inheritDoc} Displays the lineage of the message including its own message number.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NewMessage

public NewMessage()
Deprecated. 
Standard Constructor for messages. The default namespace will be the empty string ("")

NewMessage

public NewMessage(java.lang.String defaultNamespace)
Deprecated. 
Standard Constructor for messages.
Parameters:
defaultNamespace - the namespace which is assumed when calls are made that don't include a namespace specification.
Method Detail

clone

public java.lang.Object clone()
Deprecated. 
Duplicates the Message. The returned duplicate is a real copy. It may be freely modified without causing change to the originally cloned message.
Overrides:
clone in class java.lang.Object
Returns:
Message a Message that is a copy of the original message
Since:
JXTA 1.0

equals

public boolean equals(java.lang.Object target)
Deprecated. 
Compare this Message against another. Returns true if all of the elements are identical and in the same order. Message properties (setProperty/getProperty) are not considered in the calculation.
Overrides:
equals in class java.lang.Object
Parameters:
target - The to compare against.
Returns:
boolean true if the elements are identical.
Since:
JXTA 1.0

hashCode

public int hashCode()
Deprecated. 
Returns a hash code value for the object. This method is supported for the benefit of hashtables.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toString

public java.lang.String toString()
Deprecated. 
{@inheritDoc} Displays the lineage of the message including its own message number.
Overrides:
toString in class java.lang.Object

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Deprecated. 
Return the default Namespace of this message.
Returns:
The default namespace for this message.

addElement

public void addElement(NewMessageElement add)
Deprecated. 
Add a MessageElement into the message. The Element is stored in the default namespace.
Parameters:
add - the Element to add to the message.
Since:
JXTA 1.0

addElement

public void addElement(java.lang.String namespace,
                       NewMessageElement add)
Deprecated. 
Add a MessageElement into the message using the specified namespace.
Parameters:
namespace - contains the namespace of the element to add. You can specify null as a shorthand for the default namespace.
add - the Element to add to the message.
Since:
JXTA 1.0

replaceElement

public NewMessageElement replaceElement(NewMessageElement replacement)
Deprecated. 
Replace a NewMessageElement in the message using the specified namespace. This method will remove all NewMessageElement 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.
Parameters:
replacement - the Element to be inserted into to the message.
Returns:
One of the elements which was replaced or null if no existing matching item was located.
Since:
JXTA 1.0

replaceElement

public NewMessageElement replaceElement(java.lang.String namespace,
                                        NewMessageElement replacement)
Deprecated. 
Replace a NewMessageElement in the message using the specified namespace. This method will remove all NewMessageElement 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.
Parameters:
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.
Returns:
One of the elements which was replaced or null if no existing matching item was located.
Since:
JXTA 1.0

getNamespaces

public java.util.Iterator getNamespaces()
Deprecated. 
Returns an iterator of the namespaces present in this message. all of the elements will be Strings.
Returns:
iterator of strings of the namespaces of this message.

getElement

public NewMessageElement getElement(java.lang.String name)
Deprecated. 
Retrieve a element by name from the message without regard to namespace. If there is more than one element with this name, a random element will be returned.
Parameters:
name - The name of the element to attept to retrieve.
Returns:
Element the element or null if no matching element could be found.
Since:
JXTA 1.0

getElement

public NewMessageElement getElement(java.lang.String namespace,
                                    java.lang.String name)
Deprecated. 
Retrieve a element by name in the specified namespace from the message. If there is more than one element with this name, a random element will be returned.
Parameters:
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
Returns:
Element the element.
Since:
JXTA 1.0

getElements

public NewMessage.ElementIterator getElements()
Deprecated. 
Returns a list iterator of all of the elements contained in this message. Elements from all namespaces are returned.

The iterator returned is not synchronized with the message. If you modify the state of the Message, the enumeration will not reflect your changes. Nor will the message be modified by any changes you make in the iterator.

Returns:
Enumeration of Elements.
Since:
JXTA 1.0

getElements

public NewMessage.ElementIterator getElements(java.lang.String name)
Deprecated. 
Returns a list iterator of all of the elements contained in this message who's name matches the specified name. Elements from all namespaces are returned.

The iterator returned is not synchronized with the message. If you modify the state of the Message, the list iterator will not reflect your changes. Nor will the message be modified by any changes you make in the iterator.

Parameters:
name - the name of the elements to match against
Returns:
iterator of the elements matching the specified name, if any.
Since:
JXTA 1.0

getNamespaceElements

public java.util.ListIterator getNamespaceElements(java.lang.String namespace)
Deprecated. 
Returns an list iterator of all of the elements contained in this message which match the specified namespace. The Enumeration returned is not synchronized with the message. If you modify the state of the Message, the enumeration will not reflect your changes. Nor will the message be modified by any changes you make in the iterator.
Parameters:
namespace - contains the namespace which must be matched in the elements returned. You can specify null as a shorthand for the default namespace.
Returns:
Enumeration of Elements.
Since:
JXTA 1.0

getElements

public java.util.ListIterator getElements(java.lang.String namespace,
                                          java.lang.String name)
Deprecated. 
Returns a list iterator of all of the elements contained in the specified namespace who's name matches the specified name. The iterator returned is not synchronized with the message. If you modify the state of the Message, the list iterator will not reflect your changes. Nor will the message be modified by any changes you make in the iterator.
Parameters:
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
Returns:
Enumeration of Elements.
Since:
JXTA 1.0

getElements

public NewMessage.ElementIterator getElements(MimeMediaType type)
Deprecated. 
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. Elements from all namespaces are returned. The Iterator returned is not synchronized with the message. If you modify the state of the Message, the iterator will not reflect your changes. Nor will the message be modified by any changes you make in the iterator.
Parameters:
type - contains the type of the elements to get
Returns:
Enumeration of Elements.
Since:
JXTA 1.0

getElements

public java.util.ListIterator getElements(java.lang.String namespace,
                                          MimeMediaType type)
Deprecated. 
Returns a list iterator of all of the elements contained in this message whose name's match the given in the order they were added. The iterator returned is not synchronized with the message. If you modify the state of the Message, the enumeration will not reflect your changes. Nor will the message be modified by any changes you make in the iterator.
Parameters:
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
Returns:
Enumeration of Elements.
Since:
JXTA 1.0

removeElement

public boolean removeElement(NewMessageElement remove)
Deprecated. 
Remove an the first occurance of an element from the message.
Parameters:
remove - the Element to remove from the message.
Returns:
boolean returns true if the element was removed, otherwise false.
Since:
JXTA 1.0

clear

public void clear()
Deprecated. 
Removes all of the elements in all namespaces from the message.

getByteLength

public long getByteLength()
Deprecated. 
Returns the aggregate size of all the memeber elements.
Returns:
the sum of all element sizes in bytes.

getModCount

public int getModCount()
Deprecated. 
Returns the modification count of this message. This ever ascending number can be used to determine if the message has been modified by another thread or for use in caching of parts of the message structure.
Returns:
the modification count of this message.

getMessageNumber

public int getMessageNumber()
Deprecated. 
Returns the number of this message

getMessageLineage

public java.util.Iterator getMessageLineage()
Deprecated. 
Returns the lineage of this message, the first item is this message's number.

setMessageProperty

public java.lang.Object setMessageProperty(java.lang.Object key,
                                           java.lang.Object value)
Deprecated. 
Associate a transient property with this message. if there was a previous value for the key provided then it is returned. This feature is useful for managing the state of messages during processing.

The setting of particular keys may be controlled by a Java Security Manager. Keys of type 'java.lang.Class' are checked against the caller of this method. Only callers which are instances of the key class may modify the property. This check is not possible through reflection. All other types of keys are unchecked.

Parameters:
key - the property key
value - the value for the property
Returns:
previous value for the property or null if no previous

getMessageProperty

public java.lang.Object getMessageProperty(java.lang.Object key)
Deprecated. 
retrieves a transient property from the set for this message.
Parameters:
key - the property key.
Returns:
value for the property or null if no property for this key.

Project JXTA