Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / gnu / xml / dom / DomDOMException.java
blobcf93fcf9749229b69c385fff27b7e49647e1b37d
1 /* DomDOMException.java --
2 Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package gnu.xml.dom;
40 import org.w3c.dom.DOMException;
41 import org.w3c.dom.Node;
43 /**
44 * <p> DOMException implementation. The version that
45 * is provided by the W3C is abstract, so it can't be instantiated.
47 * <p> This also provides a bit more information about the error
48 * that is being reported, in terms of the relevant DOM structures
49 * and data.
51 * @author David Brownell
53 public class DomDOMException
54 extends DOMException
57 /** @serial Data that caused an error to be reported */
58 private String data;
60 /** @serial Node associated with the error. */
61 private Node node;
63 /** @serial Data associated with the error. */
64 private int value;
66 /**
67 * Constructs an exception, with the diagnostic message
68 * corresponding to the specified code.
70 public DomDOMException(short code)
72 super(code, diagnostic(code));
75 /**
76 * Constructs an exception, with the diagnostic message
77 * corresponding to the specified code and additional
78 * information as provided.
80 public DomDOMException(short code, String data, Node node, int value)
82 super(code, diagnostic(code));
83 this.data = data;
84 this.node = node;
85 this.value = value;
88 /** Returns the node to which the diagnotic applies, or null. */
89 final public Node getNode()
91 return node;
94 /** Returns data to which the diagnotic applies, or null. */
95 final public String getData()
97 return data;
100 /** Returns data to which the diagnotic applies, or null. */
101 final public int getValue()
103 return value;
107 * Returns a diagnostic message that may be slightly more useful
108 * than the generic one, where possible.
110 public String getMessage()
112 String retval = super.getMessage();
114 if (data != null)
116 retval += "\nMore Information: " + data;
118 if (value != 0)
120 retval += "\nNumber: " + value;
122 if (node != null)
124 retval += "\nNode Name: " + node.getNodeName();
126 return retval;
129 // these strings should be localizable.
131 private static String diagnostic(short code)
133 switch (code)
135 // DOM L1:
136 case INDEX_SIZE_ERR:
137 return "An index or size is out of range.";
138 case DOMSTRING_SIZE_ERR:
139 return "A string is too big.";
140 case HIERARCHY_REQUEST_ERR:
141 return "The node doesn't belong here.";
142 case WRONG_DOCUMENT_ERR:
143 return "The node belongs in another document.";
144 case INVALID_CHARACTER_ERR:
145 return "That character is not permitted.";
146 case NO_DATA_ALLOWED_ERR:
147 return "This node does not permit data.";
148 case NO_MODIFICATION_ALLOWED_ERR:
149 return "No changes are allowed.";
150 case NOT_FOUND_ERR:
151 return "The node was not found in that context.";
152 case NOT_SUPPORTED_ERR:
153 return "That object is not supported.";
154 case INUSE_ATTRIBUTE_ERR:
155 return "The attribute belongs to a different element.";
157 // DOM L2:
158 case INVALID_STATE_ERR:
159 return "The object is not usable.";
160 case SYNTAX_ERR:
161 return "An illegal string was provided.";
162 case INVALID_MODIFICATION_ERR:
163 return "An object's type may not be changed.";
164 case NAMESPACE_ERR:
165 return "The operation violates XML Namespaces.";
166 case INVALID_ACCESS_ERR:
167 return "Parameter or operation isn't supported by this node.";
168 case TYPE_MISMATCH_ERR:
169 return "The type of the argument is incompatible with the expected type.";
171 return "Reserved exception number: " + code;