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