|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.endpoint.MessageElement
net.jxta.endpoint.TextMessageElement
net.jxta.endpoint.StringMessageElement
public class StringMessageElement
A Message Element using character strings for the element data.
Field Summary | |
---|---|
protected String |
data
The data for this Message Element. |
Fields inherited from class net.jxta.endpoint.TextMessageElement |
---|
cachedGetCharLength, cachedGetChars |
Fields inherited from class net.jxta.endpoint.MessageElement |
---|
cachedGetByteLength, cachedGetBytes, cachedToString, name, sig, type |
Constructor Summary | |
---|---|
StringMessageElement(String name,
String value,
MessageElement sig)
Create a new Message Element from the provided String. |
|
StringMessageElement(String name,
String value,
String encoding,
MessageElement sig)
Create a new Message Element from the provided String. |
Method Summary | |
---|---|
boolean |
equals(Object target)
Elements are considered equal if they have the same name, type and signatures. |
byte[] |
getBytes(boolean copy)
Returns a byte array which contains the element data. |
long |
getCharLength()
Returns the size of the element data in characters synchronized for caching purposes. |
char[] |
getChars(boolean copy)
Returns a char array which contains the element data. |
Reader |
getReader()
Returns the sequence of characters which represents the content of the TextDocument . |
InputStream |
getStream()
Returns the stream of bytes which represents the content of this Document . |
int |
hashCode()
|
void |
sendToStream(OutputStream sendTo)
Send the contents of this Document to the specified stream. |
void |
sendToWriter(Writer sendTo)
Send the contents of this TextDocument to the specified
Writer. |
String |
toString()
Returns a String representation of the element data. |
Methods inherited from class net.jxta.endpoint.TextMessageElement |
---|
getFileExtension |
Methods inherited from class net.jxta.endpoint.MessageElement |
---|
clone, copyInputStreamToOutputStream, getByteLength, getElementName, getElementProperty, getMimeType, getSequentialName, getSignature, getUniqueName, setElementProperty |
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 |
---|
protected String data
Constructor Detail |
---|
public StringMessageElement(String name, String value, MessageElement sig)
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
- Message digest/digital signature element. If no signature is
to be specified, pass null
.
IllegalArgumentException
- if value
is
null
.public StringMessageElement(String name, String value, String encoding, MessageElement sig) throws UnsupportedEncodingException
name
- Name of the MessageElement. May be the empty string ("") or
null
if the MessageElement 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 character encoding will be
used. (Using the system default character encoding should be used with
extreme caution).sig
- Message digest/digital signature element. If no signature is
to be specified, pass null
.
IllegalArgumentException
- if value
is
null
.
UnsupportedEncodingException
- if the requested encoding is not
supported.Method Detail |
---|
public boolean equals(Object target)
equals
in class MessageElement
public int hashCode()
hashCode
in class MessageElement
public String toString()
'charset'
parameter of the message element's mimetype, if
any, is used to determine encoding. If the charset specified is
unsupported then the default encoding will be used.
synchronized for caching purposes.
synchronized for caching purposes.
toString
in class TextMessageElement
public byte[] getBytes(boolean copy)
copy
parameter allows you to request a
private, modifiable copy of the element data.
This implementation builds the byte array from the stream.
getBytes
in class MessageElement
copy
- If true then the result can be modified without damaging the state of this
MessageElement. If false, then the result may be a shared copy of the data and
should be considered read-only.
public long getCharLength()
getCharLength
in class TextMessageElement
public char[] getChars(boolean copy)
getChars
in class TextMessageElement
copy
- return a copy if true
public InputStream getStream() throws IOException
Document
.
InputStream
containing the bytes
of this Document
.
IOException
- For errors while writing the Document
.public Reader getReader() throws IOException
TextDocument
.
IOException
- when there is a problem getting a reader.public void sendToStream(OutputStream sendTo) throws IOException
Document
to the specified stream.
This version probably has sub-optimal performance. Sub-classes
should override this implementation.
sendToStream
in interface DocumentStreamIO
sendToStream
in class MessageElement
sendTo
- The OutputStream to which the Document
will
be written.
IOException
- For errors while writing the Document
.public void sendToWriter(Writer sendTo) throws IOException
TextDocument
to the specified
Writer.
This version probably has sub-optimal performance. Sub-classes
should override this implementation if possible.
sendToWriter
in interface TextDocumentReaderIO
sendToWriter
in class TextMessageElement
sendTo
- The Writer
to which the characters of the
TextDocument
will be written.
IOException
- If an I/O error occurs.
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |