OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [xml/] [dom/] [DomDOMException.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* DomDOMException.java --
2
   Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
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.
10
 
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.
15
 
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.
20
 
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.
25
 
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. */
37
 
38
package gnu.xml.dom;
39
 
40
import org.w3c.dom.DOMException;
41
import org.w3c.dom.Node;
42
 
43
/**
44
 * <p> DOMException implementation.   The version that
45
 * is provided by the W3C is abstract, so it can't be instantiated.
46
 *
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.
50
 *
51
 * @author David Brownell
52
 */
53
public class DomDOMException
54
  extends DOMException
55
{
56
 
57
  /** @serial Data that caused an error to be reported */
58
  private String data;
59
 
60
  /** @serial Node associated with the error. */
61
  private Node node;
62
 
63
  /** @serial Data associated with the error. */
64
  private int value;
65
 
66
  /**
67
   * Constructs an exception, with the diagnostic message
68
   * corresponding to the specified code.
69
   */
70
  public DomDOMException(short code)
71
  {
72
    super(code, diagnostic(code));
73
  }
74
 
75
  /**
76
   * Constructs an exception, with the diagnostic message
77
   * corresponding to the specified code and additional
78
   * information as provided.
79
   */
80
  public DomDOMException(short code, String data, Node node, int value)
81
  {
82
    super(code, diagnostic(code));
83
    this.data = data;
84
    this.node = node;
85
    this.value = value;
86
  }
87
 
88
  /** Returns the node to which the diagnotic applies, or null. */
89
  final public Node getNode()
90
  {
91
    return node;
92
  }
93
 
94
  /** Returns data to which the diagnotic applies, or null. */
95
  final public String getData()
96
  {
97
    return data;
98
  }
99
 
100
  /** Returns data to which the diagnotic applies, or null. */
101
  final public int getValue()
102
  {
103
    return value;
104
  }
105
 
106
  /**
107
   * Returns a diagnostic message that may be slightly more useful
108
   * than the generic one, where possible.
109
   */
110
  public String getMessage()
111
  {
112
    String retval = super.getMessage();
113
 
114
    if (data != null)
115
      {
116
        retval += "\nMore Information: " + data;
117
      }
118
    if (value != 0)
119
      {
120
        retval += "\nNumber: " + value;
121
      }
122
    if (node != null)
123
      {
124
        retval += "\nNode Name: " + node.getNodeName();
125
      }
126
    return retval;
127
  }
128
 
129
  // these strings should be localizable.
130
 
131
  private static String diagnostic(short code)
132
  {
133
    switch (code)
134
      {
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.";
156
 
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.";
170
      }
171
    return "Reserved exception number: " + code;
172
  }
173
 
174
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.