|
||||||||||
PREV CLASS (src) NEXT CLASS (src) | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.emb.MediaBean
This class implements the Media interface and models media objects that are transient, immutable, and local. In order to avoid excessive memory use, a temporary file may be used to store and access the media content while an instance is alive.
Field Summary |
Fields inherited from interface javax.emb.Media (src) |
MIME_TYPE_UNKNOWN |
Constructor Summary | |
MediaBean(java.io.File mediaFile,
java.lang.String mimeType)
This constructor wraps a new instance around the given media file. |
|
MediaBean(java.io.InputStream contentStream,
java.lang.String mimeType,
java.lang.String name)
This constructor initializes a new instance with content copied from the given content stream, and the given mime type and name. |
Method Summary | |
byte[] |
getContent()
Returns the complete media content as a byte array. |
MediaFormat (src) |
getFormat()
Queries a suitable media format instance from the MediaFormatRegistry singleton and returns it. |
MediaHeader (src) |
getHeader()
Returns the receiver's header information. |
java.lang.String |
getMimeType()
Returns a mime type for the receiver's content as a string. |
java.lang.String |
getName()
Returns the receiver's non-unique name as a String. |
Media (src) |
getProxy()
Returns a media object that can be used as a proxy for the receiver, e.g. |
long |
getSize()
This operation returns the receiver's content size in number of bytes as a long value. |
int |
readContent(long position,
byte[] buffer)
Similarly to input streams, this method fills the given buffer with content read from the media object. |
int |
readContent(long position,
byte[] buffer,
int offset,
int length)
Similar to input streams, this method fills the given buffer with content read from the media object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MediaBean(java.io.InputStream contentStream, java.lang.String mimeType, java.lang.String name) throws MediaException (src)
null
, one is chosen automatically by
analyzing the given file extension, or Media.MIME_TYPE_UNKNOWN
is assigned in case none can be derived.
This constructor is suitable for media content regardless of its size. Please note that the given input stream is closed once the content is read completely. Also note that a temporary file is used internally to maintain the content. The implementation tries to delete this file once the instance is garbage collected, and again once the process dies in case the former attempt fails.
contentStream
- media content stream.mimeType
- media mime type.name
- media name.
ContentAccessException (src)
- if something goes wrong during
content transfer.
java.lang.NullPointerException
- if the given content stream or
name is null
.
MediaException (src)
public MediaBean(java.io.File mediaFile, java.lang.String mimeType) throws MediaException (src)
Media.MIME_TYPE_UNKNOWN
is assigned in case none can be derived.
This constructor is useful to invoke a media related service on an
existing media file without copying the content of the latter. Please
note that the file is not deleted once an instance referencing it is
garbage collected.
mediaFile
- a file.mimeType
- the optional MIME type of the content.
ContentAccessException (src)
- if something goes wrong during
content transfer, or if the given file is not present or cannot
be accessed.
java.lang.NullPointerException
- if the given media file is null.
MediaException (src)
Method Detail |
public byte[] getContent() throws MediaException (src)
Media (src)
getContent
in interface Media (src)
MediaException (src)
Media.getContent()
public MediaFormat (src) getFormat() throws MediaException (src)
Media (src)
getFormat
in interface Media (src)
MediaException (src)
Media.getFormat()
public MediaHeader (src) getHeader() throws MediaException (src)
Media (src)
getHeader
in interface Media (src)
MediaException (src)
Media.getHeader()
public java.lang.String getMimeType() throws MediaException (src)
Media (src)
getMimeType
in interface Media (src)
MediaException (src)
Media.getMimeType()
public java.lang.String getName() throws MediaException (src)
Media (src)
getName
in interface Media (src)
MediaException (src)
Media.getName()
public Media (src) getProxy() throws MediaException (src)
Media (src)
getProxy
in interface Media (src)
MediaException (src)
Media.getProxy()
public long getSize() throws MediaException (src)
Media (src)
getSize
in interface Media (src)
MediaException (src)
Media.getSize()
public int readContent(long position, byte[] buffer) throws MediaException (src)
Media (src)
readContent
in interface Media (src)
position
- the position in media to copy from.buffer
- the byte array to store content.
MediaException (src)
Media.readContent(long, byte[])
public int readContent(long position, byte[] buffer, int offset, int length) throws MediaException (src)
Media (src)
readContent
in interface Media (src)
position
- the position in media to copy from.buffer
- the byte array to store content.offset
- the offset in the buffer to begin storing content.length
- the number of bytes to copy from the content.
MediaException (src)
Media.readContent(long, byte[], int, int)
|
||||||||||
PREV CLASS (src) NEXT CLASS (src) | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |