|
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
public abstract class TextMessageElement
An extension of MessageElement for managing elements that are composed of character text. (as opposed to raw bytes).
The data contained within aTextMessageElement
is accessible in three
additional ways to those provided by MessageElement
:
Reader
from TextDocumentReaderIO.getReader()
Writer
via sendToWriter(Writer)
getChars(boolean)
Field Summary | |
---|---|
protected long |
cachedGetCharLength
cached result of getCharLength() operation. |
protected SoftReference<char[]> |
cachedGetChars
cached result of MessageElement.getBytes(boolean) operation. |
Fields inherited from class net.jxta.endpoint.MessageElement |
---|
cachedGetByteLength, cachedGetBytes, cachedToString, name, sig, type |
Constructor Summary | |
---|---|
protected |
TextMessageElement(String name,
MimeMediaType type,
MessageElement sig)
Internal constructor for initializaing everything but the data. |
Method Summary | |
---|---|
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 . |
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.MessageElement |
---|
clone, copyInputStreamToOutputStream, equals, getByteLength, getBytes, getElementName, getElementProperty, getMimeType, getSequentialName, getSignature, getUniqueName, hashCode, sendToStream, setElementProperty |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.jxta.document.Document |
---|
getMimeType |
Methods inherited from interface net.jxta.document.DocumentStreamIO |
---|
getStream, sendToStream |
Methods inherited from interface net.jxta.document.TextDocumentReaderIO |
---|
getReader |
Field Detail |
---|
protected transient long cachedGetCharLength
getCharLength()
operation.
protected transient SoftReference<char[]> cachedGetChars
MessageElement.getBytes(boolean)
operation.
Constructor Detail |
---|
protected TextMessageElement(String name, MimeMediaType type, MessageElement sig)
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.Method Detail |
---|
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 MessageElement
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 MessageElement
Document
.public long getCharLength()
public char[] getChars(boolean copy)
copy
- return a copy if true
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
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 |