public class AVideo extends java.lang.Object implements Video, java.io.Serializable
it is used to retrieve and store the opaque data
as polymorphic thru the Media
interface.
AVideo is serializable, but, if you are using InputStream,
you have to extend this class, and provide the implementation to
serialize and deserialize _isdata
.
Modifier and Type | Field and Description |
---|---|
protected java.io.InputStream |
_isdata
The raw data in stream (or
DYNAMIC_STREAM ). |
protected static java.io.InputStream |
DYNAMIC_STREAM
Used if you want to implement a media whose input stream is created
dynamically each time
getStreamData() is called. |
Constructor and Description |
---|
AVideo(java.io.File file)
Constructs a video with a file.
|
AVideo(java.io.InputStream is)
Creates an instance of a video with an input stream.
|
AVideo(java.lang.String filename)
Constructs a video with a file name.
|
AVideo(java.lang.String name,
byte[] data) |
AVideo(java.lang.String name,
java.io.InputStream isdata)
Creates an instance of a video with an input stream.
|
AVideo(java.net.URL url)
Constructs a video with an URL.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getByteData()
Returns the raw data in byte array.
|
java.lang.String |
getContentType()
Returns the content type, e.g., "image/jpeg", or null if not available.
|
java.lang.String |
getFormat()
Returns the format name, e.g., "jpeg", or null if not available.
|
java.lang.String |
getName()
Returns the name (usually filename) of this media, or null
if not available.
|
java.io.Reader |
getReaderData()
Not supported.
|
java.io.InputStream |
getStreamData()
Returns the data in the input stream.
|
java.lang.String |
getStringData()
Always throws IllegalStateException.
|
boolean |
inMemory()
Returns whether the data is cached in memory (in form of
byte[] or String).
|
boolean |
isBinary()
Returns whether the format of this content is binary or text-based.
|
boolean |
isContentDisposition()
Whether to allow Content-Disposition or not when writing the media to response header.
|
protected static final java.io.InputStream DYNAMIC_STREAM
getStreamData()
is called.AVideo(String, InputStream)
protected final transient java.io.InputStream _isdata
public AVideo(java.lang.String name, byte[] data) throws java.io.IOException
java.io.IOException
public AVideo(java.lang.String name, java.io.InputStream isdata) throws java.io.IOException
getStreamData()
is called,
you can pass DYNAMIC_STREAM
to the data argument, and then
override getStreamData()
.
Note: the caller of getStreamData()
has to close
the returned input stream.
java.io.IOException
public AVideo(java.net.URL url)
public AVideo(java.io.File file)
public AVideo(java.lang.String filename) throws java.io.IOException
java.io.IOException
public AVideo(java.io.InputStream is) throws java.io.IOException
getStreamData()
is called,
you can pass DYNAMIC_STREAM
to the data argument, and then
override getStreamData()
.
Note: the caller of getStreamData()
has to close
the returned input stream.
java.io.IOException
public java.lang.String getName()
Media
public java.lang.String getContentType()
Media
getContentType
in interface Media
Media.getFormat()
public java.io.InputStream getStreamData()
Note: the caller has to invoke InputStream.close()
after using the input stream returned by getStreamData()
.
getStreamData
in interface Media
Media.getReaderData()
public final java.lang.String getStringData()
getStringData
in interface Media
Media.getByteData()
public final java.io.Reader getReaderData()
getReaderData
in interface Media
Media.getStreamData()
public java.lang.String getFormat()
Media
getFormat
in interface Media
Media.getContentType()
public boolean isContentDisposition()
Media
Default: true
isContentDisposition
in interface Media
public boolean isBinary()
Media
Media.getByteData()
or Media.getStreamData()
to retrieve its content.
If false, use Media.getStringData()
or Media.getReaderData()
to retrieve its content.isBinary
in interface Media
Media.getStringData()
,
Media.getByteData()
,
Media.getReaderData()
,
Media.getStreamData()
public final boolean inMemory()
Media
inMemory
in interface Media
Media.getStringData()
,
Media.getByteData()
,
Media.getReaderData()
,
Media.getStreamData()
public byte[] getByteData()
Media
It might not be a copy, so don't modify it directly unless you know what you are doing.
If the data is not cached in memory (Media.inMemory()
return false),
the data will be read from Media.getStreamData()
. Furthermore, it
also implies you can not invoke this method again.
getByteData
in interface Media
Media.getStringData()
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.