Project JXTA

net.jxta.endpoint
Class NewStringMessageElement

java.lang.Object
  |
  +--net.jxta.endpoint.NewMessageElement
        |
        +--net.jxta.endpoint.NewTextMessageElement
              |
              +--net.jxta.endpoint.NewStringMessageElement
All Implemented Interfaces:
java.lang.Cloneable, Document, TextDocument

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 NewStringMessageElement
extends NewTextMessageElement

A Message Element using character strings for the element data.


Field Summary
protected  java.lang.String data
          Deprecated. The data for this element.
 
Fields inherited from class net.jxta.endpoint.NewMessageElement
name, properties, sig, type
 
Constructor Summary
NewStringMessageElement(java.lang.String name, java.lang.String value, NewMessageElement sig)
          Deprecated. Create a new Message Element from the provided string.
NewStringMessageElement(java.lang.String name, java.lang.String value, java.lang.String encoding, NewMessageElement sig)
          Deprecated. Create a new Message Element from the provided string.
 
Method Summary
 boolean equals(java.lang.Object target)
          Deprecated. Compare this MessageElement against another
 long getByteLength()
          Deprecated. Returns the size of the element data.
 long getCharLength()
          Deprecated. Returns the size of the element data in characters
 java.io.Reader getReader()
          Deprecated. Returns a Reader containing the element data.
 java.io.InputStream getStream()
          Deprecated. Returns a stream containing the element data.
 int hashCode()
          Deprecated. Returns a hash code value for the object.
 void sendToStream(java.io.OutputStream sendTo)
          Deprecated. Sends the element data to the specified stream
 void sendToWriter(java.io.Writer sendTo)
          Deprecated. Sends the element character data to the specified writer
 java.lang.String toString()
          Deprecated. Constructs a new String from the data contained by the element.
 
Methods inherited from class net.jxta.endpoint.NewTextMessageElement
getFileExtension
 
Methods inherited from class net.jxta.endpoint.NewMessageElement
clone, getMessageProperty, getMimeType, getName, getSequentialName, getSignature, getUniqueName, setMessageProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.jxta.document.Document
getMimeType
 

Field Detail

data

protected java.lang.String data
Deprecated. 
The data for this element.
Constructor Detail

NewStringMessageElement

public NewStringMessageElement(java.lang.String name,
                               java.lang.String value,
                               NewMessageElement sig)
Deprecated. 
Create a new Message Element from the provided string. The string will be encoded using UTF-8 on the wire.
Parameters:
name - Name of the Element. May be the empty string ("") or null if the Element is not named.
value - A String containing the contents of this element.
sig - optional message digest/digital signature elemnent. If no signature is to be specified, pass null.
Throws:
java.lang.IllegalArgumentException - if is null.
Since:
JXTA 1.0

NewStringMessageElement

public NewStringMessageElement(java.lang.String name,
                               java.lang.String value,
                               java.lang.String encoding,
                               NewMessageElement sig)
                        throws java.io.UnsupportedEncodingException
Deprecated. 
Create a new Message Element from the provided string. The string will be encoded using the specified encoding on the wire.
Parameters:
name - Name of the Element. May be the empty string ("") or null if the Element is not named.
value - A String containing the contents of this element.
encoding - Name of the character encoding to use. If null then the system default encoding default will be used. (Using the default encoding should be used with caution).
sig - optional message digest/digital signature elemnent. If no signature is to be specified, pass null.
Throws:
java.lang.IllegalArgumentException - if value is null
java.io.UnsupportedEncodingException - if the specified encoding is not supported.
Since:
JXTA 1.0
Method Detail

equals

public boolean equals(java.lang.Object target)
Deprecated. 
Compare this MessageElement against another
Overrides:
equals in class NewMessageElement
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. 
Constructs a new String from the data contained by the element. The element is converted using the charset specified in its mime-type.
Overrides:
toString in class NewMessageElement
Returns:
string containing the value of this element as a string

getByteLength

public long getByteLength()
Deprecated. 
Returns the size of the element data.
Overrides:
getByteLength in class NewMessageElement
Returns:
long containing the size of the element data.
Since:
JXTA 1.0

getCharLength

public long getCharLength()
Deprecated. 
Returns the size of the element data in characters
Overrides:
getCharLength in class NewTextMessageElement
Returns:
long containing the size of the element data.
Since:
JXTA 1.0

getStream

public java.io.InputStream getStream()
                              throws java.io.IOException
Deprecated. 
Returns a stream containing the element data.

XXX 20020519 bondolo@jxta.org This implementation is really horrible, use getDataReader if you possibly can. The only alternative I see is to pass the data through a piped output stream using a print writer. To ensure that we don't deadlock, we would have to process chars from the string one at a time.

Overrides:
getStream in class NewMessageElement
Returns:
InputStream of the stream containing element data.
Throws:
java.io.IOException - when there is a problem getting an InputStream.
Since:
JXTA 1.0

getReader

public java.io.Reader getReader()
                         throws java.io.IOException
Deprecated. 
Returns a Reader containing the element data.
Overrides:
getReader in class NewTextMessageElement
Returns:
InputStream of the stream containing element data.
Throws:
java.io.IOException - when there is a problem getting a reader.
Since:
JXTA 1.0

sendToStream

public void sendToStream(java.io.OutputStream sendTo)
                  throws java.io.IOException
Deprecated. 
Sends the element data to the specified stream
Overrides:
sendToStream in class NewMessageElement
Parameters:
sendTo - the output stream to send the data to.
Throws:
java.io.IOException - when there is a problem sending to the specified stream
Since:
JXTA 1.0

sendToWriter

public void sendToWriter(java.io.Writer sendTo)
                  throws java.io.IOException
Deprecated. 
Sends the element character data to the specified writer
Overrides:
sendToWriter in class NewTextMessageElement
Parameters:
sendTo - the writer to send the data to.
Throws:
java.io.IOException - when there is a problem sending to the specified writer
Since:
JXTA 1.0

Project JXTA