|
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.InputStreamMessageElement
public class InputStreamMessageElement
A Message Element using InputStream
as the source for the
element data. This implementation copies all of the data from the stream at
the time of creation.
Field Summary | |
---|---|
protected int |
cachedHashCode
Cached Hash Code |
protected List |
databytes
The bytes of this element. |
protected long |
length
The length of the data. |
Fields inherited from class net.jxta.endpoint.MessageElement |
---|
cachedGetByteLength, cachedGetBytes, cachedToString, name, properties, sig, type |
Constructor Summary | |
---|---|
InputStreamMessageElement(String name,
MimeMediaType type,
InputStream in,
long len,
MessageElement sig)
Create a new Message Element. |
|
InputStreamMessageElement(String name,
MimeMediaType type,
InputStream in,
MessageElement sig)
Create a new MessageElement. |
Method Summary | |
---|---|
protected List |
CopyToDataBytes(InputStream in,
long limit)
Copy data from a stream with best possible effciency. |
boolean |
equals(Object target)
Elements are considered equal if they have the same name, type and signatures. |
long |
getByteLength()
Returns the size of the element data in bytes. |
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. |
Methods inherited from class net.jxta.endpoint.MessageElement |
---|
clone, copyInputStreamToOutputStream, getBytes, getElementName, getElementProperty, getFileExtension, getMimeType, getSequentialName, getSignature, getUniqueName, setElementProperty, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected List databytes
protected long length
protected transient int cachedHashCode
Constructor Detail |
---|
public InputStreamMessageElement(String name, MimeMediaType type, InputStream in, MessageElement sig) throws IOException
name
- Name of the MessageElement. May be the empty string ("") if
the MessageElement is not named.type
- Type of the MessageElement. null is the same as specifying
the type "Application/Octet-stream".in
- the stream containing the body of the MessageElement. The
stream will be closed by the MessageElement.sig
- optional message digest/digital signature elemnent or null if
no signature is desired.
IOException
- If there is a problem reading from the source stream.public InputStreamMessageElement(String name, MimeMediaType type, InputStream in, long len, MessageElement sig) throws IOException
name
- Name of the MessageElement. May be the empty string ("") if
the MessageElement is not named.type
- Type of the MessageElement. null is the same as specifying
the type "Application/Octet-stream".in
- the stream containing the body of the MessageElement.
The stream will NOT be closed unless EOF is unexpectedly reached.len
- The size of the Element will be limited to len bytes
from the stream. If you are using the stream interface and know
the size of the stream, specifying it here improves performance
and space effciency a lot. The stream must contain at least
len
bytes.sig
- optional message digest/digital signature elemnent or null if
no signature is desired.
IOException
- if there is a problem reading from the source streamMethod Detail |
---|
public boolean equals(Object target)
equals
in class MessageElement
public int hashCode()
hashCode
in class MessageElement
public long getByteLength()
getByteLength
in class MessageElement
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.protected List CopyToDataBytes(InputStream in, long limit) throws IOException
in
- the stream to copy fromlimit
- the maximum number of bytes to copy from the stream.
Long.LONG_MAX will read until EOF.
IOException
- if there is a problem reading from the stream.
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |