Project JXTA

net.jxta.endpoint
Class NewMessageElement

java.lang.Object
  |
  +--net.jxta.endpoint.NewMessageElement
All Implemented Interfaces:
java.lang.Cloneable, Document
Direct Known Subclasses:
NewByteArrayMessageElement, NewInputStreamMessageElement, NewTextMessageElement

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 abstract class NewMessageElement
extends java.lang.Object
implements java.lang.Cloneable, Document

A Message is composed of MessageElements. An MessageElement has an optional name, an optional type (which defaults to "Application/Octet-stream"), a body and an optional digest/digital signature.


Field Summary
protected  java.lang.String name
          Deprecated. The name of this element.
protected  java.util.HashMap properties
          Deprecated. message properties hashmap
protected  NewMessageElement sig
          Deprecated. The optional element which digitially signs or digests this element.
protected  MimeMediaType type
          Deprecated. The type of this element.
 
Constructor Summary
protected NewMessageElement(java.lang.String name, MimeMediaType type, NewMessageElement sig)
          Deprecated. Internal constructor for initializaing everything but the data.
 
Method Summary
 java.lang.Object clone()
          Deprecated. make a clone of this element.
 boolean equals(java.lang.Object target)
          Deprecated. Compare this MessageElement against another
abstract  long getByteLength()
          Deprecated. Returns the size of the element data in bytes.
 java.lang.String getFileExtension()
          Deprecated. Return the file extension to use for this document.
 java.lang.Object getMessageProperty(java.lang.Object key)
          Deprecated. retrieves a transient property from the set for this message.
 MimeMediaType getMimeType()
          Deprecated. Returns the type of the MessageElement.
 java.lang.String getName()
          Deprecated. Returns the name of the MessageElement.
static java.lang.String getSequentialName()
          Deprecated. Returns a string containing a pseudo-random unique string and an integer value.
 NewMessageElement getSignature()
          Deprecated. Returns the element containing the digest/digital signature for this element
abstract  java.io.InputStream getStream()
          Deprecated. Returns a byte stream containing the element data.
static java.lang.String getUniqueName()
          Deprecated. Returns a pseudo-random unique string which can be used as an element name
 void sendToStream(java.io.OutputStream sendTo)
          Deprecated. Sends the element data to the specified byte stream
 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. Returns the string representation of this element.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Deprecated. 
The name of this element. May be the empty string ("") if the element is unnamed.

type

protected MimeMediaType type
Deprecated. 
The type of this element.

sig

protected NewMessageElement sig
Deprecated. 
The optional element which digitially signs or digests this element. If null then the element is has no signature element. If sig == this then this element is a signature element.

properties

protected java.util.HashMap properties
Deprecated. 
message properties hashmap
Constructor Detail

NewMessageElement

protected NewMessageElement(java.lang.String name,
                            MimeMediaType type,
                            NewMessageElement sig)
Deprecated. 
Internal constructor for initializaing everything but the data.
Parameters:
name - Name of the Element. May be the empty string ("") if the Element is not named.
type - Type of the Element. null is equivalent to specifying the type "Application/Octet-stream"
sig - optional message digest/digital signature elemnent. If no signature is to be specified, pass null.
Since:
JXTA 1.0
Method Detail

getUniqueName

public static java.lang.String getUniqueName()
Deprecated. 
Returns a pseudo-random unique string which can be used as an element name
Returns:
String containing a pseudo-random value

getSequentialName

public static java.lang.String getSequentialName()
Deprecated. 
Returns a string containing a pseudo-random unique string and an integer value. The result of String.compare() will be consistent with the order in which results were returned from this function.

The value for the sequential portion will be incremented for each call to getSequentialName() and a new pseudo-random value will be chosen every time you restart the JavaVM.

Security Consideration : Be aware that the pseudo random portion of the names generated by this string are shared amongst all peer groups running in the same Java VM. You may be at a risk for loss of annonimity if you use the element names produced in more than one peer group.

Returns:
String containing a pseudo-random value and a sequence number. The result of String.compare() will be consistent with the order in which results were returned from this function.

clone

public final java.lang.Object clone()
Deprecated. 
make a clone of this element. Since elements are immutable, this returns the same object.
Overrides:
clone in class java.lang.Object
Returns:
Element the same elemement
Since:
JXTA 1.0

equals

public boolean equals(java.lang.Object target)
Deprecated. 
Compare this MessageElement against another
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

toString

public java.lang.String toString()
Deprecated. 
Returns the string representation of this element. The 'charset' parameter of the mimetype, if any, is used to determine encoding. If the charset specified is unsupported then the default enconding will be used.
Overrides:
toString in class java.lang.Object
Returns:
String string representation of this message element.

getName

public java.lang.String getName()
Deprecated. 
Returns the name of the MessageElement. Unnamed elements will return the empty string ("");
Returns:
String containing the name of the MessageElement.
Since:
JXTA 1.0

getMimeType

public MimeMediaType getMimeType()
Deprecated. 
Returns the type of the MessageElement.
Specified by:
getMimeType in interface Document
Returns:
MimeMediaType containing a copy of the type of the element. Will return "Application/Octet-Stream" if no type was originally specified.
Since:
JXTA 1.0

getFileExtension

public java.lang.String getFileExtension()
Deprecated. 
Return the file extension to use for this document. We use the "unknown" extension and leave it to sub-classes to extend this. if we had a mailcap facility we could do better classification based on mimetype.
Specified by:
getFileExtension in interface Document
Following copied from interface: net.jxta.document.Document
Returns:
a string containing an appropriate file extension

getByteLength

public abstract long getByteLength()
Deprecated. 
Returns the size of the element data in bytes.
Returns:
long containing the size of the element data.
Since:
JXTA 1.0

getStream

public abstract java.io.InputStream getStream()
                                       throws java.io.IOException
Deprecated. 
Returns a byte stream containing the element data.
Specified by:
getStream in interface Document
Returns:
InputStream of the stream containing element data.
Throws:
java.io.IOException - if there is a problem getting the stream
Since:
JXTA 1.0

sendToStream

public void sendToStream(java.io.OutputStream sendTo)
                  throws java.io.IOException
Deprecated. 
Sends the element data to the specified byte stream
Specified by:
sendToStream in interface Document
Parameters:
sendTo - the output stream to send the data to.
Throws:
java.io.IOException - if there is a problem sending the data to the specified stream
Since:
JXTA 1.0

getSignature

public NewMessageElement getSignature()
Deprecated. 
Returns the element containing the digest/digital signature for this element
Returns:
Element containing the digital signature.
Since:
JXTA 1.0

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