1 /* 2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.imageio.metadata; 27 28 import javax.imageio.IIOException; 29 import org.w3c.dom.Node; 30 31 /** 32 * An <code>IIOInvalidTreeException</code> is thrown when an attempt 33 * by an <code>IIOMetadata</code> object to parse a tree of 34 * <code>IIOMetadataNode</code>s fails. The node that led to the 35 * parsing error may be stored. As with any parsing error, the actual 36 * error may occur at a different point that that where it is 37 * detected. The node returned by <code>getOffendingNode</code> 38 * should merely be considered as a clue to the actual nature of the 39 * problem. 40 * 41 * @see IIOMetadata#setFromTree 42 * @see IIOMetadata#mergeTree 43 * @see IIOMetadataNode 44 * 45 */ 46 public class IIOInvalidTreeException extends IIOException { 47 private static final long serialVersionUID = -1314083172544132777L; 48 49 /** 50 * The <code>Node</code> that led to the parsing error, or 51 * <code>null</code>. 52 */ 53 protected Node offendingNode = null; 54 55 /** 56 * Constructs an <code>IIOInvalidTreeException</code> with a 57 * message string and a reference to the <code>Node</code> that 58 * caused the parsing error. 59 * 60 * @param message a <code>String</code> containing the reason for 61 * the parsing failure. 62 * @param offendingNode the DOM <code>Node</code> that caused the 63 * exception, or <code>null</code>. 64 */ 65 public IIOInvalidTreeException(String message, Node offendingNode) { 66 super(message); 67 this.offendingNode = offendingNode; 68 } 69 70 /** 71 * Constructs an <code>IIOInvalidTreeException</code> with a 72 * message string, a reference to an exception that caused this 73 * exception, and a reference to the <code>Node</code> that caused 74 * the parsing error. 75 * 76 * @param message a <code>String</code> containing the reason for 77 * the parsing failure. 78 * @param cause the <code>Throwable</code> (<code>Error</code> or 79 * <code>Exception</code>) that caused this exception to occur, 80 * or <code>null</code>. 81 * @param offendingNode the DOM <code>Node</code> that caused the 82 * exception, or <code>null</code>. 83 */ 84 public IIOInvalidTreeException(String message, Throwable cause, 85 Node offendingNode) { 86 super(message, cause); 87 this.offendingNode = offendingNode; 88 } 89 90 /** 91 * Returns the <code>Node</code> that caused the error in parsing. 92 * 93 * @return the offending <code>Node</code>. 94 */ 95 public Node getOffendingNode() { 96 return offendingNode; 97 } 98 }