jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 23313 jdk/src/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java@f100f0d49e0b
child 35667 ed476aba94de
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
     2
 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.imageio.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.imageio.ImageReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.imageio.metadata.IIOMetadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.imageio.metadata.IIOMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.imageio.metadata.IIOMetadataFormatImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.imageio.stream.ImageInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * A superclass containing instance variables and methods common to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <code>ImageReaderSpi</code> and <code>ImageWriterSpi</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see IIORegistry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see ImageReaderSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see ImageWriterSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public abstract class ImageReaderWriterSpi extends IIOServiceProvider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * An array of strings to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * <code>getFormatNames</code>, initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Constructors should set this to a non-<code>null</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected String[] names = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * An array of strings to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * <code>getFileSuffixes</code>, initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected String[] suffixes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * An array of strings to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * <code>getMIMETypes</code>, initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    protected String[] MIMETypes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * A <code>String</code> containing the name of the associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * plug-in class, initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    protected String pluginClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * A boolean indicating whether this plug-in supports the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * standard metadata format for stream metadata, initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    protected boolean supportsStandardStreamMetadataFormat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * A <code>String</code> containing the name of the native stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * metadata format supported by this plug-in, initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    protected String nativeStreamMetadataFormatName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * A <code>String</code> containing the class name of the native
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * stream metadata format supported by this plug-in, initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    protected String nativeStreamMetadataFormatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * An array of <code>String</code>s containing the names of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * additional stream metadata formats supported by this plug-in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    protected String[] extraStreamMetadataFormatNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * An array of <code>String</code>s containing the class names of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * any additional stream metadata formats supported by this plug-in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    protected String[] extraStreamMetadataFormatClassNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * A boolean indicating whether this plug-in supports the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * standard metadata format for image metadata, initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected boolean supportsStandardImageMetadataFormat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * A <code>String</code> containing the name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * native stream metadata format supported by this plug-in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    protected String nativeImageMetadataFormatName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * A <code>String</code> containing the class name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * native stream metadata format supported by this plug-in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    protected String nativeImageMetadataFormatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * An array of <code>String</code>s containing the names of any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * additional image metadata formats supported by this plug-in,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    protected String[] extraImageMetadataFormatNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * An array of <code>String</code>s containing the class names of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * any additional image metadata formats supported by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * plug-in, initially <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    protected String[] extraImageMetadataFormatClassNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Constructs an <code>ImageReaderWriterSpi</code> with a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * set of values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param vendorName the vendor name, as a non-<code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param version a version identifier, as a non-<code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param names a non-<code>null</code> array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * <code>String</code>s indicating the format names.  At least one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * entry must be present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param suffixes an array of <code>String</code>s indicating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * common file suffixes.  If no suffixes are defined,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <code>null</code> should be supplied.  An array of length 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * will be normalized to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param MIMETypes an array of <code>String</code>s indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * the format's MIME types.  If no MIME types are defined,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * <code>null</code> should be supplied.  An array of length 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * will be normalized to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param pluginClassName the fully-qualified name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * associated <code>ImageReader</code> or <code>ImageWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * class, as a non-<code>null</code> <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param supportsStandardStreamMetadataFormat a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * <code>boolean</code> that indicates whether a stream metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * object can use trees described by the standard metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param nativeStreamMetadataFormatName a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * <code>String</code>, or <code>null</code>, to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * <code>getNativeStreamMetadataFormatName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @param nativeStreamMetadataFormatClassName a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <code>String</code>, or <code>null</code>, to be used to instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * a metadata format object to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * <code>getNativeStreamMetadataFormat</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param extraStreamMetadataFormatNames an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * <code>String</code>s, or <code>null</code>, to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * <code>getExtraStreamMetadataFormatNames</code>.  An array of length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * 0 is normalized to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @param extraStreamMetadataFormatClassNames an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <code>String</code>s, or <code>null</code>, to be used to instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * a metadata format object to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <code>getStreamMetadataFormat</code>.  An array of length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * 0 is normalized to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param supportsStandardImageMetadataFormat a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <code>boolean</code> that indicates whether an image metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * object can use trees described by the standard metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param nativeImageMetadataFormatName a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * <code>String</code>, or <code>null</code>, to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * <code>getNativeImageMetadataFormatName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param nativeImageMetadataFormatClassName a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * <code>String</code>, or <code>null</code>, to be used to instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * a metadata format object to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * <code>getNativeImageMetadataFormat</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @param extraImageMetadataFormatNames an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * <code>String</code>s to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * <code>getExtraImageMetadataFormatNames</code>.  An array of length 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * is normalized to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @param extraImageMetadataFormatClassNames an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <code>String</code>s, or <code>null</code>, to be used to instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * a metadata format object to be returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * <code>getImageMetadataFormat</code>.  An array of length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * 0 is normalized to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @exception IllegalArgumentException if <code>vendorName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @exception IllegalArgumentException if <code>version</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @exception IllegalArgumentException if <code>names</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * is <code>null</code> or has length 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @exception IllegalArgumentException if <code>pluginClassName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public ImageReaderWriterSpi(String vendorName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                String version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                String[] names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                String[] suffixes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                String[] MIMETypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                String pluginClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                boolean supportsStandardStreamMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                String nativeStreamMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                String nativeStreamMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                String[] extraStreamMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                String[] extraStreamMetadataFormatClassNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                                boolean supportsStandardImageMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                String nativeImageMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                String nativeImageMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                                String[] extraImageMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                                String[] extraImageMetadataFormatClassNames) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        super(vendorName, version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        if (names == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            throw new IllegalArgumentException("names == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (names.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            throw new IllegalArgumentException("names.length == 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if (pluginClassName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            throw new IllegalArgumentException("pluginClassName == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   242
        this.names = names.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (suffixes != null && suffixes.length > 0) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   245
            this.suffixes = suffixes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        if (MIMETypes != null && MIMETypes.length > 0) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   249
            this.MIMETypes = MIMETypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        this.pluginClassName = pluginClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        this.supportsStandardStreamMetadataFormat =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            supportsStandardStreamMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        this.nativeStreamMetadataFormatName = nativeStreamMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        this.nativeStreamMetadataFormatClassName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            nativeStreamMetadataFormatClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        if (extraStreamMetadataFormatNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            extraStreamMetadataFormatNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            this.extraStreamMetadataFormatNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   262
                extraStreamMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        if (extraStreamMetadataFormatClassNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            extraStreamMetadataFormatClassNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            this.extraStreamMetadataFormatClassNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   268
                extraStreamMetadataFormatClassNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        this.supportsStandardImageMetadataFormat =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            supportsStandardImageMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        this.nativeImageMetadataFormatName = nativeImageMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        this.nativeImageMetadataFormatClassName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            nativeImageMetadataFormatClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        if (extraImageMetadataFormatNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            extraImageMetadataFormatNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            this.extraImageMetadataFormatNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   279
                extraImageMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (extraImageMetadataFormatClassNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            extraImageMetadataFormatClassNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            this.extraImageMetadataFormatClassNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   285
                extraImageMetadataFormatClassNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * Constructs a blank <code>ImageReaderWriterSpi</code>.  It is up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * to the subclass to initialize instance variables and/or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * override method implementations in order to provide working
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * versions of all methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public ImageReaderWriterSpi() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * Returns an array of <code>String</code>s containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * human-readable names for the formats that are generally usable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * by the <code>ImageReader</code> or <code>ImageWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * implementation associated with this service provider.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * example, a single <code>ImageReader</code> might be able to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * process both PBM and PNM files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @return a non-<code>null</code> array of <code>String</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * or length at least 1 containing informal format names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * associated with this reader or writer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public String[] getFormatNames() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   311
        return names.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * Returns an array of <code>String</code>s containing a list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * file suffixes associated with the formats that are generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * usable by the <code>ImageReader</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <code>ImageWriter</code> implementation associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * service provider.  For example, a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <code>ImageReader</code> might be able to process files with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * '.pbm' and '.pnm' suffixes, or both '.jpg' and '.jpeg'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * suffixes.  If there are no known file suffixes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * <code>null</code> will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * <p> Returning a particular suffix does not guarantee that files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * with that suffix can be processed; it merely indicates that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * may be worthwhile attempting to decode or encode such files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * using this service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @return an array of <code>String</code>s or length at least 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * containing common file suffixes associated with this reader or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * writer, or <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public String[] getFileSuffixes() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   335
        return suffixes == null ? null : suffixes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * Returns an array of <code>String</code>s containing a list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * MIME types associated with the formats that are generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * usable by the <code>ImageReader</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * <code>ImageWriter</code> implementation associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * <p> Ideally, only a single MIME type would be required in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * to describe a particular format.  However, for several reasons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * it is necessary to associate a list of types with each service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * provider.  First, many common image file formats do not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * standard MIME types, so a list of commonly used unofficial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * names will be required, such as <code>image/x-pbm</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * <code>image/x-portable-bitmap</code>.  Some file formats have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * official MIME types but may sometimes be referred to using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * their previous unofficial designations, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * <code>image/x-png</code> instead of the official
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * <code>image/png</code>.  Finally, a single service provider may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * be capable of parsing multiple distinct types from the MIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * point of view, for example <code>image/x-xbitmap</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * <code>image/x-xpixmap</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * <p> Returning a particular MIME type does not guarantee that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * files claiming to be of that type can be processed; it merely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * indicates that it may be worthwhile attempting to decode or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * encode such files using this service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @return an array of <code>String</code>s or length at least 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * containing MIME types associated with this reader or writer, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    public String[] getMIMETypes() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   370
        return MIMETypes == null ? null : MIMETypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * Returns the fully-qualified class name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * <code>ImageReader</code> or <code>ImageWriter</code> plug-in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * associated with this service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @return the class name, as a non-<code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    public String getPluginClassName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        return pluginClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Returns <code>true</code> if the standard metadata format is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * among the document formats recognized by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * <code>getAsTree</code> and <code>setFromTree</code> methods on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * the stream metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @return <code>true</code> if the standard format is supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * for stream metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    public boolean isStandardStreamMetadataFormatSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        return supportsStandardStreamMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * Returns the name of the "native" stream metadata format for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * this plug-in, which typically allows for lossless encoding and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * transmission of the stream metadata stored in the format handled by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * this plug-in.  If no such format is supported,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * <code>null</code>will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * <p> The default implementation returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * <code>nativeStreamMetadataFormatName</code> instance variable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @return the name of the native stream metadata format, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public String getNativeStreamMetadataFormatName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        return nativeStreamMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * Returns an array of <code>String</code>s containing the names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * of additional document formats, other than the native and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * standard formats, recognized by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * <code>getAsTree</code> and <code>setFromTree</code> methods on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * the stream metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * <p> If the plug-in does not handle metadata, null should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * <p> The set of formats may differ according to the particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * images being read or written; this method should indicate all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * the additional formats supported by the plug-in under any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * circumstances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * <p> The default implementation returns a clone of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * <code>extraStreamMetadataFormatNames</code> instance variable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @return an array of <code>String</code>s, or null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * @see IIOMetadata#getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * @see #getExtraImageMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @see #getNativeStreamMetadataFormatName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    public String[] getExtraStreamMetadataFormatNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        return extraStreamMetadataFormatNames == null ?
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   446
            null : extraStreamMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Returns <code>true</code> if the standard metadata format is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * among the document formats recognized by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * <code>getAsTree</code> and <code>setFromTree</code> methods on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * the image metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @return <code>true</code> if the standard format is supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * for image metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    public boolean isStandardImageMetadataFormatSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        return supportsStandardImageMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * Returns the name of the "native" image metadata format for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * this plug-in, which typically allows for lossless encoding and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * transmission of the image metadata stored in the format handled by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * this plug-in.  If no such format is supported,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * <code>null</code>will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * <p> The default implementation returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * <code>nativeImageMetadataFormatName</code> instance variable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @return the name of the native image metadata format, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @see #getExtraImageMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    public String getNativeImageMetadataFormatName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        return nativeImageMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * Returns an array of <code>String</code>s containing the names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * of additional document formats, other than the native and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * standard formats, recognized by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * <code>getAsTree</code> and <code>setFromTree</code> methods on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * the image metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * <p> If the plug-in does not handle image metadata, null should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * <p> The set of formats may differ according to the particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * images being read or written; this method should indicate all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * the additional formats supported by the plug-in under any circumstances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * <p> The default implementation returns a clone of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * <code>extraImageMetadataFormatNames</code> instance variable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @return an array of <code>String</code>s, or null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @see IIOMetadata#getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @see #getExtraStreamMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @see #getNativeImageMetadataFormatName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    public String[] getExtraImageMetadataFormatNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        return extraImageMetadataFormatNames == null ?
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   510
            null : extraImageMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * Returns an <code>IIOMetadataFormat</code> object describing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * given stream metadata format, or <code>null</code> if no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * description is available.  The supplied name must be the native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * stream metadata format name, the standard metadata format name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * or one of those returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * <code>getExtraStreamMetadataFormatNames</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @param formatName the desired stream metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * @return an <code>IIOMetadataFormat</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * @exception IllegalArgumentException if <code>formatName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * is <code>null</code> or is not a supported name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    public IIOMetadataFormat getStreamMetadataFormat(String formatName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        return getMetadataFormat(formatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                                 supportsStandardStreamMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                                 nativeStreamMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                                 nativeStreamMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                 extraStreamMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                 extraStreamMetadataFormatClassNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * Returns an <code>IIOMetadataFormat</code> object describing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * given image metadata format, or <code>null</code> if no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * description is available.  The supplied name must be the native
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   541
     * image metadata format name, the standard metadata format name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * or one of those returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * <code>getExtraImageMetadataFormatNames</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @param formatName the desired image metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @return an <code>IIOMetadataFormat</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * @exception IllegalArgumentException if <code>formatName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * is <code>null</code> or is not a supported name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    public IIOMetadataFormat getImageMetadataFormat(String formatName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        return getMetadataFormat(formatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                                 supportsStandardImageMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                                 nativeImageMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                                 nativeImageMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                                 extraImageMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                                 extraImageMetadataFormatClassNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    private IIOMetadataFormat getMetadataFormat(String formatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                                                boolean supportsStandard,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                                                String nativeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                                                String nativeClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                                                String [] extraNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                                                String [] extraClassNames) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        if (formatName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            throw new IllegalArgumentException("formatName == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        if (supportsStandard && formatName.equals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                (IIOMetadataFormatImpl.standardMetadataFormatName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            return IIOMetadataFormatImpl.getStandardFormatInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        String formatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        if (formatName.equals(nativeName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            formatClassName = nativeClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        } else if (extraNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            for (int i = 0; i < extraNames.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                if (formatName.equals(extraNames[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                    formatClassName = extraClassNames[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                    break;  // out of for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        if (formatClassName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            throw new IllegalArgumentException("Unsupported format name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        try {
23313
f100f0d49e0b 8035487: Fix raw and unchecked lint warnings in javax.imageio.spi
henryjen
parents: 22584
diff changeset
   590
            Class<?> cls = Class.forName(formatClassName, true,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                      ClassLoader.getSystemClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            Method meth = cls.getMethod("getInstance");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            return (IIOMetadataFormat) meth.invoke(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            RuntimeException ex =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                new IllegalStateException ("Can't obtain format");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            ex.initCause(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            throw ex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
}