public interface Media
By implementing this interface, objects can be processed generically by servlets and many other codes.
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()
Returns the raw data in Reader.
|
java.io.InputStream |
getStreamData()
Returns the raw data in InputStream.
|
java.lang.String |
getStringData()
Returns the raw data in string.
|
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.
|
boolean isBinary()
getByteData()
or getStreamData()
to retrieve its content.
If false, use getStringData()
or getReaderData()
to retrieve its content.getStringData()
,
getByteData()
,
getReaderData()
,
getStreamData()
boolean inMemory()
getStringData()
,
getByteData()
,
getReaderData()
,
getStreamData()
byte[] getByteData()
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 (inMemory()
return false),
the data will be read from getStreamData()
. Furthermore, it
also implies you can not invoke this method again.
java.lang.IllegalStateException
- if isBinary()
returns falsegetStringData()
java.lang.String getStringData()
If the data is not cached in memory (inMemory()
return false),
the data will be read from getReaderData()
. Furthermore, it
also implies you can not invoke this method again.
java.lang.IllegalStateException
- if isBinary()
returns falsegetByteData()
java.io.InputStream getStreamData()
Note: it wraps getByteData()
with ByteArrayInputStream
if it is in memory (inMemory()
returns true).
java.lang.IllegalStateException
- if isBinary()
returns false.getReaderData()
java.io.Reader getReaderData()
Note: it wraps getStringData()
with StringReader,
if it is in memory (inMemory()
returns true).
java.lang.IllegalStateException
- if isBinary()
returns true.getStreamData()
java.lang.String getName()
java.lang.String getFormat()
getContentType()
java.lang.String getContentType()
getFormat()
boolean isContentDisposition()
Default: true
Copyright © 2005-2018 Potix Corporation. All Rights Reserved.