jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.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.metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import org.w3c.dom.Node;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
    29
2
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * An abstract class to be extended by objects that represent metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * (non-image data) associated with images and streams.  Plug-ins
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * represent metadata using opaque, plug-in specific objects.  These
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * objects, however, provide the ability to access their internal
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    39
 * information as a tree of {@code IIOMetadataNode} objects that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * support the XML DOM interfaces as well as additional interfaces for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * storing non-textual data and retrieving information about legal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * data values.  The format of such trees is plug-in dependent, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * plug-ins may choose to support a plug-in neutral format described
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * below.  A single plug-in may support multiple metadata formats,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * whose names maybe determined by calling
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    46
 * {@code getMetadataFormatNames}.  The plug-in may also support
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * a single special format, referred to as the "native" format, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * is designed to encode its metadata losslessly.  This format will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * typically be designed specifically to work with a specific file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * format, so that images may be loaded and saved in the same format
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
    51
 * with no loss of metadata, but may be less useful for transferring
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    52
 * metadata between an {@code ImageReader} and an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    53
 * {@code ImageWriter} for different image formats.  To convert
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * between two native formats as losslessly as the image file formats
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    55
 * will allow, an {@code ImageTranscoder} object must be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see javax.imageio.ImageReader#getImageMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @see javax.imageio.ImageReader#getStreamMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @see javax.imageio.ImageReader#readAll
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @see javax.imageio.ImageWriter#getDefaultStreamMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see javax.imageio.ImageWriter#getDefaultImageMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see javax.imageio.ImageWriter#write
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see javax.imageio.ImageWriter#convertImageMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @see javax.imageio.ImageWriter#convertStreamMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @see javax.imageio.IIOImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @see javax.imageio.ImageTranscoder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public abstract class IIOMetadata {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * A boolean indicating whether the concrete subclass supports the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * standard metadata format, set via the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    protected boolean standardFormatSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * The name of the native metadata format for this object,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    79
     * initialized to {@code null} and set via the constructor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected String nativeMetadataFormatName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    84
     * The name of the class implementing {@code IIOMetadataFormat}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * and representing the native metadata format, initialized to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    86
     * {@code null} and set via the constructor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    protected String nativeMetadataFormatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * An array of names of formats, other than the standard and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * native formats, that are supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    93
     * initialized to {@code null} and set via the constructor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    protected String[] extraMetadataFormatNames = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    98
     * An array of names of classes implementing {@code IIOMetadataFormat}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * and representing the metadata formats, other than the standard and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * native formats, that are supported by this plug-in,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   101
     * initialized to {@code null} and set via the constructor.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    protected String[] extraMetadataFormatClassNames = 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 {@code IIOMetadataController} that is suggested for use
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   107
     * as the controller for this {@code IIOMetadata} object.  It
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   108
     * may be retrieved via {@code getDefaultController}.  To
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * install the default controller, call
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   110
     * {@code setController(getDefaultController())}.  This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * instance variable should be set by subclasses that choose to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * provide their own default controller, usually a GUI, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * setting parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #getDefaultController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected IIOMetadataController defaultController = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   121
     * The {@code IIOMetadataController} that will be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   122
     * used to provide settings for this {@code IIOMetadata}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   123
     * object when the {@code activateController} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * is called.  This value overrides any default controller,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   125
     * even when {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @see #setController(IIOMetadataController)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @see #hasController()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see #activateController()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    protected IIOMetadataController controller = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   135
     * Constructs an empty {@code IIOMetadata} object.  The
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   136
     * subclass is responsible for supplying values for all protected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * instance variables that will allow any non-overridden default
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   138
     * implementations of methods to satisfy their contracts.  For example,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   139
     * {@code extraMetadataFormatNames} should not have length 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    protected IIOMetadata() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   144
     * Constructs an {@code IIOMetadata} object with the given
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * format names and format class names, as well as a boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * indicating whether the standard format is supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <p> This constructor does not attempt to check the class names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * for validity.  Invalid class names may cause exceptions in
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   150
     * subsequent calls to {@code getMetadataFormat}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   152
     * @param standardMetadataFormatSupported {@code true} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * this object can return or accept a DOM tree using the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param nativeMetadataFormatName the name of the native metadata
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   156
     * format, as a {@code String}, or {@code null} if there
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * is no native format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @param nativeMetadataFormatClassName the name of the class of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   159
     * the native metadata format, or {@code null} if there is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * no native format.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   161
     * @param extraMetadataFormatNames an array of {@code String}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * indicating additional formats supported by this object, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   163
     * {@code null} if there are none.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   164
     * @param extraMetadataFormatClassNames an array of {@code String}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * indicating the class names of any additional formats supported by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   166
     * this object, or {@code null} if there are none.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @exception IllegalArgumentException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   169
     * {@code extraMetadataFormatNames} has length 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @exception IllegalArgumentException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   171
     * {@code extraMetadataFormatNames} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   172
     * {@code extraMetadataFormatClassNames} are neither both
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   173
     * {@code null}, nor of the same length.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    protected IIOMetadata(boolean standardMetadataFormatSupported,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                          String nativeMetadataFormatName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                          String nativeMetadataFormatClassName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                          String[] extraMetadataFormatNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                          String[] extraMetadataFormatClassNames) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        this.standardFormatSupported = standardMetadataFormatSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        this.nativeMetadataFormatName = nativeMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        this.nativeMetadataFormatClassName = nativeMetadataFormatClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (extraMetadataFormatNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            if (extraMetadataFormatNames.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                throw new IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    ("extraMetadataFormatNames.length == 0!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            if (extraMetadataFormatClassNames == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                throw new IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    ("extraMetadataFormatNames != null && extraMetadataFormatClassNames == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            if (extraMetadataFormatClassNames.length !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                extraMetadataFormatNames.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                throw new IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    ("extraMetadataFormatClassNames.length != extraMetadataFormatNames.length!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   197
            this.extraMetadataFormatNames = extraMetadataFormatNames.clone();
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   198
            this.extraMetadataFormatClassNames = extraMetadataFormatClassNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            if (extraMetadataFormatClassNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                throw new IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    ("extraMetadataFormatNames == null && extraMetadataFormatClassNames != null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   208
     * Returns {@code true} if the standard metadata format is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   209
     * supported by {@code getMetadataFormat},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   210
     * {@code getAsTree}, {@code setFromTree}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   211
     * {@code mergeTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   214
     * {@code standardFormatSupported} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   216
     * @return {@code true} if the standard metadata format
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * is supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @see #getAsTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @see #setFromTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @see #mergeTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @see #getMetadataFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public boolean isStandardMetadataFormatSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return standardFormatSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   229
     * Returns {@code true} if this object does not support the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   230
     * {@code mergeTree}, {@code setFromTree}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   231
     * {@code reset} methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   233
     * @return true if this {@code IIOMetadata} object cannot be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public abstract boolean isReadOnly();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Returns the name of the "native" metadata format for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * plug-in, which typically allows for lossless encoding and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * transmission of the metadata stored in the format handled by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * this plug-in.  If no such format is supported,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   243
     * {@code null} will be returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * <p> The structure and contents of the "native" metadata format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * are defined by the plug-in that created this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   247
     * {@code IIOMetadata} object.  Plug-ins for simple formats
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * will usually create a dummy node for the root, and then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * series of child nodes representing individual tags, chunks, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * keyword/value pairs.  A plug-in may choose whether or not to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * document its native format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   254
     * {@code nativeMetadataFormatName} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   256
     * @return the name of the native format, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see #getExtraMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @see #getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public String getNativeMetadataFormatName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return nativeMetadataFormatName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   266
     * Returns an array of {@code String}s containing the names
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * of additional metadata formats, other than the native and standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * formats, recognized by this plug-in's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   269
     * {@code getAsTree}, {@code setFromTree}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   270
     * {@code mergeTree} methods.  If there are no such additional
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   271
     * formats, {@code null} is returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <p> The default implementation returns a clone of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   274
     * {@code extraMetadataFormatNames} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   276
     * @return an array of {@code String}s with length at least
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   277
     * 1, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @see #getAsTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @see #setFromTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @see #mergeTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @see #getNativeMetadataFormatName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @see #getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public String[] getExtraMetadataFormatNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (extraMetadataFormatNames == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 21278
diff changeset
   289
        return extraMetadataFormatNames.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   293
     * Returns an array of {@code String}s containing the names
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * of all metadata formats, including the native and standard
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   295
     * formats, recognized by this plug-in's {@code getAsTree},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   296
     * {@code setFromTree}, and {@code mergeTree} methods.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   297
     * If there are no such formats, {@code null} is returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * <p> The default implementation calls
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   300
     * {@code getNativeMetadataFormatName},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   301
     * {@code isStandardMetadataFormatSupported}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   302
     * {@code getExtraMetadataFormatNames} and returns the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * combined results.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   305
     * @return an array of {@code String}s.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @see #getNativeMetadataFormatName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @see #isStandardMetadataFormatSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see #getExtraMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public String[] getMetadataFormatNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        String nativeName = getNativeMetadataFormatName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        String standardName = isStandardMetadataFormatSupported() ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            IIOMetadataFormatImpl.standardMetadataFormatName : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        String[] extraNames = getExtraMetadataFormatNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        int numFormats = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        if (nativeName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            ++numFormats;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        if (standardName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            ++numFormats;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        if (extraNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            numFormats += extraNames.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        if (numFormats == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        String[] formats = new String[numFormats];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        int index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if (nativeName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            formats[index++] = nativeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        if (standardName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            formats[index++] = standardName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if (extraNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            for (int i = 0; i < extraNames.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                formats[index++] = extraNames[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        return formats;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   349
     * Returns an {@code IIOMetadataFormat} object describing the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   350
     * given metadata format, or {@code null} if no description
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * is available.  The supplied name must be one of those returned
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   352
     * by {@code getMetadataFormatNames} (<i>i.e.</i>, either the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * native format name, the standard format name, or one of those
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   354
     * returned by {@code getExtraMetadataFormatNames}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * <p> The default implementation checks the name against the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * global standard metadata format name, and returns that format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * if it is supported.  Otherwise, it checks against the native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * format names followed by any additional format names.  If a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * match is found, it retrieves the name of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   361
     * {@code IIOMetadataFormat} class from
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   362
     * {@code nativeMetadataFormatClassName} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   363
     * {@code extraMetadataFormatClassNames} as appropriate, and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * constructs an instance of that class using its
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   365
     * {@code getInstance} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @param formatName the desired metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   369
     * @return an {@code IIOMetadataFormat} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   371
     * @exception IllegalArgumentException if {@code formatName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   372
     * is {@code null} or is not one of the names recognized by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * the plug-in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @exception IllegalStateException if the class corresponding to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * the format name cannot be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public IIOMetadataFormat getMetadataFormat(String formatName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        if (formatName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            throw new IllegalArgumentException("formatName == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        if (standardFormatSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            && formatName.equals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                (IIOMetadataFormatImpl.standardMetadataFormatName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            return IIOMetadataFormatImpl.getStandardFormatInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        String formatClassName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        if (formatName.equals(nativeMetadataFormatName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            formatClassName = nativeMetadataFormatClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        } else if (extraMetadataFormatNames != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            for (int i = 0; i < extraMetadataFormatNames.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                if (formatName.equals(extraMetadataFormatNames[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                    formatClassName = extraMetadataFormatClassNames[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                    break;  // out of for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        if (formatClassName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            throw new IllegalArgumentException("Unsupported format name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        try {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   401
            final String className = formatClassName;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   402
            // Try to load from the module of the IIOMetadata implementation
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   403
            // for this plugin since the IIOMetadataImpl is part of the plugin
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   404
            PrivilegedAction<Class<?>> pa = () -> { return getMetadataFormatClass(className); };
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   405
            Class<?> cls = AccessController.doPrivileged(pa);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            Method meth = cls.getMethod("getInstance");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            return (IIOMetadataFormat) meth.invoke(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            RuntimeException ex =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                new IllegalStateException ("Can't obtain format");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            ex.initCause(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            throw ex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   414
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
40138
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   416
    // If updating this method also see the same in ImageReaderWriterSpi.java
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   417
    private Class<?> getMetadataFormatClass(String formatClassName) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   418
        Module thisModule = IIOMetadata.class.getModule();
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   419
        Module targetModule = this.getClass().getModule();
40138
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   420
        Class<?> c = null;
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   421
        try {
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   422
            ClassLoader cl = this.getClass().getClassLoader();
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   423
            c = Class.forName(formatClassName, false, cl);
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   424
            if (!IIOMetadataFormat.class.isAssignableFrom(c)) {
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   425
                return null;
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   426
            }
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   427
        } catch (ClassNotFoundException e) {
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   428
        }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   429
        if (thisModule.equals(targetModule) || c == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   430
            return c;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   431
        }
40138
d294794a0878 8140314: Verify IIOMetadataFormat class on loading
prr
parents: 36511
diff changeset
   432
        if (targetModule.isNamed()) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   433
            int i = formatClassName.lastIndexOf(".");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   434
            String pn = i > 0 ? formatClassName.substring(0, i) : "";
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   435
            if (!targetModule.isExported(pn, thisModule)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   436
                throw new IllegalStateException("Class " + formatClassName +
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   437
                   " in named module must be exported to java.desktop module.");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   438
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   439
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35667
diff changeset
   440
        return c;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   444
     * Returns an XML DOM {@code Node} object that represents the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * root of a tree of metadata contained within this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * according to the conventions defined by a given metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * <p> The names of the available metadata formats may be queried
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   450
     * using the {@code getMetadataFormatNames} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @param formatName the desired metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   454
     * @return an XML DOM {@code Node} object forming the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * root of a tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   457
     * @exception IllegalArgumentException if {@code formatName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   458
     * is {@code null} or is not one of the names returned by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   459
     * {@code getMetadataFormatNames}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @see #getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @see #setFromTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @see #mergeTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    public abstract Node getAsTree(String formatName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   468
     * Alters the internal state of this {@code IIOMetadata}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   469
     * object from a tree of XML DOM {@code Node}s whose syntax
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * is defined by the given metadata format.  The previous state is
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   471
     * altered only as necessary to accommodate the nodes that are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * present in the given tree.  If the tree structure or contents
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   473
     * are invalid, an {@code IIOInvalidTreeException} will be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * <p> As the semantics of how a tree or subtree may be merged with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * another tree are completely format-specific, plug-in authors may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * implement this method in whatever manner is most appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * the format, including simply replacing all existing state with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * contents of the given tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @param formatName the desired metadata format.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   483
     * @param root an XML DOM {@code Node} object forming the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * root of a tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @exception IllegalStateException if this object is read-only.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   487
     * @exception IllegalArgumentException if {@code formatName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   488
     * is {@code null} or is not one of the names returned by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   489
     * {@code getMetadataFormatNames}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   490
     * @exception IllegalArgumentException if {@code root} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   491
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @exception IIOInvalidTreeException if the tree cannot be parsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * successfully using the rules of the given format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see #getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @see #getAsTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @see #setFromTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    public abstract void mergeTree(String formatName, Node root)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        throws IIOInvalidTreeException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   503
     * Returns an {@code IIOMetadataNode} representing the chroma
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   504
     * information of the standard {@code javax_imageio_1.0}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   505
     * metadata format, or {@code null} if no such information is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * available.  This method is intended to be called by the utility
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   507
     * routine {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   509
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   515
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    protected IIOMetadataNode getStandardChromaNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   524
     * Returns an {@code IIOMetadataNode} representing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * compression information of the standard
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   526
     * {@code javax_imageio_1.0} metadata format, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   527
     * {@code null} if no such information is available.  This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * method is intended to be called by the utility routine
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   529
     * {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   531
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   537
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    protected IIOMetadataNode getStandardCompressionNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   546
     * Returns an {@code IIOMetadataNode} representing the data
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * format information of the standard
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   548
     * {@code javax_imageio_1.0} metadata format, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   549
     * {@code null} if no such information is available.  This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * method is intended to be called by the utility routine
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   551
     * {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   553
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   559
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    protected IIOMetadataNode getStandardDataNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   568
     * Returns an {@code IIOMetadataNode} representing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * dimension information of the standard
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   570
     * {@code javax_imageio_1.0} metadata format, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   571
     * {@code null} if no such information is available.  This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * method is intended to be called by the utility routine
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   573
     * {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   575
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   581
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    protected IIOMetadataNode getStandardDimensionNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   590
     * Returns an {@code IIOMetadataNode} representing the document
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   591
     * information of the standard {@code javax_imageio_1.0}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   592
     * metadata format, or {@code null} if no such information is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * available.  This method is intended to be called by the utility
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   594
     * routine {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   596
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   602
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    protected IIOMetadataNode getStandardDocumentNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   611
     * Returns an {@code IIOMetadataNode} representing the textual
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   612
     * information of the standard {@code javax_imageio_1.0}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   613
     * metadata format, or {@code null} if no such information is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * available.  This method is intended to be called by the utility
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   615
     * routine {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   617
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   623
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    protected IIOMetadataNode getStandardTextNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   632
     * Returns an {@code IIOMetadataNode} representing the tiling
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   633
     * information of the standard {@code javax_imageio_1.0}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   634
     * metadata format, or {@code null} if no such information is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * available.  This method is intended to be called by the utility
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   636
     * routine {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   638
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   644
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @see #getStandardTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    protected IIOMetadataNode getStandardTileNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   653
     * Returns an {@code IIOMetadataNode} representing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * transparency information of the standard
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   655
     * {@code javax_imageio_1.0} metadata format, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   656
     * {@code null} if no such information is available.  This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * method is intended to be called by the utility routine
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   658
     * {@code getStandardTree}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   660
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * <p> Subclasses should override this method to produce an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * appropriate subtree if they wish to support the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * metadata format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   666
     * @return an {@code IIOMetadataNode}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    protected IIOMetadataNode getStandardTransparencyNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Appends a new node to an existing node, if the new node is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   674
     * non-{@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    private void append(IIOMetadataNode root, IIOMetadataNode node) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        if (node != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            root.appendChild(node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * A utility method to return a tree of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   684
     * {@code IIOMetadataNode}s representing the metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * contained within this object according to the conventions of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   686
     * the standard {@code javax_imageio_1.0} metadata format.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   688
     * <p> This method calls the various {@code getStandard*Node}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * methods to supply each of the subtrees rooted at the children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * of the root node.  If any of those methods returns
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   691
     * {@code null}, the corresponding subtree will be omitted.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   692
     * If all of them return {@code null}, a tree consisting of a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * single root node will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   695
     * @return an {@code IIOMetadataNode} representing the root
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   696
     * of a metadata tree in the {@code javax_imageio_1.0}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * @see #getStandardChromaNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @see #getStandardCompressionNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * @see #getStandardDataNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @see #getStandardDimensionNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * @see #getStandardDocumentNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @see #getStandardTextNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * @see #getStandardTileNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * @see #getStandardTransparencyNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    protected final IIOMetadataNode getStandardTree() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        IIOMetadataNode root = new IIOMetadataNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                (IIOMetadataFormatImpl.standardMetadataFormatName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        append(root, getStandardChromaNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        append(root, getStandardCompressionNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        append(root, getStandardDataNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        append(root, getStandardDimensionNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        append(root, getStandardDocumentNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        append(root, getStandardTextNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        append(root, getStandardTileNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        append(root, getStandardTransparencyNode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        return root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   723
     * Sets the internal state of this {@code IIOMetadata} object
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   724
     * from a tree of XML DOM {@code Node}s whose syntax is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * defined by the given metadata format.  The previous state is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * discarded.  If the tree's structure or contents are invalid, an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   727
     * {@code IIOInvalidTreeException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   729
     * <p> The default implementation calls {@code reset}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   730
     * followed by {@code mergeTree(formatName, root)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * @param formatName the desired metadata format.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   733
     * @param root an XML DOM {@code Node} object forming the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * root of a tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * @exception IllegalStateException if this object is read-only.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   737
     * @exception IllegalArgumentException if {@code formatName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   738
     * is {@code null} or is not one of the names returned by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   739
     * {@code getMetadataFormatNames}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   740
     * @exception IllegalArgumentException if {@code root} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   741
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * @exception IIOInvalidTreeException if the tree cannot be parsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * successfully using the rules of the given format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * @see #getMetadataFormatNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * @see #getAsTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * @see #mergeTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    public void setFromTree(String formatName, Node root)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        throws IIOInvalidTreeException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        mergeTree(formatName, root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * Resets all the data stored in this object to default values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * usually to the state this object was in immediately after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * construction, though the precise semantics are plug-in specific.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * Note that there are many possible default values, depending on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * how the object was created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * @exception IllegalStateException if this object is read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * @see javax.imageio.ImageReader#getStreamMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * @see javax.imageio.ImageReader#getImageMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * @see javax.imageio.ImageWriter#getDefaultStreamMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * @see javax.imageio.ImageWriter#getDefaultImageMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    public abstract void reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   772
     * Sets the {@code IIOMetadataController} to be used
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   773
     * to provide settings for this {@code IIOMetadata}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   774
     * object when the {@code activateController} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * is called, overriding any default controller.  If the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   776
     * argument is {@code null}, no controller will be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * used, including any default.  To restore the default, use
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   778
     * {@code setController(getDefaultController())}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   780
     * <p> The default implementation sets the {@code controller}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * instance variable to the supplied value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * @param controller An appropriate
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   784
     * {@code IIOMetadataController}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * @see #getController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * @see #getDefaultController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * @see #hasController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * @see #activateController()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    public void setController(IIOMetadataController controller) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        this.controller = controller;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   797
     * Returns whatever {@code IIOMetadataController} is currently
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * installed.  This could be the default if there is one,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   799
     * {@code null}, or the argument of the most recent call
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   800
     * to {@code setController}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   803
     * {@code controller} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @return the currently installed
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   806
     * {@code IIOMetadataController}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @see #setController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * @see #getDefaultController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * @see #hasController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * @see #activateController()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    public IIOMetadataController getController() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return controller;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   819
     * Returns the default {@code IIOMetadataController}, if there
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * is one, regardless of the currently installed controller.  If
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   821
     * there is no default controller, returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   824
     * {@code defaultController} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   826
     * @return the default {@code IIOMetadataController}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   827
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * @see #setController(IIOMetadataController)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * @see #getController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * @see #hasController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * @see #activateController()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    public IIOMetadataController getDefaultController() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        return defaultController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   840
     * Returns {@code true} if there is a controller installed
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   841
     * for this {@code IIOMetadata} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   843
     * <p> The default implementation returns {@code true} if the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   844
     * {@code getController} method returns a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   845
     * non-{@code null} value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   847
     * @return {@code true} if a controller is installed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * @see #setController(IIOMetadataController)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * @see #getController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * @see #getDefaultController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * @see #activateController()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    public boolean hasController() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        return (getController() != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   860
     * Activates the installed {@code IIOMetadataController} for
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   861
     * this {@code IIOMetadata} object and returns the resulting
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   862
     * value.  When this method returns {@code true}, all values for this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   863
     * {@code IIOMetadata} object will be ready for the next write
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   864
     * operation.  If {@code false} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * returned, no settings in this object will have been disturbed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     * (<i>i.e.</i>, the user canceled the operation).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * <p> Ordinarily, the controller will be a GUI providing a user
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   869
     * interface for a subclass of {@code IIOMetadata} for a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * particular plug-in.  Controllers need not be GUIs, however.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   872
     * <p> The default implementation calls {@code getController}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   873
     * and the calls {@code activate} on the returned object if
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   874
     * {@code hasController} returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   876
     * @return {@code true} if the controller completed normally.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * @exception IllegalStateException if there is no controller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * currently installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * @see IIOMetadataController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * @see #setController(IIOMetadataController)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * @see #getController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * @see #getDefaultController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * @see #hasController
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    public boolean activateController() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        if (!hasController()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            throw new IllegalStateException("hasController() == false!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        return getController().activate(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
}