1 /*
2  * reserved comment block
3  * DO NOT REMOVE OR ALTER!
4  */
5 /*
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the  "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 package com.sun.org.apache.xml.internal.serializer.dom3;
24 
25 import org.w3c.dom.DOMError;
26 import org.w3c.dom.DOMLocator;
27 
28 /**
29  * Implementation of the DOM Level 3 DOMError interface.
30  *
31  * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ERROR-Interfaces-DOMError'>DOMError Interface definition from Document Object Model (DOM) Level 3 Core Specification</a>.
32  *
33  * @xsl.usage internal
34  */
35 
36 final class DOMErrorImpl implements DOMError {
37 
38     /** private data members */
39 
40     // The DOMError Severity
41     private short fSeverity = DOMError.SEVERITY_WARNING;
42 
43     // The Error message
44     private String fMessage = null;
45 
46     //  A String indicating which related data is expected in relatedData.
47     private String fType;
48 
49     // The platform related exception
50     private Exception fException = null;
51 
52     //
53     private Object fRelatedData;
54 
55     // The location of the exception
56     private DOMLocatorImpl fLocation = new DOMLocatorImpl();
57 
58 
59     //
60     // Constructors
61     //
62 
63     /**
64      * Default constructor.
65      */
DOMErrorImpl()66     DOMErrorImpl () {
67     }
68 
69     /**
70      * @param severity
71      * @param message
72      * @param type
73      */
DOMErrorImpl(short severity, String message, String type)74     DOMErrorImpl(short severity, String message, String type) {
75         fSeverity = severity;
76         fMessage = message;
77         fType = type;
78     }
79 
80     /**
81      * @param severity
82      * @param message
83      * @param type
84      * @param exception
85      */
DOMErrorImpl(short severity, String message, String type, Exception exception)86     DOMErrorImpl(short severity, String message, String type,
87             Exception exception) {
88         fSeverity = severity;
89         fMessage = message;
90         fType = type;
91         fException = exception;
92     }
93 
94     /**
95      * @param severity
96      * @param message
97      * @param type
98      * @param exception
99      * @param relatedData
100      * @param location
101      */
DOMErrorImpl(short severity, String message, String type, Exception exception, Object relatedData, DOMLocatorImpl location)102     DOMErrorImpl(short severity, String message, String type,
103             Exception exception, Object relatedData, DOMLocatorImpl location) {
104         fSeverity = severity;
105         fMessage = message;
106         fType = type;
107         fException = exception;
108         fRelatedData = relatedData;
109         fLocation = location;
110     }
111 
112 
113     /**
114      * The severity of the error, either <code>SEVERITY_WARNING</code>,
115      * <code>SEVERITY_ERROR</code>, or <code>SEVERITY_FATAL_ERROR</code>.
116      *
117      * @return A short containing the DOMError severity
118      */
getSeverity()119     public short getSeverity() {
120         return fSeverity;
121     }
122 
123     /**
124      * The DOMError message string.
125      *
126      * @return String
127      */
getMessage()128     public String getMessage() {
129         return fMessage;
130     }
131 
132     /**
133      * The location of the DOMError.
134      *
135      * @return A DOMLocator object containing the DOMError location.
136      */
getLocation()137     public DOMLocator getLocation() {
138         return fLocation;
139     }
140 
141     /**
142      * The related platform dependent exception if any.
143      *
144      * @return A java.lang.Exception
145      */
getRelatedException()146     public Object getRelatedException(){
147         return fException;
148     }
149 
150     /**
151      * Returns a String indicating which related data is expected in relatedData.
152      *
153      * @return A String
154      */
getType()155     public String getType(){
156         return fType;
157     }
158 
159     /**
160      * The related DOMError.type dependent data if any.
161      *
162      * @return java.lang.Object
163      */
getRelatedData()164     public Object getRelatedData(){
165         return fRelatedData;
166     }
167 
reset()168     public void reset(){
169         fSeverity = DOMError.SEVERITY_WARNING;
170         fException = null;
171         fMessage = null;
172         fType = null;
173         fRelatedData = null;
174         fLocation = null;
175     }
176 
177 }// class DOMErrorImpl
178