jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java
author alanb
Fri, 07 Apr 2017 08:05:54 +0000
changeset 44545 83b611b88ac8
parent 40138 d294794a0878
permissions -rw-r--r--
8177530: Module system implementation refresh (4/2017) Reviewed-by: mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@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;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
    31
import java.security.AccessController;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
    32
import java.security.PrivilegedAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.imageio.ImageReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.imageio.metadata.IIOMetadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.imageio.metadata.IIOMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.imageio.metadata.IIOMetadataFormatImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import javax.imageio.stream.ImageInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * A superclass containing instance variables and methods common to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    43
 * {@code ImageReaderSpi} and {@code ImageWriterSpi}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see IIORegistry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see ImageReaderSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @see ImageWriterSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public abstract class ImageReaderWriterSpi extends IIOServiceProvider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * An array of strings to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    54
     * {@code getFormatNames}, initially {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    55
     * Constructors should set this to a non-{@code null} value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected String[] names = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * An array of strings to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    61
     * {@code getFileSuffixes}, initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    protected String[] suffixes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * An array of strings to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    67
     * {@code getMIMETypes}, initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected String[] MIMETypes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    72
     * A {@code String} containing the name of the associated
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    73
     * plug-in class, initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    protected String pluginClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * A boolean indicating whether this plug-in supports the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * standard metadata format for stream metadata, initially
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    80
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    protected boolean supportsStandardStreamMetadataFormat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    85
     * A {@code String} containing the name of the native stream
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * metadata format supported by this plug-in, initially
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    87
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    protected String nativeStreamMetadataFormatName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    92
     * A {@code String} containing the class name of the native
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * stream metadata format supported by this plug-in, initially
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    94
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    protected String nativeStreamMetadataFormatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    99
     * An array of {@code String}s containing the names of any
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * additional stream metadata formats supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   101
     * initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    protected String[] extraStreamMetadataFormatNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   106
     * An array of {@code String}s containing the class names of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * any additional stream metadata formats supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   108
     * initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    protected String[] extraStreamMetadataFormatClassNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * A boolean indicating whether this plug-in supports the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * standard metadata format for image metadata, initially
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   115
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    protected boolean supportsStandardImageMetadataFormat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   120
     * A {@code String} containing the name of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * native stream metadata format supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   122
     * initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    protected String nativeImageMetadataFormatName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   127
     * A {@code String} containing the class name of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * native stream metadata format supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   129
     * initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    protected String nativeImageMetadataFormatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   134
     * An array of {@code String}s containing the names of any
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * additional image metadata formats supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   136
     * initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    protected String[] extraImageMetadataFormatNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   141
     * An array of {@code String}s containing the class names of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * any additional image metadata formats supported by this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   143
     * plug-in, initially {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    protected String[] extraImageMetadataFormatClassNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   148
     * Constructs an {@code ImageReaderWriterSpi} with a given
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * set of values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   151
     * @param vendorName the vendor name, as a non-{@code null}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   152
     * {@code String}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   153
     * @param version a version identifier, as a non-{@code null}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   154
     * {@code String}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   155
     * @param names a non-{@code null} array of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   156
     * {@code String}s indicating the format names.  At least one
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * entry must be present.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   158
     * @param suffixes an array of {@code String}s indicating the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * common file suffixes.  If no suffixes are defined,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   160
     * {@code null} should be supplied.  An array of length 0
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   161
     * will be normalized to {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   162
     * @param MIMETypes an array of {@code String}s indicating
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * the format's MIME types.  If no MIME types are defined,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   164
     * {@code null} should be supplied.  An array of length 0
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   165
     * will be normalized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param pluginClassName the fully-qualified name of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   167
     * associated {@code ImageReader} or {@code ImageWriter}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   168
     * class, as a non-{@code null String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param supportsStandardStreamMetadataFormat a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   170
     * {@code boolean} that indicates whether a stream metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * object can use trees described by the standard metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param nativeStreamMetadataFormatName a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   173
     * {@code String}, or {@code null}, to be returned from
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   174
     * {@code getNativeStreamMetadataFormatName}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @param nativeStreamMetadataFormatClassName a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   176
     * {@code String}, or {@code null}, to be used to instantiate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * a metadata format object to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   178
     * {@code getNativeStreamMetadataFormat}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param extraStreamMetadataFormatNames an array of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   180
     * {@code String}s, or {@code null}, to be returned from
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   181
     * {@code getExtraStreamMetadataFormatNames}.  An array of length
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   182
     * 0 is normalized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @param extraStreamMetadataFormatClassNames an array of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   184
     * {@code String}s, or {@code null}, to be used to instantiate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * a metadata format object to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   186
     * {@code getStreamMetadataFormat}.  An array of length
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   187
     * 0 is normalized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param supportsStandardImageMetadataFormat a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   189
     * {@code boolean} that indicates whether an image metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * object can use trees described by the standard metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @param nativeImageMetadataFormatName a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   192
     * {@code String}, or {@code null}, to be returned from
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   193
     * {@code getNativeImageMetadataFormatName}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @param nativeImageMetadataFormatClassName a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   195
     * {@code String}, or {@code null}, to be used to instantiate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * a metadata format object to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   197
     * {@code getNativeImageMetadataFormat}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @param extraImageMetadataFormatNames an array of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   199
     * {@code String}s to be returned from
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   200
     * {@code getExtraImageMetadataFormatNames}.  An array of length 0
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   201
     * is normalized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @param extraImageMetadataFormatClassNames an array of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   203
     * {@code String}s, or {@code null}, to be used to instantiate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * a metadata format object to be returned from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   205
     * {@code getImageMetadataFormat}.  An array of length
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   206
     * 0 is normalized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   208
     * @exception IllegalArgumentException if {@code vendorName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   209
     * is {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   210
     * @exception IllegalArgumentException if {@code version}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   211
     * is {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   212
     * @exception IllegalArgumentException if {@code names}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   213
     * is {@code null} or has length 0.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   214
     * @exception IllegalArgumentException if {@code pluginClassName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   215
     * is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public ImageReaderWriterSpi(String vendorName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                String version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                String[] names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                String[] suffixes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                String[] MIMETypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                String pluginClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                boolean supportsStandardStreamMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                String nativeStreamMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                String nativeStreamMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                                String[] extraStreamMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                String[] extraStreamMetadataFormatClassNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                boolean supportsStandardImageMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                                String nativeImageMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                                String nativeImageMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                                String[] extraImageMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                String[] extraImageMetadataFormatClassNames) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        super(vendorName, version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (names == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            throw new IllegalArgumentException("names == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        if (names.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            throw new IllegalArgumentException("names.length == 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        if (pluginClassName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            throw new IllegalArgumentException("pluginClassName == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   244
        this.names = names.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (suffixes != null && suffixes.length > 0) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   247
            this.suffixes = suffixes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        if (MIMETypes != null && MIMETypes.length > 0) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   251
            this.MIMETypes = MIMETypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        this.pluginClassName = pluginClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        this.supportsStandardStreamMetadataFormat =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            supportsStandardStreamMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        this.nativeStreamMetadataFormatName = nativeStreamMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        this.nativeStreamMetadataFormatClassName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            nativeStreamMetadataFormatClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        if (extraStreamMetadataFormatNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            extraStreamMetadataFormatNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            this.extraStreamMetadataFormatNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   264
                extraStreamMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        if (extraStreamMetadataFormatClassNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            extraStreamMetadataFormatClassNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            this.extraStreamMetadataFormatClassNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   270
                extraStreamMetadataFormatClassNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        this.supportsStandardImageMetadataFormat =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            supportsStandardImageMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        this.nativeImageMetadataFormatName = nativeImageMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        this.nativeImageMetadataFormatClassName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            nativeImageMetadataFormatClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if (extraImageMetadataFormatNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            extraImageMetadataFormatNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            this.extraImageMetadataFormatNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   281
                extraImageMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        // If length == 0, leave it null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        if (extraImageMetadataFormatClassNames != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            extraImageMetadataFormatClassNames.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            this.extraImageMetadataFormatClassNames =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   287
                extraImageMetadataFormatClassNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   292
     * Constructs a blank {@code ImageReaderWriterSpi}.  It is up
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * to the subclass to initialize instance variables and/or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * override method implementations in order to provide working
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * versions of all methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    public ImageReaderWriterSpi() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   301
     * Returns an array of {@code String}s containing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * human-readable names for the formats that are generally usable
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   303
     * by the {@code ImageReader} or {@code ImageWriter}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * implementation associated with this service provider.  For
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   305
     * example, a single {@code ImageReader} might be able to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * process both PBM and PNM files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   308
     * @return a non-{@code null} array of {@code String}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * or length at least 1 containing informal format names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * associated with this reader or writer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public String[] getFormatNames() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   313
        return names.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   317
     * Returns an array of {@code String}s containing a list of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * file suffixes associated with the formats that are generally
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   319
     * usable by the {@code ImageReader} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   320
     * {@code ImageWriter} implementation associated with this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * service provider.  For example, a single
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   322
     * {@code ImageReader} might be able to process files with
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * '.pbm' and '.pnm' suffixes, or both '.jpg' and '.jpeg'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * suffixes.  If there are no known file suffixes,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   325
     * {@code null} will be returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * <p> Returning a particular suffix does not guarantee that files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * with that suffix can be processed; it merely indicates that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * may be worthwhile attempting to decode or encode such files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * using this service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   332
     * @return an array of {@code String}s or length at least 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * containing common file suffixes associated with this reader or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   334
     * writer, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public String[] getFileSuffixes() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   337
        return suffixes == null ? null : suffixes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   341
     * Returns an array of {@code String}s containing a list of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * MIME types associated with the formats that are generally
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   343
     * usable by the {@code ImageReader} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   344
     * {@code ImageWriter} implementation associated with this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * <p> Ideally, only a single MIME type would be required in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * to describe a particular format.  However, for several reasons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * it is necessary to associate a list of types with each service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * provider.  First, many common image file formats do not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * standard MIME types, so a list of commonly used unofficial
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   352
     * names will be required, such as {@code image/x-pbm} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   353
     * {@code image/x-portable-bitmap}.  Some file formats have
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * official MIME types but may sometimes be referred to using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * their previous unofficial designations, such as
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   356
     * {@code image/x-png} instead of the official
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   357
     * {@code image/png}.  Finally, a single service provider may
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * be capable of parsing multiple distinct types from the MIME
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   359
     * point of view, for example {@code image/x-xbitmap} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   360
     * {@code image/x-xpixmap}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * <p> Returning a particular MIME type does not guarantee that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * files claiming to be of that type can be processed; it merely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * indicates that it may be worthwhile attempting to decode or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * encode such files using this service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   367
     * @return an array of {@code String}s or length at least 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * containing MIME types associated with this reader or writer, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   369
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    public String[] getMIMETypes() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   372
        return MIMETypes == null ? null : MIMETypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Returns the fully-qualified class name of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   377
     * {@code ImageReader} or {@code ImageWriter} plug-in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * associated with this service provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   380
     * @return the class name, as a non-{@code null}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   381
     * {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public String getPluginClassName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return pluginClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   388
     * Returns {@code true} if the standard metadata format is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * among the document formats recognized by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   390
     * {@code getAsTree} and {@code setFromTree} methods on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * the stream metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   394
     * @return {@code true} if the standard format is supported
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * for stream metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    public boolean isStandardStreamMetadataFormatSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        return supportsStandardStreamMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Returns the name of the "native" stream metadata format for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * this plug-in, which typically allows for lossless encoding and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * transmission of the stream metadata stored in the format handled by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * this plug-in.  If no such format is supported,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   406
     * {@code null} will be returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * <p> The default implementation returns the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   409
     * {@code nativeStreamMetadataFormatName} instance variable,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @return the name of the native stream metadata format, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   413
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    public String getNativeStreamMetadataFormatName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return nativeStreamMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   421
     * Returns an array of {@code String}s containing the names
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * of additional document formats, other than the native and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * standard formats, recognized by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   424
     * {@code getAsTree} and {@code setFromTree} methods on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * the stream metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <p> If the plug-in does not handle metadata, null should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * <p> The set of formats may differ according to the particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * images being read or written; this method should indicate all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * the additional formats supported by the plug-in under any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * circumstances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <p> The default implementation returns a clone of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   437
     * {@code extraStreamMetadataFormatNames} instance variable,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   440
     * @return an array of {@code String}s, or null.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @see IIOMetadata#getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @see #getExtraImageMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @see #getNativeStreamMetadataFormatName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public String[] getExtraStreamMetadataFormatNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return extraStreamMetadataFormatNames == null ?
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   448
            null : extraStreamMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   452
     * Returns {@code true} if the standard metadata format is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * among the document formats recognized by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   454
     * {@code getAsTree} and {@code setFromTree} methods on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * the image metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   458
     * @return {@code true} if the standard format is supported
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * for image metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    public boolean isStandardImageMetadataFormatSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        return supportsStandardImageMetadataFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * Returns the name of the "native" image metadata format for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * this plug-in, which typically allows for lossless encoding and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * transmission of the image metadata stored in the format handled by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * this plug-in.  If no such format is supported,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   470
     * {@code null} will be returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * <p> The default implementation returns the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   473
     * {@code nativeImageMetadataFormatName} instance variable,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * @return the name of the native image metadata format, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   477
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @see #getExtraImageMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    public String getNativeImageMetadataFormatName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        return nativeImageMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   486
     * Returns an array of {@code String}s containing the names
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * of additional document formats, other than the native and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * standard formats, recognized by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   489
     * {@code getAsTree} and {@code setFromTree} methods on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * the image metadata objects produced or consumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * <p> If the plug-in does not handle image metadata, null should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * <p> The set of formats may differ according to the particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * images being read or written; this method should indicate all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * the additional formats supported by the plug-in under any circumstances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * <p> The default implementation returns a clone of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   501
     * {@code extraImageMetadataFormatNames} instance variable,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * which is typically set by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   504
     * @return an array of {@code String}s, or null.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @see IIOMetadata#getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @see #getExtraStreamMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @see #getNativeImageMetadataFormatName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public String[] getExtraImageMetadataFormatNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        return extraImageMetadataFormatNames == null ?
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   512
            null : extraImageMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   516
     * Returns an {@code IIOMetadataFormat} object describing the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   517
     * given stream metadata format, or {@code null} if no
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * description is available.  The supplied name must be the native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * stream metadata format name, the standard metadata format name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * or one of those returned by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   521
     * {@code getExtraStreamMetadataFormatNames}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * @param formatName the desired stream metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   525
     * @return an {@code IIOMetadataFormat} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   527
     * @exception IllegalArgumentException if {@code formatName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   528
     * is {@code null} or is not a supported name.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    public IIOMetadataFormat getStreamMetadataFormat(String formatName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        return getMetadataFormat(formatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                                 supportsStandardStreamMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                 nativeStreamMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                 nativeStreamMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                                 extraStreamMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                                 extraStreamMetadataFormatClassNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   540
     * Returns an {@code IIOMetadataFormat} object describing the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   541
     * given image metadata format, or {@code null} if no
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * 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
   543
     * image metadata format name, the standard metadata format name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * or one of those returned by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   545
     * {@code getExtraImageMetadataFormatNames}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @param formatName the desired image metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   549
     * @return an {@code IIOMetadataFormat} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   551
     * @exception IllegalArgumentException if {@code formatName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   552
     * is {@code null} or is not a supported name.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    public IIOMetadataFormat getImageMetadataFormat(String formatName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        return getMetadataFormat(formatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                                 supportsStandardImageMetadataFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                                 nativeImageMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                                 nativeImageMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                                 extraImageMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                                 extraImageMetadataFormatClassNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    private IIOMetadataFormat getMetadataFormat(String formatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                                                boolean supportsStandard,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                                                String nativeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                                                String nativeClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                                                String [] extraNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                                                String [] extraClassNames) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        if (formatName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            throw new IllegalArgumentException("formatName == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        if (supportsStandard && formatName.equals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                (IIOMetadataFormatImpl.standardMetadataFormatName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            return IIOMetadataFormatImpl.getStandardFormatInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        String formatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if (formatName.equals(nativeName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            formatClassName = nativeClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        } else if (extraNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            for (int i = 0; i < extraNames.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                if (formatName.equals(extraNames[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                    formatClassName = extraClassNames[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                    break;  // out of for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        if (formatClassName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            throw new IllegalArgumentException("Unsupported format name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        try {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   592
            // Try to load from the same location as the module of the SPI
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   593
            final String className = formatClassName;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   594
            PrivilegedAction<Class<?>> pa = () -> { return getMetadataFormatClass(className); };
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   595
            Class<?> cls = AccessController.doPrivileged(pa);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            Method meth = cls.getMethod("getInstance");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            return (IIOMetadataFormat) meth.invoke(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            RuntimeException ex =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                new IllegalStateException ("Can't obtain format");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            ex.initCause(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            throw ex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   605
40138
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   606
    // If updating this method also see the same in IIOMetadata.java
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   607
    private Class<?> getMetadataFormatClass(String formatClassName) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   608
        Module thisModule = ImageReaderWriterSpi.class.getModule();
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   609
        Module targetModule = this.getClass().getModule();
40138
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   610
        Class<?> c = null;
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   611
        try {
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   612
            ClassLoader cl = this.getClass().getClassLoader();
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   613
            c = Class.forName(formatClassName, false, cl);
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   614
            if (!IIOMetadataFormat.class.isAssignableFrom(c)) {
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   615
                return null;
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   616
            }
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   617
        } catch (ClassNotFoundException e) {
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   618
        }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   619
        if (thisModule.equals(targetModule) || c == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   620
            return c;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   621
        }
40138
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   622
        if (targetModule.isNamed()) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   623
            int i = formatClassName.lastIndexOf(".");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   624
            String pn = i > 0 ? formatClassName.substring(0, i) : "";
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   625
            if (!targetModule.isExported(pn, thisModule)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   626
                throw new IllegalStateException("Class " +  formatClassName +
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   627
                  " in named module must be exported to java.desktop module.");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   628
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   629
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   630
        return c;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   631
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
}