net.sourceforge.htmlunit.xerces.dom.DOMErrorImpl Maven / Gradle / Ivy
Show all versions of neko-htmlunit Show documentation
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sourceforge.htmlunit.xerces.dom;
import org.w3c.dom.DOMError;
import org.w3c.dom.DOMLocator;
import net.sourceforge.htmlunit.xerces.xni.parser.XMLParseException;
/**
* DOMErrorImpl
is an implementation that describes an error.
* Note: The error object that describes the error
* might be reused by Xerces implementation, across multiple calls to the
* handleEvent method on DOMErrorHandler interface.
*
* See also the Document Object Model (DOM) Level 3 Core Specification.
*
*
* @author Gopal Sharma, SUN Microsystems Inc.
* @author Elena Litani, IBM
*/
// REVISIT: the implementation of ErrorReporter.
// we probably should not pass XMLParseException
//
public class DOMErrorImpl implements DOMError {
public short fSeverity = DOMError.SEVERITY_WARNING;
public final String fMessage = null;
public DOMLocatorImpl fLocator = new DOMLocatorImpl();
public Exception fException = null;
public String fType;
public Object fRelatedData;
/** Default constructor. */
public DOMErrorImpl () {
}
/**
* Extracts information from XMLParserException
* @param severity the severity
* @param exception the exception
*/
public DOMErrorImpl (short severity, XMLParseException exception) {
fSeverity = severity;
fException = exception;
fLocator = createDOMLocator (exception);
}
/**
* {@inheritDoc}
*
* The severity of the error, either SEVERITY_WARNING
,
* SEVERITY_ERROR
, or SEVERITY_FATAL_ERROR
.
*/
@Override
public short getSeverity() {
return fSeverity;
}
/**
* {@inheritDoc}
*
* An implementation specific string describing the error that occured.
*/
@Override
public String getMessage() {
return fMessage;
}
/**
* {@inheritDoc}
*
* The location of the error.
*/
@Override
public DOMLocator getLocation() {
return fLocator;
}
// method to get the DOMLocator Object
private DOMLocatorImpl createDOMLocator(XMLParseException exception) {
// assuming DOMLocator wants the *expanded*, not the literal, URI of the doc... - neilg
return new DOMLocatorImpl(exception.getLineNumber(),
exception.getColumnNumber(),
exception.getCharacterOffset(),
exception.getExpandedSystemId());
}
/**
* {@inheritDoc}
*
* The related platform dependent exception if any.exception is a reserved
* word, we need to rename it.Change to "relatedException". (F2F 26 Sep
* 2001)
*/
@Override
public Object getRelatedException(){
return fException;
}
public void reset(){
fSeverity = DOMError.SEVERITY_WARNING;
fException = null;
}
@Override
public String getType(){
return fType;
}
@Override
public Object getRelatedData(){
return fRelatedData;
}
}