Class AVideo
- All Implemented Interfaces:
Serializable,Media,Video
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.
- Since:
- 8.6.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InputStreamThe raw data in stream (orDYNAMIC_STREAM).protected static final InputStreamUsed if you want to implement a media whose input stream is created dynamically each timegetStreamData()is called. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a video with a file.AVideo(InputStream is) Creates an instance of a video with an input stream.Constructs a video with a file name.AVideo(String name, InputStream isdata) Creates an instance of a video with an input stream.Constructs a video with an URL. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the raw data in byte array.Returns the content type, e.g., "image/jpeg", or null if not available.Returns the format name, e.g., "jpeg", or null if not available.getName()Returns the name (usually filename) of this media, or null if not available.final ReaderNot supported.Returns the data in the input stream.final StringAlways throws IllegalStateException.final 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.booleanWhether to allow Content-Disposition or not when writing the media to response header.
-
Field Details
-
DYNAMIC_STREAM
Used if you want to implement a media whose input stream is created dynamically each timegetStreamData()is called.- See Also:
-
_isdata
-
-
Constructor Details
-
AVideo
- Throws:
IOException
-
AVideo
Creates 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:
IOException
-
AVideo
Constructs a video with an URL. -
AVideo
Constructs a video with a file. -
AVideo
Constructs a video with a file name.- Throws:
IOException
-
AVideo
Creates 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:
IOException
-
-
Method Details
-
getName
Description copied from interface:MediaReturns the name (usually filename) of this media, or null if not available. -
getContentType
Description copied from interface:MediaReturns the content type, e.g., "image/jpeg", or null if not available.- Specified by:
getContentTypein interfaceMedia- See Also:
-
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:
-
getStringData
Always throws IllegalStateException.- Specified by:
getStringDatain interfaceMedia- See Also:
-
getReaderData
Not supported. It always throws IllegalStateException.- Specified by:
getReaderDatain interfaceMedia- See Also:
-
getFormat
Description copied from interface:MediaReturns the format name, e.g., "jpeg", or null if not available. -
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. -
inMemory
public final boolean inMemory()Description copied from interface:MediaReturns whether the data is cached in memory (in form of byte[] or String). -
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:
-