|
1 /* |
|
2 * reserved comment block |
|
3 * DO NOT REMOVE OR ALTER! |
|
4 */ |
|
5 /* |
|
6 * Copyright 2001, 2002,2004 The Apache Software Foundation. |
|
7 * |
|
8 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
9 * you may not use this file except in compliance with the License. |
|
10 * You may obtain a copy of the License at |
|
11 * |
|
12 * http://www.apache.org/licenses/LICENSE-2.0 |
|
13 * |
|
14 * Unless required by applicable law or agreed to in writing, software |
|
15 * distributed under the License is distributed on an "AS IS" BASIS, |
|
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
17 * See the License for the specific language governing permissions and |
|
18 * limitations under the License. |
|
19 */ |
|
20 |
|
21 package com.sun.org.apache.xerces.internal.dom; |
|
22 |
|
23 import org.w3c.dom.DOMError; |
|
24 import org.w3c.dom.DOMLocator; |
|
25 import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException; |
|
26 |
|
27 |
|
28 /** |
|
29 * <code>DOMErrorImpl</code> is an implementation that describes an error. |
|
30 * <strong>Note:</strong> The error object that describes the error |
|
31 * might be reused by Xerces implementation, across multiple calls to the |
|
32 * handleEvent method on DOMErrorHandler interface. |
|
33 * |
|
34 * |
|
35 * <p>See also the <a href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010913'>Document Object Model (DOM) Level 3 Core Specification</a>. |
|
36 * |
|
37 * @xerces.internal |
|
38 * |
|
39 * @author Gopal Sharma, SUN Microsystems Inc. |
|
40 * @author Elena Litani, IBM |
|
41 * |
|
42 */ |
|
43 |
|
44 // REVISIT: the implementation of ErrorReporter. |
|
45 // we probably should not pass XMLParseException |
|
46 // |
|
47 |
|
48 public class DOMErrorImpl implements DOMError { |
|
49 |
|
50 // |
|
51 // Data |
|
52 // |
|
53 |
|
54 public short fSeverity = DOMError.SEVERITY_WARNING; |
|
55 public String fMessage = null; |
|
56 public DOMLocatorImpl fLocator = new DOMLocatorImpl(); |
|
57 public Exception fException = null; |
|
58 public String fType; |
|
59 public Object fRelatedData; |
|
60 |
|
61 |
|
62 |
|
63 // |
|
64 // Constructors |
|
65 // |
|
66 |
|
67 /** Default constructor. */ |
|
68 public DOMErrorImpl () { |
|
69 } |
|
70 |
|
71 /** Exctracts information from XMLParserException) */ |
|
72 public DOMErrorImpl (short severity, XMLParseException exception) { |
|
73 fSeverity = severity; |
|
74 fException = exception; |
|
75 fLocator = createDOMLocator (exception); |
|
76 } |
|
77 |
|
78 /** |
|
79 * The severity of the error, either <code>SEVERITY_WARNING</code>, |
|
80 * <code>SEVERITY_ERROR</code>, or <code>SEVERITY_FATAL_ERROR</code>. |
|
81 */ |
|
82 |
|
83 public short getSeverity() { |
|
84 return fSeverity; |
|
85 } |
|
86 |
|
87 /** |
|
88 * An implementation specific string describing the error that occured. |
|
89 */ |
|
90 |
|
91 public String getMessage() { |
|
92 return fMessage; |
|
93 } |
|
94 |
|
95 /** |
|
96 * The location of the error. |
|
97 */ |
|
98 |
|
99 public DOMLocator getLocation() { |
|
100 return fLocator; |
|
101 } |
|
102 |
|
103 // method to get the DOMLocator Object |
|
104 private DOMLocatorImpl createDOMLocator(XMLParseException exception) { |
|
105 // assuming DOMLocator wants the *expanded*, not the literal, URI of the doc... - neilg |
|
106 return new DOMLocatorImpl(exception.getLineNumber(), |
|
107 exception.getColumnNumber(), |
|
108 exception.getCharacterOffset(), |
|
109 exception.getExpandedSystemId()); |
|
110 } // createDOMLocator() |
|
111 |
|
112 |
|
113 /** |
|
114 * The related platform dependent exception if any.exception is a reserved |
|
115 * word, we need to rename it.Change to "relatedException". (F2F 26 Sep |
|
116 * 2001) |
|
117 */ |
|
118 public Object getRelatedException(){ |
|
119 return fException; |
|
120 } |
|
121 |
|
122 public void reset(){ |
|
123 fSeverity = DOMError.SEVERITY_WARNING; |
|
124 fException = null; |
|
125 } |
|
126 |
|
127 public String getType(){ |
|
128 return fType; |
|
129 } |
|
130 |
|
131 public Object getRelatedData(){ |
|
132 return fRelatedData; |
|
133 } |
|
134 |
|
135 |
|
136 }// class DOMErrorImpl |