public class AImage extends Object implements Image, Serializable
In other words, it is used to retrieve and store the opaque data
as polymorphic thru the Media interface.
To encode AWT image to an instance of Image,
use Images.encode(java.lang.String, java.awt.image.RenderedImage, float, boolean).
Images.encode(java.lang.String, java.awt.image.RenderedImage, float, boolean),
Serialized Form| Constructor and Description |
|---|
AImage(File file)
Constructs an image with a file.
|
AImage(String filename)
Constructs an image with a file name.
|
AImage(String name,
byte[] data)
Constructs an image with a byte array.
|
AImage(String name,
InputStream is)
Constructs an image with an input stream.
|
AImage(URL url)
Constructs an image with an URL.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getByteData()
Returns the raw data in byte array.
|
String |
getContentType()
Returns the content type, e.g., "image/jpeg", or null if not available.
|
String |
getFormat()
Returns the format name, e.g., "jpeg", or null if not available.
|
int |
getHeight()
Returns the height.
|
String |
getName()
Returns the name (usually filename) of this media, or null
if not available.
|
Reader |
getReaderData()
Always throws IllegalStateException.
|
InputStream |
getStreamData()
An input stream on top of
getByteData(). |
String |
getStringData()
Always throws IllegalStateException.
|
int |
getWidth()
Returns the width.
|
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.
|
ImageIcon |
toImageIcon()
Converts to an image icon.
|
public AImage(String name, byte[] data) throws IOException
IOExceptionpublic AImage(String name, InputStream is) throws IOException
Note that this method automatically closes the input stream (since ZK 3.0.0).
IOExceptionpublic AImage(String filename) throws IOException
IOExceptionpublic AImage(File file) throws IOException
IOExceptionpublic AImage(URL url) throws IOException
IOExceptionpublic final boolean isBinary()
MediaMedia.getByteData() or Media.getStreamData()
to retrieve its content.
If false, use Media.getStringData() or Media.getReaderData()
to retrieve its content.isBinary in interface MediaMedia.getStringData(),
Media.getByteData(),
Media.getReaderData(),
Media.getStreamData()public final boolean inMemory()
MediainMemory in interface MediaMedia.getStringData(),
Media.getByteData(),
Media.getReaderData(),
Media.getStreamData()public byte[] getByteData()
MediaIt 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 MediaMedia.getStringData()public final String getStringData()
getStringData in interface MediaMedia.getByteData()public final InputStream getStreamData()
getByteData().
Though harmless, the caller doesn't need to close the returned stream.
getStreamData in interface MediaMedia.getReaderData()public final Reader getReaderData()
getReaderData in interface MediaMedia.getStreamData()public final String getName()
Mediapublic final String getFormat()
MediagetFormat in interface MediaMedia.getContentType()public final String getContentType()
MediagetContentType in interface MediaMedia.getFormat()public final int getHeight()
public final ImageIcon toImageIcon()
toImageIcon in interface Imagepublic boolean isContentDisposition()
MediaDefault: true
isContentDisposition in interface MediaCopyright © 2018. All rights reserved.