ImageReaderWriterSpipublic abstract class ImageReaderWriterSpi extends IIOServiceProvider A superclass containing instance variables and methods common to
ImageReaderSpi and ImageWriterSpi . |
Fields Summary |
---|
protected String[] | namesAn array of strings to be returned from
getFormatNames , initially null .
Constructors should set this to a non-null value. | protected String[] | suffixesAn array of strings to be returned from
getFileSuffixes , initially null . | protected String[] | MIMETypesAn array of strings to be returned from
getMIMETypes , initially null . | protected String | pluginClassNameA String containing the name of the associated
plug-in class, initially null . | protected boolean | supportsStandardStreamMetadataFormatA boolean indicating whether this plug-in supports the
standard metadata format for stream metadata, initially
false . | protected String | nativeStreamMetadataFormatNameA String containing the name of the native stream
metadata format supported by this plug-in, initially
null . | protected String | nativeStreamMetadataFormatClassNameA String containing the class name of the native
stream metadata format supported by this plug-in, initially
null . | protected String[] | extraStreamMetadataFormatNamesAn array of String s containing the names of any
additional stream metadata formats supported by this plug-in,
initially null . | protected String[] | extraStreamMetadataFormatClassNamesAn array of String s containing the class names of
any additional stream metadata formats supported by this plug-in,
initially null . | protected boolean | supportsStandardImageMetadataFormatA boolean indicating whether this plug-in supports the
standard metadata format for image metadata, initially
false . | protected String | nativeImageMetadataFormatNameA String containing the name of the
native stream metadata format supported by this plug-in,
initially null . | protected String | nativeImageMetadataFormatClassNameA String containing the class name of the
native stream metadata format supported by this plug-in,
initially null . | protected String[] | extraImageMetadataFormatNamesAn array of String s containing the names of any
additional image metadata formats supported by this plug-in,
initially null . | protected String[] | extraImageMetadataFormatClassNamesAn array of String s containing the class names of
any additional image metadata formats supported by this
plug-in, initially null . |
Constructors Summary |
---|
public ImageReaderWriterSpi(String vendorName, String version, String[] names, String[] suffixes, String[] MIMETypes, String pluginClassName, boolean supportsStandardStreamMetadataFormat, String nativeStreamMetadataFormatName, String nativeStreamMetadataFormatClassName, String[] extraStreamMetadataFormatNames, String[] extraStreamMetadataFormatClassNames, boolean supportsStandardImageMetadataFormat, String nativeImageMetadataFormatName, String nativeImageMetadataFormatClassName, String[] extraImageMetadataFormatNames, String[] extraImageMetadataFormatClassNames)Constructs an ImageReaderWriterSpi with a given
set of values.
super(vendorName, version);
if (names == null) {
throw new IllegalArgumentException("names == null!");
}
if (names.length == 0) {
throw new IllegalArgumentException("names.length == 0!");
}
if (pluginClassName == null) {
throw new IllegalArgumentException("pluginClassName == null!");
}
this.names = (String[])names.clone();
// If length == 0, leave it null
if (suffixes != null && suffixes.length > 0) {
this.suffixes = (String[])suffixes.clone();
}
// If length == 0, leave it null
if (MIMETypes != null && MIMETypes.length > 0) {
this.MIMETypes = (String[])MIMETypes.clone();
}
this.pluginClassName = pluginClassName;
this.supportsStandardStreamMetadataFormat =
supportsStandardStreamMetadataFormat;
this.nativeStreamMetadataFormatName = nativeStreamMetadataFormatName;
this.nativeStreamMetadataFormatClassName =
nativeStreamMetadataFormatClassName;
// If length == 0, leave it null
if (extraStreamMetadataFormatNames != null &&
extraStreamMetadataFormatNames.length > 0) {
this.extraStreamMetadataFormatNames =
(String[])extraStreamMetadataFormatNames.clone();
}
// If length == 0, leave it null
if (extraStreamMetadataFormatClassNames != null &&
extraStreamMetadataFormatClassNames.length > 0) {
this.extraStreamMetadataFormatClassNames =
(String[])extraStreamMetadataFormatClassNames.clone();
}
this.supportsStandardImageMetadataFormat =
supportsStandardImageMetadataFormat;
this.nativeImageMetadataFormatName = nativeImageMetadataFormatName;
this.nativeImageMetadataFormatClassName =
nativeImageMetadataFormatClassName;
// If length == 0, leave it null
if (extraImageMetadataFormatNames != null &&
extraImageMetadataFormatNames.length > 0) {
this.extraImageMetadataFormatNames =
(String[])extraImageMetadataFormatNames.clone();
}
// If length == 0, leave it null
if (extraImageMetadataFormatClassNames != null &&
extraImageMetadataFormatClassNames.length > 0) {
this.extraImageMetadataFormatClassNames =
(String[])extraImageMetadataFormatClassNames.clone();
}
| public ImageReaderWriterSpi()Constructs a blank ImageReaderWriterSpi . It is up
to the subclass to initialize instance variables and/or
override method implementations in order to provide working
versions of all methods.
|
Methods Summary |
---|
public java.lang.String[] | getExtraImageMetadataFormatNames()Returns an array of String s containing the names
of additional document formats, other than the native and
standard formats, recognized by the
getAsTree and setFromTree methods on
the image metadata objects produced or consumed by this
plug-in.
If the plug-in does not handle image metadata, null should
be returned.
The set of formats may differ according to the particular
images being read or written; this method should indicate all
the additional formats supported by the plug-in under any circumstances.
The default implementation returns a clone of the
extraImageMetadataFormatNames instance variable,
which is typically set by the constructor.
return extraImageMetadataFormatNames == null ?
null : (String[])extraImageMetadataFormatNames.clone();
| public java.lang.String[] | getExtraStreamMetadataFormatNames()Returns an array of String s containing the names
of additional document formats, other than the native and
standard formats, recognized by the
getAsTree and setFromTree methods on
the stream metadata objects produced or consumed by this
plug-in.
If the plug-in does not handle metadata, null should be
returned.
The set of formats may differ according to the particular
images being read or written; this method should indicate all
the additional formats supported by the plug-in under any
circumstances.
The default implementation returns a clone of the
extraStreamMetadataFormatNames instance variable,
which is typically set by the constructor.
return extraStreamMetadataFormatNames == null ?
null : (String[])extraStreamMetadataFormatNames.clone();
| public java.lang.String[] | getFileSuffixes()Returns an array of String s containing a list of
file suffixes associated with the formats that are generally
usable by the ImageReader or
ImageWriter implementation associated with this
service provider. For example, a single
ImageReader might be able to process files with
'.pbm' and '.pnm' suffixes, or both '.jpg' and '.jpeg'
suffixes. If there are no known file suffixes,
null will be returned.
Returning a particular suffix does not guarantee that files
with that suffix can be processed; it merely indicates that it
may be worthwhile attempting to decode or encode such files
using this service provider.
return suffixes == null ? null : (String[])suffixes.clone();
| public java.lang.String[] | getFormatNames()Returns an array of String s containing
human-readable names for the formats that are generally usable
by the ImageReader or ImageWriter
implementation associated with this service provider. For
example, a single ImageReader might be able to
process both PBM and PNM files.
return (String[])names.clone();
| public javax.imageio.metadata.IIOMetadataFormat | getImageMetadataFormat(java.lang.String formatName)Returns an IIOMetadataFormat object describing the
given image metadata format, or null if no
description is available. The supplied name must be the native
iamge metadata format name, the standard metadata format name,
or one of those returned by
getExtraImageMetadataFormatNames .
return getMetadataFormat(formatName,
supportsStandardImageMetadataFormat,
nativeImageMetadataFormatName,
nativeImageMetadataFormatClassName,
extraImageMetadataFormatNames,
extraImageMetadataFormatClassNames);
| public java.lang.String[] | getMIMETypes()Returns an array of String s containing a list of
MIME types associated with the formats that are generally
usable by the ImageReader or
ImageWriter implementation associated with this
service provider.
Ideally, only a single MIME type would be required in order
to describe a particular format. However, for several reasons
it is necessary to associate a list of types with each service
provider. First, many common image file formats do not have
standard MIME types, so a list of commonly used unofficial
names will be required, such as image/x-pbm and
image/x-portable-bitmap . Some file formats have
official MIME types but may sometimes be referred to using
their previous unofficial designations, such as
image/x-png instead of the official
image/png . Finally, a single service provider may
be capable of parsing multiple distinct types from the MIME
point of view, for example image/x-xbitmap and
image/x-xpixmap .
Returning a particular MIME type does not guarantee that
files claiming to be of that type can be processed; it merely
indicates that it may be worthwhile attempting to decode or
encode such files using this service provider.
return MIMETypes == null ? null : (String[])MIMETypes.clone();
| private javax.imageio.metadata.IIOMetadataFormat | getMetadataFormat(java.lang.String formatName, boolean supportsStandard, java.lang.String nativeName, java.lang.String nativeClassName, java.lang.String[] extraNames, java.lang.String[] extraClassNames)
if (formatName == null) {
throw new IllegalArgumentException("formatName == null!");
}
if (supportsStandard && formatName.equals
(IIOMetadataFormatImpl.standardMetadataFormatName)) {
return IIOMetadataFormatImpl.getStandardFormatInstance();
}
String formatClassName = null;
if (formatName.equals(nativeName)) {
formatClassName = nativeClassName;
} else if (extraNames != null) {
for (int i = 0; i < extraNames.length; i++) {
if (formatName.equals(extraNames[i])) {
formatClassName = extraClassNames[i];
break; // out of for
}
}
}
if (formatClassName == null) {
throw new IllegalArgumentException("Unsupported format name");
}
try {
Class cls = Class.forName(formatClassName, true,
ClassLoader.getSystemClassLoader());
Method meth = cls.getMethod("getInstance", null);
return (IIOMetadataFormat) meth.invoke(null, null);
} catch (Exception e) {
RuntimeException ex =
new IllegalStateException ("Can't obtain format");
ex.initCause(e);
throw ex;
}
| public java.lang.String | getNativeImageMetadataFormatName()Returns the name of the "native" image metadata format for
this plug-in, which typically allows for lossless encoding and
transmission of the image metadata stored in the format handled by
this plug-in. If no such format is supported,
null will be returned.
The default implementation returns the
nativeImageMetadataFormatName instance variable,
which is typically set by the constructor.
return nativeImageMetadataFormatName;
| public java.lang.String | getNativeStreamMetadataFormatName()Returns the name of the "native" stream metadata format for
this plug-in, which typically allows for lossless encoding and
transmission of the stream metadata stored in the format handled by
this plug-in. If no such format is supported,
null will be returned.
The default implementation returns the
nativeStreamMetadataFormatName instance variable,
which is typically set by the constructor.
return nativeStreamMetadataFormatName;
| public java.lang.String | getPluginClassName()Returns the fully-qualified class name of the
ImageReader or ImageWriter plug-in
associated with this service provider.
return pluginClassName;
| public javax.imageio.metadata.IIOMetadataFormat | getStreamMetadataFormat(java.lang.String formatName)Returns an IIOMetadataFormat object describing the
given stream metadata format, or null if no
description is available. The supplied name must be the native
stream metadata format name, the standard metadata format name,
or one of those returned by
getExtraStreamMetadataFormatNames .
return getMetadataFormat(formatName,
supportsStandardStreamMetadataFormat,
nativeStreamMetadataFormatName,
nativeStreamMetadataFormatClassName,
extraStreamMetadataFormatNames,
extraStreamMetadataFormatClassNames);
| public boolean | isStandardImageMetadataFormatSupported()Returns true if the standard metadata format is
among the document formats recognized by the
getAsTree and setFromTree methods on
the image metadata objects produced or consumed by this
plug-in.
return supportsStandardImageMetadataFormat;
| public boolean | isStandardStreamMetadataFormatSupported()Returns true if the standard metadata format is
among the document formats recognized by the
getAsTree and setFromTree methods on
the stream metadata objects produced or consumed by this
plug-in.
return supportsStandardStreamMetadataFormat;
|
|