You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rpc-dev@xml.apache.org by ha...@apache.org on 2001/11/06 19:33:40 UTC
cvs commit: xml-rpc/src/java/org/xml/sax AttributeList.java DTDHandler.java DocumentHandler.java EntityResolver.java ErrorHandler.java HandlerBase.java InputSource.java Locator.java Parser.java SAXException.java SAXParseException.java
hannes 01/11/06 10:33:40
Added: src/java/org/xml/sax AttributeList.java DTDHandler.java
DocumentHandler.java EntityResolver.java
ErrorHandler.java HandlerBase.java InputSource.java
Locator.java Parser.java SAXException.java
SAXParseException.java
Log:
Checked in SAX 1.0 classes used by XML-RPC
Revision Changes Path
1.1 xml-rpc/src/java/org/xml/sax/AttributeList.java
Index: AttributeList.java
===================================================================
// SAX Attribute List Interface.
// No warranty; no copyright -- use this as you will.
// $Id: AttributeList.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Interface for an element's attribute specifications.
*
* <p>The SAX parser implements this interface and passes an instance
* to the SAX application as the second argument of each startElement
* event.</p>
*
* <p>The instance provided will return valid results only during the
* scope of the startElement invocation (to save it for future
* use, the application must make a copy: the AttributeListImpl
* helper class provides a convenient constructor for doing so).</p>
*
* <p>An AttributeList includes only attributes that have been
* specified or defaulted: #IMPLIED attributes will not be included.</p>
*
* <p>There are two ways for the SAX application to obtain information
* from the AttributeList. First, it can iterate through the entire
* list:</p>
*
* <pre>
* public void startElement (String name, AttributeList atts) {
* for (int i = 0; i < atts.getLength(); i++) {
* String name = atts.getName(i);
* String type = atts.getType(i);
* String value = atts.getValue(i);
* [...]
* }
* }
* </pre>
*
* <p>(Note that the result of getLength() will be zero if there
* are no attributes.)
*
* <p>As an alternative, the application can request the value or
* type of specific attributes:</p>
*
* <pre>
* public void startElement (String name, AttributeList atts) {
* String identifier = atts.getValue("id");
* String label = atts.getValue("label");
* [...]
* }
* </pre>
*
* <p>The AttributeListImpl helper class provides a convenience
* implementation for use by parser or application writers.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.DocumentHandler#startElement
* @see org.xml.sax.helpers.AttributeListImpl
*/
public interface AttributeList {
/**
* Return the number of attributes in this list.
*
* <p>The SAX parser may provide attributes in any
* arbitrary order, regardless of the order in which they were
* declared or specified. The number of attributes may be
* zero.</p>
*
* @return The number of attributes in the list.
*/
public abstract int getLength ();
/**
* Return the name of an attribute in this list (by position).
*
* <p>The names must be unique: the SAX parser shall not include the
* same attribute twice. Attributes without values (those declared
* #IMPLIED without a value specified in the start tag) will be
* omitted from the list.</p>
*
* <p>If the attribute name has a namespace prefix, the prefix
* will still be attached.</p>
*
* @param i The index of the attribute in the list (starting at 0).
* @return The name of the indexed attribute, or null
* if the index is out of range.
* @see #getLength
*/
public abstract String getName (int i);
/**
* Return the type of an attribute in the list (by position).
*
* <p>The attribute type is one of the strings "CDATA", "ID",
* "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
* or "NOTATION" (always in upper case).</p>
*
* <p>If the parser has not read a declaration for the attribute,
* or if the parser does not report attribute types, then it must
* return the value "CDATA" as stated in the XML 1.0 Recommentation
* (clause 3.3.3, "Attribute-Value Normalization").</p>
*
* <p>For an enumerated attribute that is not a notation, the
* parser will report the type as "NMTOKEN".</p>
*
* @param i The index of the attribute in the list (starting at 0).
* @return The attribute type as a string, or
* null if the index is out of range.
* @see #getLength
* @see #getType(java.lang.String)
*/
public abstract String getType (int i);
/**
* Return the value of an attribute in the list (by position).
*
* <p>If the attribute value is a list of tokens (IDREFS,
* ENTITIES, or NMTOKENS), the tokens will be concatenated
* into a single string separated by whitespace.</p>
*
* @param i The index of the attribute in the list (starting at 0).
* @return The attribute value as a string, or
* null if the index is out of range.
* @see #getLength
* @see #getValue(java.lang.String)
*/
public abstract String getValue (int i);
/**
* Return the type of an attribute in the list (by name).
*
* <p>The return value is the same as the return value for
* getType(int).</p>
*
* <p>If the attribute name has a namespace prefix in the document,
* the application must include the prefix here.</p>
*
* @param name The name of the attribute.
* @return The attribute type as a string, or null if no
* such attribute exists.
* @see #getType(int)
*/
public abstract String getType (String name);
/**
* Return the value of an attribute in the list (by name).
*
* <p>The return value is the same as the return value for
* getValue(int).</p>
*
* <p>If the attribute name has a namespace prefix in the document,
* the application must include the prefix here.</p>
*
* @param i The index of the attribute in the list.
* @return The attribute value as a string, or null if
* no such attribute exists.
* @see #getValue(int)
*/
public abstract String getValue (String name);
}
1.1 xml-rpc/src/java/org/xml/sax/DTDHandler.java
Index: DTDHandler.java
===================================================================
// SAX DTD handler.
// No warranty; no copyright -- use this as you will.
// $Id: DTDHandler.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Receive notification of basic DTD-related events.
*
* <p>If a SAX application needs information about notations and
* unparsed entities, then the application implements this
* interface and registers an instance with the SAX parser using
* the parser's setDTDHandler method. The parser uses the
* instance to report notation and unparsed entity declarations to
* the application.</p>
*
* <p>The SAX parser may report these events in any order, regardless
* of the order in which the notations and unparsed entities were
* declared; however, all DTD events must be reported after the
* document handler's startDocument event, and before the first
* startElement event.</p>
*
* <p>It is up to the application to store the information for
* future use (perhaps in a hash table or object tree).
* If the application encounters attributes of type "NOTATION",
* "ENTITY", or "ENTITIES", it can use the information that it
* obtained through this interface to find the entity and/or
* notation corresponding with the attribute value.</p>
*
* <p>The HandlerBase class provides a default implementation
* of this interface, which simply ignores the events.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.Parser#setDTDHandler
* @see org.xml.sax.HandlerBase
*/
public interface DTDHandler {
/**
* Receive notification of a notation declaration event.
*
* <p>It is up to the application to record the notation for later
* reference, if necessary.</p>
*
* <p>If a system identifier is present, and it is a URL, the SAX
* parser must resolve it fully before passing it to the
* application.</p>
*
* @param name The notation name.
* @param publicId The notation's public identifier, or null if
* none was given.
* @param systemId The notation's system identifier, or null if
* none was given.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #unparsedEntityDecl
* @see org.xml.sax.AttributeList
*/
public abstract void notationDecl (String name,
String publicId,
String systemId)
throws SAXException;
/**
* Receive notification of an unparsed entity declaration event.
*
* <p>Note that the notation name corresponds to a notation
* reported by the notationDecl() event. It is up to the
* application to record the entity for later reference, if
* necessary.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @param name The unparsed entity's name.
* @param publicId The entity's public identifier, or null if none
* was given.
* @param systemId The entity's system identifier (it must always
* have one).
* @param notation name The name of the associated notation.
* @see #notationDecl
* @see org.xml.sax.AttributeList
*/
public abstract void unparsedEntityDecl (String name,
String publicId,
String systemId,
String notationName)
throws SAXException;
}
1.1 xml-rpc/src/java/org/xml/sax/DocumentHandler.java
Index: DocumentHandler.java
===================================================================
// SAX document handler.
// No warranty; no copyright -- use this as you will.
// $Id: DocumentHandler.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Receive notification of general document events.
*
* <p>This is the main interface that most SAX applications
* implement: if the application needs to be informed of basic parsing
* events, it implements this interface and registers an instance with
* the SAX parser using the setDocumentHandler method. The parser
* uses the instance to report basic document-related events like
* the start and end of elements and character data.</p>
*
* <p>The order of events in this interface is very important, and
* mirrors the order of information in the document itself. For
* example, all of an element's content (character data, processing
* instructions, and/or subelements) will appear, in order, between
* the startElement event and the corresponding endElement event.</p>
*
* <p>Application writers who do not want to implement the entire
* interface can derive a class from HandlerBase, which implements
* the default functionality; parser writers can instantiate
* HandlerBase to obtain a default handler. The application can find
* the location of any document event using the Locator interface
* supplied by the Parser through the setDocumentLocator method.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.Parser#setDocumentHandler
* @see org.xml.sax.Locator
* @see org.xml.sax.HandlerBase
*/
public interface DocumentHandler {
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.</p>
*
* @param locator An object that can return the location of
* any SAX document event.
* @see org.xml.sax.Locator
*/
public abstract void setDocumentLocator (Locator locator);
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
public abstract void startDocument ()
throws SAXException;
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
public abstract void endDocument ()
throws SAXException;
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param atts The attributes attached to the element, if any.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see org.xml.sax.AttributeList
*/
public abstract void startElement (String name, AttributeList atts)
throws SAXException;
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
public abstract void endElement (String name)
throws SAXException;
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
public abstract void characters (char ch[], int start, int length)
throws SAXException;
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
public abstract void ignorableWhitespace (char ch[], int start, int length)
throws SAXException;
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
public abstract void processingInstruction (String target, String data)
throws SAXException;
}
1.1 xml-rpc/src/java/org/xml/sax/EntityResolver.java
Index: EntityResolver.java
===================================================================
// SAX entity resolver.
// No warranty; no copyright -- use this as you will.
// $Id: EntityResolver.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
import java.io.IOException;
/**
* Basic interface for resolving entities.
*
* <p>If a SAX application needs to implement customized handling
* for external entities, it must implement this interface and
* register an instance with the SAX parser using the parser's
* setEntityResolver method.</p>
*
* <p>The parser will then allow the application to intercept any
* external entities (including the external DTD subset and external
* parameter entities, if any) before including them.</p>
*
* <p>Many SAX applications will not need to implement this interface,
* but it will be especially useful for applications that build
* XML documents from databases or other specialised input sources,
* or for applications that use URI types other than URLs.</p>
*
* <p>The following resolver would provide the application
* with a special character stream for the entity with the system
* identifier "http://www.myhost.com/today":</p>
*
* <pre>
* import org.xml.sax.EntityResolver;
* import org.xml.sax.InputSource;
*
* public class MyResolver implements EntityResolver {
* public InputSource resolveEntity (String publicId, String systemId)
* {
* if (systemId.equals("http://www.myhost.com/today")) {
* // return a special input source
* MyReader reader = new MyReader();
* return new InputSource(reader);
* } else {
* // use the default behaviour
* return null;
* }
* }
* }
* </pre>
*
* <p>The application can also use this interface to redirect system
* identifiers to local URIs or to look up replacements in a catalog
* (possibly by using the public identifier).</p>
*
* <p>The HandlerBase class implements the default behaviour for
* this interface, which is simply always to return null (to request
* that the parser use the default system identifier).</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.Parser#setEntityResolver
* @see org.xml.sax.InputSource
* @see org.xml.sax.HandlerBase
*/
public interface EntityResolver {
/**
* Allow the application to resolve external entities.
*
* <p>The Parser will call this method before opening any external
* entity except the top-level document entity (including the
* external DTD subset, external entities referenced within the
* DTD, and external entities referenced within the document
* element): the application may request that the parser resolve
* the entity itself, that it use an alternative URI, or that it
* use an entirely different input source.</p>
*
* <p>Application writers can use this method to redirect external
* system identifiers to secure and/or local URIs, to look up
* public identifiers in a catalogue, or to read an entity from a
* database or other input source (including, for example, a dialog
* box).</p>
*
* <p>If the system identifier is a URL, the SAX parser must
* resolve it fully before reporting it to the application.</p>
*
* @param publicId The public identifier of the external entity
* being referenced, or null if none was supplied.
* @param systemId The system identifier of the external entity
* being referenced.
* @return An InputSource object describing the new input source,
* or null to request that the parser open a regular
* URI connection to the system identifier.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception java.io.IOException A Java-specific IO exception,
* possibly the result of creating a new InputStream
* or Reader for the InputSource.
* @see org.xml.sax.InputSource
*/
public abstract InputSource resolveEntity (String publicId,
String systemId)
throws SAXException, IOException;
}
1.1 xml-rpc/src/java/org/xml/sax/ErrorHandler.java
Index: ErrorHandler.java
===================================================================
// SAX error handler.
// No warranty; no copyright -- use this as you will.
// $Id: ErrorHandler.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Basic interface for SAX error handlers.
*
* <p>If a SAX application needs to implement customized error
* handling, it must implement this interface and then register an
* instance with the SAX parser using the parser's setErrorHandler
* method. The parser will then report all errors and warnings
* through this interface.</p>
*
* <p> The parser shall use this interface instead of throwing an
* exception: it is up to the application whether to throw an
* exception for different types of errors and warnings. Note,
* however, that there is no requirement that the parser continue to
* provide useful information after a call to fatalError (in other
* words, a SAX driver class could catch an exception and report a
* fatalError).</p>
*
* <p>The HandlerBase class provides a default implementation of this
* interface, ignoring warnings and recoverable errors and throwing a
* SAXParseException for fatal errors. An application may extend
* that class rather than implementing the complete interface
* itself.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.Parser#setErrorHandler
* @see org.xml.sax.SAXParseException
* @see org.xml.sax.HandlerBase
*/
public interface ErrorHandler {
/**
* Receive notification of a warning.
*
* <p>SAX parsers will use this method to report conditions that
* are not errors or fatal errors as defined by the XML 1.0
* recommendation. The default behaviour is to take no action.</p>
*
* <p>The SAX parser must continue to provide normal parsing events
* after invoking this method: it should still be possible for the
* application to process the document through to the end.</p>
*
* @param exception The warning information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.SAXParseException
*/
public abstract void warning (SAXParseException exception)
throws SAXException;
/**
* Receive notification of a recoverable error.
*
* <p>This corresponds to the definition of "error" in section 1.2
* of the W3C XML 1.0 Recommendation. For example, a validating
* parser would use this callback to report the violation of a
* validity constraint. The default behaviour is to take no
* action.</p>
*
* <p>The SAX parser must continue to provide normal parsing events
* after invoking this method: it should still be possible for the
* application to process the document through to the end. If the
* application cannot do so, then the parser should report a fatal
* error even if the XML 1.0 recommendation does not require it to
* do so.</p>
*
* @param exception The error information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.SAXParseException
*/
public abstract void error (SAXParseException exception)
throws SAXException;
/**
* Receive notification of a non-recoverable error.
*
* <p>This corresponds to the definition of "fatal error" in
* section 1.2 of the W3C XML 1.0 Recommendation. For example, a
* parser would use this callback to report the violation of a
* well-formedness constraint.</p>
*
* <p>The application must assume that the document is unusable
* after the parser has invoked this method, and should continue
* (if at all) only for the sake of collecting addition error
* messages: in fact, SAX parsers are free to stop reporting any
* other events once this method has been invoked.</p>
*
* @param exception The error information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.SAXParseException
*/
public abstract void fatalError (SAXParseException exception)
throws SAXException;
}
1.1 xml-rpc/src/java/org/xml/sax/HandlerBase.java
Index: HandlerBase.java
===================================================================
// SAX default handler base class.
// No warranty; no copyright -- use this as you will.
// $Id: HandlerBase.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Default base class for handlers.
*
* <p>This class implements the default behaviour for four SAX
* interfaces: EntityResolver, DTDHandler, DocumentHandler,
* and ErrorHandler.</p>
*
* <p>Application writers can extend this class when they need to
* implement only part of an interface; parser writers can
* instantiate this class to provide default handlers when the
* application has not supplied its own.</p>
*
* <p>Note that the use of this class is optional.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler
* @see org.xml.sax.DocumentHandler
* @see org.xml.sax.ErrorHandler
*/
public class HandlerBase
implements EntityResolver, DTDHandler,
DocumentHandler, ErrorHandler
{
//////////////////////////////////////////////////////////////////////
// Default implementation of the EntityResolver interface.
//////////////////////////////////////////////////////////////////////
/**
* Resolve an external entity.
*
* <p>Always return null, so that the parser will use the system
* identifier provided in the XML document. This method implements
* the SAX default behaviour: application writers can override it
* in a subclass to do special translations such as catalog lookups
* or URI redirection.</p>
*
* @param publicId The public identifer, or null if none is
* available.
* @param systemId The system identifier provided in the XML
* document.
* @return The new input source, or null to require the
* default behaviour.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.EntityResolver#resolveEntity
*/
public InputSource resolveEntity (String publicId, String systemId)
throws SAXException
{
return null;
}
//////////////////////////////////////////////////////////////////////
// Default implementation of DTDHandler interface.
//////////////////////////////////////////////////////////////////////
/**
* Receive notification of a notation declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass if they wish to keep track of the notations
* declared in a document.</p>
*
* @param name The notation name.
* @param publicId The notation public identifier, or null if not
* available.
* @param systemId The notation system identifier.
* @see org.xml.sax.DTDHandler#notationDecl
*/
public void notationDecl (String name, String publicId, String systemId)
{
// no op
}
/**
* Receive notification of an unparsed entity declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to keep track of the unparsed entities
* declared in a document.</p>
*
* @param name The entity name.
* @param publicId The entity public identifier, or null if not
* available.
* @param systemId The entity system identifier.
* @param notationName The name of the associated notation.
* @see org.xml.sax.DTDHandler#unparsedEntityDecl
*/
public void unparsedEntityDecl (String name, String publicId,
String systemId, String notationName)
{
// no op
}
//////////////////////////////////////////////////////////////////////
// Default implementation of DocumentHandler interface.
//////////////////////////////////////////////////////////////////////
/**
* Receive a Locator object for document events.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass if they wish to store the locator for use
* with other document events.</p>
*
* @param locator A locator for all SAX document events.
* @see org.xml.sax.DocumentHandler#setDocumentLocator
* @see org.xml.sax.Locator
*/
public void setDocumentLocator (Locator locator)
{
// no op
}
/**
* Receive notification of the beginning of the document.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the beginning
* of a document (such as allocating the root node of a tree or
* creating an output file).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#startDocument
*/
public void startDocument ()
throws SAXException
{
// no op
}
/**
* Receive notification of the end of the document.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the beginning
* of a document (such as finalising a tree or closing an output
* file).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#endDocument
*/
public void endDocument ()
throws SAXException
{
// no op
}
/**
* Receive notification of the start of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each element (such as allocating a new tree node or writing
* output to a file).</p>
*
* @param name The element type name.
* @param attributes The specified or defaulted attributes.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#startElement
*/
public void startElement (String name, AttributeList attributes)
throws SAXException
{
// no op
}
/**
* Receive notification of the end of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the end of
* each element (such as finalising a tree node or writing
* output to a file).</p>
*
* @param name The element type name.
* @param attributes The specified or defaulted attributes.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#endElement
*/
public void endElement (String name)
throws SAXException
{
// no op
}
/**
* Receive notification of character data inside an element.
*
* <p>By default, do nothing. Application writers may override this
* method to take specific actions for each chunk of character data
* (such as adding the data to a node or buffer, or printing it to
* a file).</p>
*
* @param ch The characters.
* @param start The start position in the character array.
* @param length The number of characters to use from the
* character array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#characters
*/
public void characters (char ch[], int start, int length)
throws SAXException
{
// no op
}
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>By default, do nothing. Application writers may override this
* method to take specific actions for each chunk of ignorable
* whitespace (such as adding data to a node or buffer, or printing
* it to a file).</p>
*
* @param ch The whitespace characters.
* @param start The start position in the character array.
* @param length The number of characters to use from the
* character array.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#ignorableWhitespace
*/
public void ignorableWhitespace (char ch[], int start, int length)
throws SAXException
{
// no op
}
/**
* Receive notification of a processing instruction.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions for each
* processing instruction, such as setting status variables or
* invoking other methods.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none is supplied.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.DocumentHandler#processingInstruction
*/
public void processingInstruction (String target, String data)
throws SAXException
{
// no op
}
//////////////////////////////////////////////////////////////////////
// Default implementation of the ErrorHandler interface.
//////////////////////////////////////////////////////////////////////
/**
* Receive notification of a parser warning.
*
* <p>The default implementation does nothing. Application writers
* may override this method in a subclass to take specific actions
* for each warning, such as inserting the message in a log file or
* printing it to the console.</p>
*
* @param e The warning information encoded as an exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ErrorHandler#warning
* @see org.xml.sax.SAXParseException
*/
public void warning (SAXParseException e)
throws SAXException
{
// no op
}
/**
* Receive notification of a recoverable parser error.
*
* <p>The default implementation does nothing. Application writers
* may override this method in a subclass to take specific actions
* for each error, such as inserting the message in a log file or
* printing it to the console.</p>
*
* @param e The warning information encoded as an exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ErrorHandler#warning
* @see org.xml.sax.SAXParseException
*/
public void error (SAXParseException e)
throws SAXException
{
// no op
}
/**
* Report a fatal XML parsing error.
*
* <p>The default implementation throws a SAXParseException.
* Application writers may override this method in a subclass if
* they need to take specific actions for each fatal error (such as
* collecting all of the errors into a single report): in any case,
* the application must stop all regular processing when this
* method is invoked, since the document is no longer reliable, and
* the parser may no longer report parsing events.</p>
*
* @param e The error information encoded as an exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ErrorHandler#fatalError
* @see org.xml.sax.SAXParseException
*/
public void fatalError (SAXParseException e)
throws SAXException
{
throw e;
}
}
1.1 xml-rpc/src/java/org/xml/sax/InputSource.java
Index: InputSource.java
===================================================================
// SAX input source.
// No warranty; no copyright -- use this as you will.
// $Id: InputSource.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
import java.io.Reader;
import java.io.InputStream;
/**
* A single input source for an XML entity.
*
* <p>This class allows a SAX application to encapsulate information
* about an input source in a single object, which may include
* a public identifier, a system identifier, a byte stream (possibly
* with a specified encoding), and/or a character stream.</p>
*
* <p>There are two places that the application will deliver this
* input source to the parser: as the argument to the Parser.parse
* method, or as the return value of the EntityResolver.resolveEntity
* method.</p>
*
* <p>The SAX parser will use the InputSource object to determine how
* to read XML input. If there is a character stream available, the
* parser will read that stream directly; if not, the parser will use
* a byte stream, if available; if neither a character stream nor a
* byte stream is available, the parser will attempt to open a URI
* connection to the resource identified by the system
* identifier.</p>
*
* <p>An InputSource object belongs to the application: the SAX parser
* shall never modify it in any way (it may modify a copy if
* necessary).</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.Parser#parse
* @see org.xml.sax.EntityResolver#resolveEntity
* @see java.io.InputStream
* @see java.io.Reader
*/
public class InputSource {
/**
* Zero-argument default constructor.
*
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setCharacterStream
* @see #setEncoding
*/
public InputSource ()
{
}
/**
* Create a new input source with a system identifier.
*
* <p>Applications may use setPublicId to include a
* public identifier as well, or setEncoding to specify
* the character encoding, if known.</p>
*
* <p>If the system identifier is a URL, it must be full resolved.</p>
*
* @param systemId The system identifier (URI).
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setEncoding
* @see #setCharacterStream
*/
public InputSource (String systemId)
{
setSystemId(systemId);
}
/**
* Create a new input source with a byte stream.
*
* <p>Application writers may use setSystemId to provide a base
* for resolving relative URIs, setPublicId to include a
* public identifier, and/or setEncoding to specify the object's
* character encoding.</p>
*
* @param byteStream The raw byte stream containing the document.
* @see #setPublicId
* @see #setSystemId
* @see #setEncoding
* @see #setByteStream
* @see #setCharacterStream
*/
public InputSource (InputStream byteStream)
{
setByteStream(byteStream);
}
/**
* Create a new input source with a character stream.
*
* <p>Application writers may use setSystemId() to provide a base
* for resolving relative URIs, and setPublicId to include a
* public identifier.</p>
*
* <p>The character stream shall not include a byte order mark.</p>
*
* @see #setPublicId
* @see #setSystemId
* @see #setByteStream
* @see #setCharacterStream
*/
public InputSource (Reader characterStream)
{
setCharacterStream(characterStream);
}
/**
* Set the public identifier for this input source.
*
* <p>The public identifier is always optional: if the application
* writer includes one, it will be provided as part of the
* location information.</p>
*
* @param publicId The public identifier as a string.
* @see #getPublicId
* @see org.xml.sax.Locator#getPublicId
* @see org.xml.sax.SAXParseException#getPublicId
*/
public void setPublicId (String publicId)
{
this.publicId = publicId;
}
/**
* Get the public identifier for this input source.
*
* @return The public identifier, or null if none was supplied.
* @see #setPublicId
*/
public String getPublicId ()
{
return publicId;
}
/**
* Set the system identifier for this input source.
*
* <p>The system identifier is optional if there is a byte stream
* or a character stream, but it is still useful to provide one,
* since the application can use it to resolve relative URIs
* and can include it in error messages and warnings (the parser
* will attempt to open a connection to the URI only if
* there is no byte stream or character stream specified).</p>
*
* <p>If the application knows the character encoding of the
* object pointed to by the system identifier, it can register
* the encoding using the setEncoding method.</p>
*
* <p>If the system ID is a URL, it must be fully resolved.</p>
*
* @param systemId The system identifier as a string.
* @see #setEncoding
* @see #getSystemId
* @see org.xml.sax.Locator#getSystemId
* @see org.xml.sax.SAXParseException#getSystemId
*/
public void setSystemId (String systemId)
{
this.systemId = systemId;
}
/**
* Get the system identifier for this input source.
*
* <p>The getEncoding method will return the character encoding
* of the object pointed to, or null if unknown.</p>
*
* <p>If the system ID is a URL, it will be fully resolved.</p>
*
* @return The system identifier.
* @see #setSystemId
* @see #getEncoding
*/
public String getSystemId ()
{
return systemId;
}
/**
* Set the byte stream for this input source.
*
* <p>The SAX parser will ignore this if there is also a character
* stream specified, but it will use a byte stream in preference
* to opening a URI connection itself.</p>
*
* <p>If the application knows the character encoding of the
* byte stream, it should set it with the setEncoding method.</p>
*
* @param byteStream A byte stream containing an XML document or
* other entity.
* @see #setEncoding
* @see #getByteStream
* @see #getEncoding
* @see java.io.InputStream
*/
public void setByteStream (InputStream byteStream)
{
this.byteStream = byteStream;
}
/**
* Get the byte stream for this input source.
*
* <p>The getEncoding method will return the character
* encoding for this byte stream, or null if unknown.</p>
*
* @return The byte stream, or null if none was supplied.
* @see #getEncoding
* @see #setByteStream
*/
public InputStream getByteStream ()
{
return byteStream;
}
/**
* Set the character encoding, if known.
*
* <p>The encoding must be a string acceptable for an
* XML encoding declaration (see section 4.3.3 of the XML 1.0
* recommendation).</p>
*
* <p>This method has no effect when the application provides a
* character stream.</p>
*
* @param encoding A string describing the character encoding.
* @see #setSystemId
* @see #setByteStream
* @see #getEncoding
*/
public void setEncoding (String encoding)
{
this.encoding = encoding;
}
/**
* Get the character encoding for a byte stream or URI.
*
* @return The encoding, or null if none was supplied.
* @see #setByteStream
* @see #getSystemId
* @see #getByteStream
*/
public String getEncoding ()
{
return encoding;
}
/**
* Set the character stream for this input source.
*
* <p>If there is a character stream specified, the SAX parser
* will ignore any byte stream and will not attempt to open
* a URI connection to the system identifier.</p>
*
* @param characterStream The character stream containing the
* XML document or other entity.
* @see #getCharacterStream
* @see java.io.Reader
*/
public void setCharacterStream (Reader characterStream)
{
this.characterStream = characterStream;
}
/**
* Get the character stream for this input source.
*
* @return The character stream, or null if none was supplied.
* @see #setCharacterStream
*/
public Reader getCharacterStream ()
{
return characterStream;
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
private String publicId;
private String systemId;
private InputStream byteStream;
private String encoding;
private Reader characterStream;
}
1.1 xml-rpc/src/java/org/xml/sax/Locator.java
Index: Locator.java
===================================================================
// SAX locator interface for document events.
// No warranty; no copyright -- use this as you will.
// $Id: Locator.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Interface for associating a SAX event with a document location.
*
* <p>If a SAX parser provides location information to the SAX
* application, it does so by implementing this interface and then
* passing an instance to the application using the document
* handler's setDocumentLocator method. The application can use the
* object to obtain the location of any other document handler event
* in the XML source document.</p>
*
* <p>Note that the results returned by the object will be valid only
* during the scope of each document handler method: the application
* will receive unpredictable results if it attempts to use the
* locator at any other time.</p>
*
* <p>SAX parsers are not required to supply a locator, but they are
* very strong encouraged to do so. If the parser supplies a
* locator, it must do so before reporting any other document events.
* If no locator has been set by the time the application receives
* the startDocument event, the application should assume that a
* locator is not available.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.DocumentHandler#setDocumentLocator
*/
public interface Locator {
/**
* Return the public identifier for the current document event.
* <p>This will be the public identifier
* @return A string containing the public identifier, or
* null if none is available.
* @see #getSystemId
*/
public abstract String getPublicId ();
/**
* Return the system identifier for the current document event.
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @return A string containing the system identifier, or null
* if none is available.
* @see #getPublicId
*/
public abstract String getSystemId ();
/**
* Return the line number where the current document event ends.
* Note that this is the line position of the first character
* after the text associated with the document event.
* @return The line number, or -1 if none is available.
* @see #getColumnNumber
*/
public abstract int getLineNumber ();
/**
* Return the column number where the current document event ends.
* Note that this is the column number of the first
* character after the text associated with the document
* event. The first column in a line is position 1.
* @return The column number, or -1 if none is available.
* @see #getLineNumber
*/
public abstract int getColumnNumber ();
}
1.1 xml-rpc/src/java/org/xml/sax/Parser.java
Index: Parser.java
===================================================================
// SAX parser interface.
// No warranty; no copyright -- use this as you will.
// $Id: Parser.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
import java.io.IOException;
import java.util.Locale;
/**
* Basic interface for SAX (Simple API for XML) parsers.
*
* <p>All SAX parsers must implement this basic interface: it allows
* applications to register handlers for different types of events
* and to initiate a parse from a URI, or a character stream.</p>
*
* <p>All SAX parsers must also implement a zero-argument constructor
* (though other constructors are also allowed).</p>
*
* <p>SAX parsers are reusable but not re-entrant: the application
* may reuse a parser object (possibly with a different input source)
* once the first parse has completed successfully, but it may not
* invoke the parse() methods recursively within a parse.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler
* @see org.xml.sax.DocumentHandler
* @see org.xml.sax.ErrorHandler
* @see org.xml.sax.HandlerBase
* @see org.xml.sax.InputSource
*/
public interface Parser
{
/**
* Allow an application to request a locale for errors and warnings.
*
* <p>SAX parsers are not required to provide localisation for errors
* and warnings; if they cannot support the requested locale,
* however, they must throw a SAX exception. Applications may
* not request a locale change in the middle of a parse.</p>
*
* @param locale A Java Locale object.
* @exception org.xml.sax.SAXException Throws an exception
* (using the previous or default locale) if the
* requested locale is not supported.
* @see org.xml.sax.SAXException
* @see org.xml.sax.SAXParseException
*/
public abstract void setLocale (Locale locale)
throws SAXException;
/**
* Allow an application to register a custom entity resolver.
*
* <p>If the application does not register an entity resolver, the
* SAX parser will resolve system identifiers and open connections
* to entities itself (this is the default behaviour implemented in
* HandlerBase).</p>
*
* <p>Applications may register a new or different entity resolver
* in the middle of a parse, and the SAX parser must begin using
* the new resolver immediately.</p>
*
* @param resolver The object for resolving entities.
* @see EntityResolver
* @see HandlerBase
*/
public abstract void setEntityResolver (EntityResolver resolver);
/**
* Allow an application to register a DTD event handler.
*
* <p>If the application does not register a DTD handler, all DTD
* events reported by the SAX parser will be silently
* ignored (this is the default behaviour implemented by
* HandlerBase).</p>
*
* <p>Applications may register a new or different
* handler in the middle of a parse, and the SAX parser must
* begin using the new handler immediately.</p>
*
* @param handler The DTD handler.
* @see DTDHandler
* @see HandlerBase
*/
public abstract void setDTDHandler (DTDHandler handler);
/**
* Allow an application to register a document event handler.
*
* <p>If the application does not register a document handler, all
* document events reported by the SAX parser will be silently
* ignored (this is the default behaviour implemented by
* HandlerBase).</p>
*
* <p>Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.</p>
*
* @param handler The document handler.
* @see DocumentHandler
* @see HandlerBase
*/
public abstract void setDocumentHandler (DocumentHandler handler);
/**
* Allow an application to register an error event handler.
*
* <p>If the application does not register an error event handler,
* all error events reported by the SAX parser will be silently
* ignored, except for fatalError, which will throw a SAXException
* (this is the default behaviour implemented by HandlerBase).</p>
*
* <p>Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.</p>
*
* @param handler The error handler.
* @see ErrorHandler
* @see SAXException
* @see HandlerBase
*/
public abstract void setErrorHandler (ErrorHandler handler);
/**
* Parse an XML document.
*
* <p>The application can use this method to instruct the SAX parser
* to begin parsing an XML document from any valid input
* source (a character stream, a byte stream, or a URI).</p>
*
* <p>Applications may not invoke this method while a parse is in
* progress (they should create a new Parser instead for each
* additional XML document). Once a parse is complete, an
* application may reuse the same Parser object, possibly with a
* different input source.</p>
*
* @param source The input source for the top-level of the
* XML document.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception java.io.IOException An IO exception from the parser,
* possibly from a byte stream or character stream
* supplied by the application.
* @see org.xml.sax.InputSource
* @see #parse(java.lang.String)
* @see #setEntityResolver
* @see #setDTDHandler
* @see #setDocumentHandler
* @see #setErrorHandler
*/
public abstract void parse (InputSource source)
throws SAXException, IOException;
/**
* Parse an XML document from a system identifier (URI).
*
* <p>This method is a shortcut for the common case of reading a
* document from a system identifier. It is the exact
* equivalent of the following:</p>
*
* <pre>
* parse(new InputSource(systemId));
* </pre>
*
* <p>If the system identifier is a URL, it must be fully resolved
* by the application before it is passed to the parser.</p>
*
* @param systemId The system identifier (URI).
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception java.io.IOException An IO exception from the parser,
* possibly from a byte stream or character stream
* supplied by the application.
* @see #parse(org.xml.sax.InputSource)
*/
public abstract void parse (String systemId)
throws SAXException, IOException;
}
1.1 xml-rpc/src/java/org/xml/sax/SAXException.java
Index: SAXException.java
===================================================================
// SAX exception class.
// No warranty; no copyright -- use this as you will.
// $Id: SAXException.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Encapsulate a general SAX error or warning.
*
* <p>This class can contain basic error or warning information from
* either the XML parser or the application: a parser writer or
* application writer can subclass it to provide additional
* functionality. SAX handlers may throw this exception or
* any exception subclassed from it.</p>
*
* <p>If the application needs to pass through other types of
* exceptions, it must wrap those exceptions in a SAXException
* or an exception derived from a SAXException.</p>
*
* <p>If the parser or application needs to include information about a
* specific location in an XML document, it should use the
* SAXParseException subclass.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.SAXParseException
*/
public class SAXException extends Exception {
/**
* Create a new SAXException.
*
* @param message The error or warning message.
* @see org.xml.sax.Parser#setLocale
*/
public SAXException (String message) {
super();
this.message = message;
this.exception = null;
}
/**
* Create a new SAXException wrapping an existing exception.
*
* <p>The existing exception will be embedded in the new
* one, and its message will become the default message for
* the SAXException.</p>
*
* @param e The exception to be wrapped in a SAXException.
*/
public SAXException (Exception e)
{
super();
this.message = null;
this.exception = e;
}
/**
* Create a new SAXException from an existing exception.
*
* <p>The existing exception will be embedded in the new
* one, but the new exception will have its own message.</p>
*
* @param message The detail message.
* @param e The exception to be wrapped in a SAXException.
* @see org.xml.sax.Parser#setLocale
*/
public SAXException (String message, Exception e)
{
super();
this.message = message;
this.exception = e;
}
/**
* Return a detail message for this exception.
*
* <p>If there is a embedded exception, and if the SAXException
* has no detail message of its own, this method will return
* the detail message from the embedded exception.</p>
*
* @return The error or warning message.
* @see org.xml.sax.Parser#setLocale
*/
public String getMessage ()
{
if (message == null && exception != null) {
return exception.getMessage();
} else {
return this.message;
}
}
/**
* Return the embedded exception, if any.
*
* @return The embedded exception, or null if there is none.
*/
public Exception getException ()
{
return exception;
}
/**
* Convert this exception to a string.
*
* @return A string version of this exception.
*/
public String toString ()
{
return getMessage();
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
private String message;
private Exception exception;
}
1.1 xml-rpc/src/java/org/xml/sax/SAXParseException.java
Index: SAXParseException.java
===================================================================
// SAX exception class.
// No warranty; no copyright -- use this as you will.
// $Id: SAXParseException.java,v 1.1 2001/11/06 18:33:40 hannes Exp $
package org.xml.sax;
/**
* Encapsulate an XML parse error or warning.
*
* <p>This exception will include information for locating the error
* in the original XML document. Note that although the application
* will receive a SAXParseException as the argument to the handlers
* in the ErrorHandler interface, the application is not actually
* required to throw the exception; instead, it can simply read the
* information in it and take a different action.</p>
*
* <p>Since this exception is a subclass of SAXException, it
* inherits the ability to wrap another exception.</p>
*
* @author David Megginson (ak117@freenet.carleton.ca)
* @version 1.0
* @see org.xml.sax.SAXException
* @see org.xml.sax.Locator
* @see org.xml.sax.ErrorHandler
*/
public class SAXParseException extends SAXException {
//////////////////////////////////////////////////////////////////////
// Constructors.
//////////////////////////////////////////////////////////////////////
/**
* Create a new SAXParseException from a message and a Locator.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback.</p>
*
* @param message The error or warning message.
* @param locator The locator object for the error or warning.
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public SAXParseException (String message, Locator locator) {
super(message);
this.publicId = locator.getPublicId();
this.systemId = locator.getSystemId();
this.lineNumber = locator.getLineNumber();
this.columnNumber = locator.getColumnNumber();
}
/**
* Wrap an existing exception in a SAXParseException.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback, and needs to wrap an existing exception that is not a
* subclass of SAXException.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param locator The locator object for the error or warning.
* @param e Any exception
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public SAXParseException (String message, Locator locator,
Exception e) {
super(message, e);
this.publicId = locator.getPublicId();
this.systemId = locator.getSystemId();
this.lineNumber = locator.getLineNumber();
this.columnNumber = locator.getColumnNumber();
}
/**
* Create a new SAXParseException.
*
* <p>This constructor is most useful for parser writers.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message.
* @param publicId The public identifer of the entity that generated
* the error or warning.
* @param systemId The system identifer of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* cause the error or warning.
* @see org.xml.sax.Parser#setLocale
*/
public SAXParseException (String message, String publicId, String systemId,
int lineNumber, int columnNumber)
{
super(message);
this.publicId = publicId;
this.systemId = systemId;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
}
/**
* Create a new SAXParseException with an embedded exception.
*
* <p>This constructor is most useful for parser writers who
* need to wrap an exception that is not a subclass of
* SAXException.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message, or null to use
* the message from the embedded exception.
* @param publicId The public identifer of the entity that generated
* the error or warning.
* @param systemId The system identifer of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* cause the error or warning.
* @param e Another exception to embed in this one.
* @see org.xml.sax.Parser#setLocale
*/
public SAXParseException (String message, String publicId, String systemId,
int lineNumber, int columnNumber, Exception e)
{
super(message, e);
this.publicId = publicId;
this.systemId = systemId;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
}
/**
* Get the public identifier of the entity where the exception occurred.
*
* @return A string containing the public identifier, or null
* if none is available.
* @see org.xml.sax.Locator#getPublicId
*/
public String getPublicId ()
{
return this.publicId;
}
/**
* Get the system identifier of the entity where the exception occurred.
*
* <p>If the system identifier is a URL, it will be resolved
* fully.</p>
*
* @return A string containing the system identifier, or null
* if none is available.
* @see org.xml.sax.Locator#getSystemId
*/
public String getSystemId ()
{
return this.systemId;
}
/**
* The line number of the end of the text where the exception occurred.
*
* @return An integer representing the line number, or -1
* if none is available.
* @see org.xml.sax.Locator#getLineNumber
*/
public int getLineNumber ()
{
return this.lineNumber;
}
/**
* The column number of the end of the text where the exception occurred.
*
* <p>The first column in a line is position 1.</p>
*
* @return An integer representing the column number, or -1
* if none is available.
* @see org.xml.sax.Locator#getColumnNumber
*/
public int getColumnNumber ()
{
return this.columnNumber;
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
private String publicId;
private String systemId;
private int lineNumber;
private int columnNumber;
}