/* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001, 2002 The Apache Software Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 1999, International * Business Machines, Inc., http://www.apache.org. For more * information on the Apache Software Foundation, please see * . */ package com.sun.org.apache.xerces.internal.xni.parser; import com.sun.org.apache.xerces.internal.xni.XMLLocator; import com.sun.org.apache.xerces.internal.xni.XNIException; /** * A parsing exception. This exception is different from the standard * XNI exception in that it stores the location in the document (or * its entities) where the exception occurred. * * @author Andy Clark, IBM * * @version $Id: XMLParseException.java,v 1.4 2002/01/29 01:15:19 lehors Exp $ */ public class XMLParseException extends XNIException { // // Data // /** Public identifier. */ protected String fPublicId; /** literal System identifier. */ protected String fLiteralSystemId; /** expanded System identifier. */ protected String fExpandedSystemId; /** Base system identifier. */ protected String fBaseSystemId; /** Line number. */ protected int fLineNumber = -1; /** Column number. */ protected int fColumnNumber = -1; // // Constructors // /** Constructs a parse exception. */ public XMLParseException(XMLLocator locator, String message) { super(message); if (locator != null) { fPublicId = locator.getPublicId(); fLiteralSystemId = locator.getLiteralSystemId(); fExpandedSystemId = locator.getExpandedSystemId(); fBaseSystemId = locator.getBaseSystemId(); fLineNumber = locator.getLineNumber(); fColumnNumber = locator.getColumnNumber(); } } // (XMLLocator,String) /** Constructs a parse exception. */ public XMLParseException(XMLLocator locator, String message, Exception exception) { super(message, exception); fPublicId = locator.getPublicId(); fLiteralSystemId = locator.getLiteralSystemId(); fExpandedSystemId = locator.getExpandedSystemId(); fBaseSystemId = locator.getBaseSystemId(); fLineNumber = locator.getLineNumber(); fColumnNumber = locator.getColumnNumber(); } // (XMLLocator,String,Exception) // // Public methods // /** Returns the public identifier. */ public String getPublicId() { return fPublicId; } // getPublicId():String /** Returns the expanded system identifier. */ public String getExpandedSystemId() { return fExpandedSystemId; } // getExpandedSystemId():String /** Returns the literal system identifier. */ public String getLiteralSystemId() { return fLiteralSystemId; } // getLiteralSystemId():String /** Returns the base system identifier. */ public String getBaseSystemId() { return fBaseSystemId; } // getBaseSystemId():String /** Returns the line number. */ public int getLineNumber() { return fLineNumber; } // getLineNumber():int /** Returns the row number. */ public int getColumnNumber() { return fColumnNumber; } // getRowNumber():int // // Object methods // /** Returns a string representation of this object. */ public String toString() { StringBuffer str = new StringBuffer(); if (fPublicId != null) { str.append(fPublicId); } str.append(':'); if (fPublicId != null) { str.append(fPublicId); } str.append(':'); if (fLiteralSystemId != null) { str.append(fLiteralSystemId); } str.append(':'); if (fExpandedSystemId != null) { str.append(fExpandedSystemId); } str.append(':'); if (fBaseSystemId != null) { str.append(fBaseSystemId); } str.append(':'); str.append(fLineNumber); str.append(':'); str.append(fColumnNumber); str.append(':'); String message = getMessage(); if (message == null) { Exception exception = getException(); if (exception != null) { message = exception.getMessage(); } } if (message != null) { str.append(message); } return str.toString(); } // toString():String } // XMLParseException