001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 /*
019 * $Id: DOMErrorImpl.java 1225426 2011-12-29 04:13:08Z mrglavas $
020 */
021
022 package org.apache.xml.serializer.dom3;
023
024 import org.w3c.dom.DOMError;
025 import org.w3c.dom.DOMLocator;
026
027 /**
028 * Implementation of the DOM Level 3 DOMError interface.
029 *
030 * <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>.
031 *
032 * @xsl.usage internal
033 */
034
035 final class DOMErrorImpl implements DOMError {
036
037 /** private data members */
038
039 // The DOMError Severity
040 private short fSeverity = DOMError.SEVERITY_WARNING;
041
042 // The Error message
043 private String fMessage = null;
044
045 // A String indicating which related data is expected in relatedData.
046 private String fType;
047
048 // The platform related exception
049 private Exception fException = null;
050
051 //
052 private Object fRelatedData;
053
054 // The location of the exception
055 private DOMLocatorImpl fLocation = new DOMLocatorImpl();
056
057
058 //
059 // Constructors
060 //
061
062 /**
063 * Default constructor.
064 */
065 DOMErrorImpl () {
066 }
067
068 /**
069 * @param severity
070 * @param message
071 * @param type
072 */
073 DOMErrorImpl(short severity, String message, String type) {
074 fSeverity = severity;
075 fMessage = message;
076 fType = type;
077 }
078
079 /**
080 * @param severity
081 * @param message
082 * @param type
083 * @param exception
084 */
085 DOMErrorImpl(short severity, String message, String type,
086 Exception exception) {
087 fSeverity = severity;
088 fMessage = message;
089 fType = type;
090 fException = exception;
091 }
092
093 /**
094 * @param severity
095 * @param message
096 * @param type
097 * @param exception
098 * @param relatedData
099 * @param location
100 */
101 DOMErrorImpl(short severity, String message, String type,
102 Exception exception, Object relatedData, DOMLocatorImpl location) {
103 fSeverity = severity;
104 fMessage = message;
105 fType = type;
106 fException = exception;
107 fRelatedData = relatedData;
108 fLocation = location;
109 }
110
111
112 /**
113 * The severity of the error, either <code>SEVERITY_WARNING</code>,
114 * <code>SEVERITY_ERROR</code>, or <code>SEVERITY_FATAL_ERROR</code>.
115 *
116 * @return A short containing the DOMError severity
117 */
118 public short getSeverity() {
119 return fSeverity;
120 }
121
122 /**
123 * The DOMError message string.
124 *
125 * @return String
126 */
127 public String getMessage() {
128 return fMessage;
129 }
130
131 /**
132 * The location of the DOMError.
133 *
134 * @return A DOMLocator object containing the DOMError location.
135 */
136 public DOMLocator getLocation() {
137 return fLocation;
138 }
139
140 /**
141 * The related platform dependent exception if any.
142 *
143 * @return A java.lang.Exception
144 */
145 public Object getRelatedException(){
146 return fException;
147 }
148
149 /**
150 * Returns a String indicating which related data is expected in relatedData.
151 *
152 * @return A String
153 */
154 public String getType(){
155 return fType;
156 }
157
158 /**
159 * The related DOMError.type dependent data if any.
160 *
161 * @return java.lang.Object
162 */
163 public Object getRelatedData(){
164 return fRelatedData;
165 }
166
167 public void reset(){
168 fSeverity = DOMError.SEVERITY_WARNING;
169 fException = null;
170 fMessage = null;
171 fType = null;
172 fRelatedData = null;
173 fLocation = null;
174 }
175
176 }// class DOMErrorImpl