1. /*
  2. * @(#)IIOInvalidTreeException.java 1.16 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.imageio.metadata;
  8. import javax.imageio.IIOException;
  9. import org.w3c.dom.Node;
  10. /**
  11. * An <code>IIOInvalidTreeException</code> is thrown when an attempt
  12. * by an <code>IIOMetadata</code> object to parse a tree of
  13. * <code>IIOMetadataNode</code>s fails. The node that led to the
  14. * parsing error may be stored. As with any parsing error, the actual
  15. * error may occur at a different point that that where it is
  16. * detected. The node returned by <code>getOffendingNode</code>
  17. * should merely be considered as a clue to the actual nature of the
  18. * problem.
  19. *
  20. * @see IIOMetadata#setFromTree
  21. * @see IIOMetadata#mergeTree
  22. * @see IIOMetadataNode
  23. *
  24. * @version 0.5
  25. */
  26. public class IIOInvalidTreeException extends IIOException {
  27. /**
  28. * The <code>Node</code> that led to the parsing error, or
  29. * <code>null</code>.
  30. */
  31. protected Node offendingNode = null;
  32. /**
  33. * Constructs an <code>IIOInvalidTreeException</code> with a
  34. * message string and a reference to the <code>Node</code> that
  35. * caused the parsing error.
  36. *
  37. * @param message a <code>String</code> containing the reason for
  38. * the parsing failure.
  39. * @param offendingNode the DOM <code>Node</code> that caused the
  40. * exception, or <code>null</code>.
  41. */
  42. public IIOInvalidTreeException(String message, Node offendingNode) {
  43. super(message);
  44. this.offendingNode = offendingNode;
  45. }
  46. /**
  47. * Constructs an <code>IIOInvalidTreeException</code> with a
  48. * message string, a reference to an exception that caused this
  49. * exception, and a reference to the <code>Node</code> that caused
  50. * the parsing error.
  51. *
  52. * @param message a <code>String</code> containing the reason for
  53. * the parsing failure.
  54. * @param cause the <code>Throwable</code> (<code>Error</code> or
  55. * <code>Exception</code>) that caused this exception to occur,
  56. * or <code>null</code>.
  57. * @param offendingNode the DOM <code>Node</code> that caused the
  58. * exception, or <code>null</code>.
  59. */
  60. public IIOInvalidTreeException(String message, Throwable cause,
  61. Node offendingNode) {
  62. super(message, cause);
  63. this.offendingNode = offendingNode;
  64. }
  65. /**
  66. * Returns the <code>Node</code> that caused the error in parsing.
  67. *
  68. * @return the offending <code>Node</code>.
  69. */
  70. public Node getOffendingNode() {
  71. return offendingNode;
  72. }
  73. }