|
Project 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.TextDocumentMessageElement
public class TextDocumentMessageElement
A Message Element using JXTA TextDocument for the element data.
Field Summary | |
---|---|
protected TextDocument |
doc
The data for this element. |
Fields inherited from class net.jxta.endpoint.TextMessageElement |
---|
cachedGetCharLength, cachedGetChars |
Fields inherited from class net.jxta.endpoint.MessageElement |
---|
cachedGetByteLength, cachedGetBytes, cachedToString, name, properties, sig, type |
Constructor Summary | |
---|---|
TextDocumentMessageElement(String name,
TextDocument doc,
MessageElement sig)
Create a new Message Element from the provided Document. |
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. |
String |
getFileExtension()
Returns the file extension type used by this Document . This
value is usually chosen based upon the MIME Media Type.
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.
We use the "text" extension and leave it to sub-classes to extend
this. |
MimeMediaType |
getMimeType()
Returns the MIME Media type of this Document per
IETF RFC 2046 MIME : Media Types.
JXTA does not currently support the 'Multipart ' or
'Message ' media types.
Will return "Application/Octet-Stream" if no type was originally
specified. |
Reader |
getReader()
Returns the sequence of characters which represents the content of this 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.
This version probably has sub-optimal performance. |
void |
sendToWriter(Writer sendTo)
Send the contents of this TextDocument to the specified
Writer.
This version probably has sub-optimal performance. |
String |
toString()
Returns a String representation of the element data. The 'charset' parameter of the message element's mimetype, if
any, is used to determine encoding. If the charset specified is
unsupported then the default enconding will be used.
synchronized for caching purposes.
synchronized for caching purposes. |
Methods inherited from class net.jxta.endpoint.MessageElement |
---|
clone, copyInputStreamToOutputStream, getByteLength, getElementName, getElementProperty, getSequentialName, getSignature, getUniqueName, setElementProperty |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected TextDocument doc
Constructor Detail |
---|
public TextDocumentMessageElement(String name, TextDocument doc, MessageElement sig)
name
- Name of the Element. May be the empty string ("") or null if
the Element is not named.doc
- A Document containing the contents of this element.sig
- optional message digest/digital signature elemnent. If
no signature is to be specified, pass null.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 enconding will be used.
synchronized for caching purposes.
synchronized for caching purposes.
toString
in interface TextDocument
toString
in class TextMessageElement
public MimeMediaType getMimeType()
Document
per
IETF RFC 2046 MIME : Media Types.
JXTA does not currently support the 'Multipart
' or
'Message
' media types.
Will return "Application/Octet-Stream" if no type was originally
specified.
getMimeType
in interface Document
getMimeType
in class MessageElement
Document
.public String getFileExtension()
Document
. This
value is usually chosen based upon the MIME Media Type.
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.
We use the "text" extension and leave it to sub-classes to extend
this.
getFileExtension
in interface Document
getFileExtension
in class TextMessageElement
Document
.public InputStream getStream() throws IOException
Document
.
InputStream
containing the bytes
of this Document
.
IOException
- if an I/O error occurs.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 Document
sendToStream
in class MessageElement
sendTo
- The OutputStream to which the Document
will
be written.
IOException
- if an I/O error occurs.public Reader getReader() throws IOException
TextDocument
.
getReader
in interface TextDocument
getReader
in class TextMessageElement
Reader
containing the characters of this
TextDocument
.
IOException
- if an I/O error occurs.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 TextDocument
sendToWriter
in class TextMessageElement
sendTo
- The OutputStream to which the Document
will be written.
IOException
- if an I/O error occurs.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
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |