View Javadoc
1   /*
2    * Copyright (c) 2000, 2001, 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  
48      /**
49       * The <code>Node</code> that led to the parsing error, or
50       * <code>null</code>.
51       */
52      protected Node offendingNode = null;
53  
54      /**
55       * Constructs an <code>IIOInvalidTreeException</code> with a
56       * message string and a reference to the <code>Node</code> that
57       * caused the parsing error.
58       *
59       * @param message a <code>String</code> containing the reason for
60       * the parsing failure.
61       * @param offendingNode the DOM <code>Node</code> that caused the
62       * exception, or <code>null</code>.
63       */
64      public IIOInvalidTreeException(String message, Node offendingNode) {
65          super(message);
66          this.offendingNode = offendingNode;
67      }
68  
69      /**
70       * Constructs an <code>IIOInvalidTreeException</code> with a
71       * message string, a reference to an exception that caused this
72       * exception, and a reference to the <code>Node</code> that caused
73       * the parsing error.
74       *
75       * @param message a <code>String</code> containing the reason for
76       * the parsing failure.
77       * @param cause the <code>Throwable</code> (<code>Error</code> or
78       * <code>Exception</code>) that caused this exception to occur,
79       * or <code>null</code>.
80       * @param offendingNode the DOM <code>Node</code> that caused the
81       * exception, or <code>null</code>.
82       */
83      public IIOInvalidTreeException(String message, Throwable cause,
84                                     Node offendingNode) {
85          super(message, cause);
86          this.offendingNode = offendingNode;
87      }
88  
89      /**
90       * Returns the <code>Node</code> that caused the error in parsing.
91       *
92       * @return the offending <code>Node</code>.
93       */
94      public Node getOffendingNode() {
95          return offendingNode;
96      }
97  }