Path: blob/master/src/java.desktop/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java
41153 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.imageio.metadata;2627import java.io.Serial;2829import javax.imageio.IIOException;3031import org.w3c.dom.Node;3233/**34* An {@code IIOInvalidTreeException} is thrown when an attempt35* by an {@code IIOMetadata} object to parse a tree of36* {@code IIOMetadataNode}s fails. The node that led to the37* parsing error may be stored. As with any parsing error, the actual38* error may occur at a different point that that where it is39* detected. The node returned by {@code getOffendingNode}40* should merely be considered as a clue to the actual nature of the41* problem.42*43* @see IIOMetadata#setFromTree44* @see IIOMetadata#mergeTree45* @see IIOMetadataNode46*47*/48public class IIOInvalidTreeException extends IIOException {4950/**51* Use serialVersionUID from JDK 9 for interoperability.52*/53@Serial54private static final long serialVersionUID = -1314083172544132777L;5556/**57* The {@code Node} that led to the parsing error, or58* {@code null}.59*/60@SuppressWarnings("serial") // Not statically typed as Serializable61protected Node offendingNode = null;6263/**64* Constructs an {@code IIOInvalidTreeException} with a65* message string and a reference to the {@code Node} that66* caused the parsing error.67*68* @param message a {@code String} containing the reason for69* the parsing failure.70* @param offendingNode the DOM {@code Node} that caused the71* exception, or {@code null}.72*/73public IIOInvalidTreeException(String message, Node offendingNode) {74super(message);75this.offendingNode = offendingNode;76}7778/**79* Constructs an {@code IIOInvalidTreeException} with a80* message string, a reference to an exception that caused this81* exception, and a reference to the {@code Node} that caused82* the parsing error.83*84* @param message a {@code String} containing the reason for85* the parsing failure.86* @param cause the {@code Throwable} ({@code Error} or87* {@code Exception}) that caused this exception to occur,88* or {@code null}.89* @param offendingNode the DOM {@code Node} that caused the90* exception, or {@code null}.91*/92public IIOInvalidTreeException(String message, Throwable cause,93Node offendingNode) {94super(message, cause);95this.offendingNode = offendingNode;96}9798/**99* Returns the {@code Node} that caused the error in parsing.100*101* @return the offending {@code Node}.102*/103public Node getOffendingNode() {104return offendingNode;105}106}107108109