KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > DOMErrorImpl


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.dom;
18
19 import org.w3c.dom.DOMError JavaDoc;
20 import org.w3c.dom.DOMLocator JavaDoc;
21 import org.apache.xerces.xni.parser.XMLParseException;
22
23
24 /**
25  * <code>DOMErrorImpl</code> is an implementation that describes an error.
26  * <strong>Note:</strong> The error object that describes the error
27  * might be reused by Xerces implementation, across multiple calls to the
28  * handleEvent method on DOMErrorHandler interface.
29  *
30  *
31  * <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>.
32  *
33  * @xerces.internal
34  *
35  * @author Gopal Sharma, SUN Microsystems Inc.
36  * @author Elena Litani, IBM
37  *
38  * @version $Id: DOMErrorImpl.java,v 1.14 2005/05/02 22:02:22 mrglavas Exp $
39  */

40
41 // REVISIT: the implementation of ErrorReporter.
42
// we probably should not pass XMLParseException
43
//
44

45 public class DOMErrorImpl implements DOMError JavaDoc {
46
47     //
48
// Data
49
//
50

51     public short fSeverity = DOMError.SEVERITY_WARNING;
52     public String JavaDoc fMessage = null;
53     public DOMLocatorImpl fLocator = new DOMLocatorImpl();
54     public Exception JavaDoc fException = null;
55     public String JavaDoc fType;
56     public Object JavaDoc fRelatedData;
57    
58
59
60     //
61
// Constructors
62
//
63

64     /** Default constructor. */
65     public DOMErrorImpl () {
66     }
67
68     /** Exctracts information from XMLParserException) */
69     public DOMErrorImpl (short severity, XMLParseException exception) {
70         fSeverity = severity;
71         fException = exception;
72         fLocator = createDOMLocator (exception);
73     }
74
75     /**
76      * The severity of the error, either <code>SEVERITY_WARNING</code>,
77      * <code>SEVERITY_ERROR</code>, or <code>SEVERITY_FATAL_ERROR</code>.
78      */

79
80     public short getSeverity() {
81         return fSeverity;
82     }
83
84     /**
85      * An implementation specific string describing the error that occured.
86      */

87
88     public String JavaDoc getMessage() {
89         return fMessage;
90     }
91
92     /**
93      * The location of the error.
94      */

95
96     public DOMLocator JavaDoc getLocation() {
97         return fLocator;
98     }
99
100     // method to get the DOMLocator Object
101
private DOMLocatorImpl createDOMLocator(XMLParseException exception) {
102         // assuming DOMLocator wants the *expanded*, not the literal, URI of the doc... - neilg
103
return new DOMLocatorImpl(exception.getLineNumber(),
104                                   exception.getColumnNumber(),
105                                   exception.getCharacterOffset(),
106                                   exception.getExpandedSystemId());
107     } // createDOMLocator()
108

109
110     /**
111      * The related platform dependent exception if any.exception is a reserved
112      * word, we need to rename it.Change to "relatedException". (F2F 26 Sep
113      * 2001)
114      */

115     public Object JavaDoc getRelatedException(){
116         return fException;
117     }
118
119     public void reset(){
120         fSeverity = DOMError.SEVERITY_WARNING;
121         fException = null;
122     }
123     
124     public String JavaDoc getType(){
125         return fType;
126     }
127     
128     public Object JavaDoc getRelatedData(){
129         return fRelatedData;
130     }
131
132
133 }// class DOMErrorImpl
134
Popular Tags