Class AVideo
- java.lang.Object
-
- org.zkoss.video.AVideo
-
public class AVideo extends java.lang.Object implements Video, java.io.Serializable
Represents a video.it is used to retrieve and store the opaque data as polymorphic thru the
Mediainterface.AVideo is serializable, but, if you are using InputStream, you have to extend this class, and provide the implementation to serialize and deserialize
_isdata.- Since:
- 8.6.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.InputStream_isdataThe raw data in stream (orDYNAMIC_STREAM).protected static java.io.InputStreamDYNAMIC_STREAMUsed if you want to implement a media whose input stream is created dynamically each timegetStreamData()is called.
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getByteData()Returns the raw data in byte array.java.lang.StringgetContentType()Returns the content type, e.g., "image/jpeg", or null if not available.java.lang.StringgetFormat()Returns the format name, e.g., "jpeg", or null if not available.java.lang.StringgetName()Returns the name (usually filename) of this media, or null if not available.java.io.ReadergetReaderData()Not supported.java.io.InputStreamgetStreamData()Returns the data in the input stream.java.lang.StringgetStringData()Always throws IllegalStateException.booleaninMemory()Returns whether the data is cached in memory (in form of byte[] or String).booleanisBinary()Returns whether the format of this content is binary or text-based.booleanisContentDisposition()Whether to allow Content-Disposition or not when writing the media to response header.
-
-
-
Field Detail
-
DYNAMIC_STREAM
protected static final java.io.InputStream DYNAMIC_STREAM
Used if you want to implement a media whose input stream is created dynamically each timegetStreamData()is called.- See Also:
AVideo(String, InputStream)
-
_isdata
protected final transient java.io.InputStream _isdata
-
-
Constructor Detail
-
AVideo
public AVideo(java.lang.String name, byte[] data) throws java.io.IOException- Throws:
java.io.IOException
-
AVideo
public AVideo(java.lang.String name, java.io.InputStream isdata) throws java.io.IOExceptionCreates an instance of a video with an input stream. If the stream shall be created each timegetStreamData()is called, you can passDYNAMIC_STREAMto the data argument, and then overridegetStreamData().Note: the caller of
getStreamData()has to close the returned input stream.- Throws:
java.io.IOException
-
AVideo
public AVideo(java.net.URL url)
Constructs a video with an URL.
-
AVideo
public AVideo(java.io.File file)
Constructs a video with a file.
-
AVideo
public AVideo(java.lang.String filename) throws java.io.IOExceptionConstructs a video with a file name.- Throws:
java.io.IOException
-
AVideo
public AVideo(java.io.InputStream is) throws java.io.IOExceptionCreates an instance of a video with an input stream. If the stream shall be created each timegetStreamData()is called, you can passDYNAMIC_STREAMto the data argument, and then overridegetStreamData().Note: the caller of
getStreamData()has to close the returned input stream.- Throws:
java.io.IOException
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:MediaReturns the name (usually filename) of this media, or null if not available.
-
getContentType
public java.lang.String getContentType()
Description copied from interface:MediaReturns the content type, e.g., "image/jpeg", or null if not available.- Specified by:
getContentTypein interfaceMedia- See Also:
Media.getFormat()
-
getStreamData
public java.io.InputStream getStreamData()
Returns the data in the input stream.Note: the caller has to invoke
InputStream.close()after using the input stream returned bygetStreamData().- Specified by:
getStreamDatain interfaceMedia- See Also:
Media.getReaderData()
-
getStringData
public final java.lang.String getStringData()
Always throws IllegalStateException.- Specified by:
getStringDatain interfaceMedia- See Also:
Media.getByteData()
-
getReaderData
public final java.io.Reader getReaderData()
Not supported. It always throws IllegalStateException.- Specified by:
getReaderDatain interfaceMedia- See Also:
Media.getStreamData()
-
getFormat
public java.lang.String getFormat()
Description copied from interface:MediaReturns the format name, e.g., "jpeg", or null if not available.- Specified by:
getFormatin interfaceMedia- See Also:
Media.getContentType()
-
isContentDisposition
public boolean isContentDisposition()
Description copied from interface:MediaWhether to allow Content-Disposition or not when writing the media to response header.Default: true
- Specified by:
isContentDispositionin interfaceMedia
-
isBinary
public boolean isBinary()
Description copied from interface:MediaReturns whether the format of this content is binary or text-based. If true, useMedia.getByteData()orMedia.getStreamData()to retrieve its content. If false, useMedia.getStringData()orMedia.getReaderData()to retrieve its content.- Specified by:
isBinaryin interfaceMedia- See Also:
Media.getStringData(),Media.getByteData(),Media.getReaderData(),Media.getStreamData()
-
inMemory
public final boolean inMemory()
Description copied from interface:MediaReturns whether the data is cached in memory (in form of byte[] or String).- Specified by:
inMemoryin interfaceMedia- See Also:
Media.getStringData(),Media.getByteData(),Media.getReaderData(),Media.getStreamData()
-
getByteData
public byte[] getByteData()
Description copied from interface:MediaReturns the raw data in byte array.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 fromMedia.getStreamData(). Furthermore, it also implies you can not invoke this method again.- Specified by:
getByteDatain interfaceMedia- See Also:
Media.getStringData()
-
-