/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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
*
*
* 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.
*/
/**
* A very basic parser configuration. This configuration class can
* be used as a base class for custom parser configurations. The
* basic parser configuration creates the symbol table (if not
* specified at construction time) and manages all of the recognized
* features and properties.
* <p>
* The basic parser configuration does <strong>not</strong> mandate
* any particular pipeline configuration or the use of specific
* components except for the symbol table. If even this is too much
* for a basic parser configuration, the programmer can create a new
* configuration class that implements the
* <code>XMLParserConfiguration</code> interface.
* <p>
* Subclasses of the basic parser configuration can add their own
* recognized features and properties by calling the
* <code>addRecognizedFeature</code> and
* <code>addRecognizedProperty</code> methods, respectively.
* <p>
* The basic parser configuration assumes that the configuration
* will be made up of various parser components that implement the
* <code>XMLComponent</code> interface. If subclasses of this
* configuration create their own components for use in the
* parser configuration, then each component should be added to
* the list of components by calling the <code>addComponent</code>
* method. The basic parser configuration will make sure to call
* the <code>reset</code> method of each registered component
* before parsing an instance document.
* <p>
* This class recognizes the following features and properties:
* <ul>
* <li>Features
* <ul>
* <li>http://xml.org/sax/features/validation</li>
* <li>http://xml.org/sax/features/namespaces</li>
* </ul>
* <li>Properties
* <ul>
* <li>http://xml.org/sax/properties/xml-string</li>
* </ul>
* </ul>
*
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
* @version $Id: BasicParserConfiguration.java,v 1.6 2010-11-01 04:40:09 joehw Exp $
*/
public abstract class BasicParserConfiguration
extends ParserConfigurationSettings
implements XMLParserConfiguration {
//
// Constants
//
// feature identifiers
/** Feature identifier: validation. */
/** Feature identifier: namespaces. */
/** Feature identifier: external general entities. */
/** Feature identifier: external parameter entities. */
// property identifiers
/** Property identifier: xml string. */
/** Property identifier: symbol table. */
/** Property identifier: error handler. */
/** Property identifier: entity resolver. */
//
// Data
//
// components (non-configurable)
/** Symbol table. */
// data
/** Locale. */
/** Components. */
// handlers
/** The document handler. */
/** The DTD handler. */
/** The DTD content model handler. */
/** Last component in the document pipeline */
//
// Constructors
//
/** Default Constructor. */
protected BasicParserConfiguration() {
} // <init>()
/**
* Constructs a parser configuration using the specified symbol table.
*
* @param symbolTable The symbol table to use.
*/
this(symbolTable, null);
} // <init>(SymbolTable)
/**
* Constructs a parser configuration using the specified symbol table
* and parent settings.
*
* @param symbolTable The symbol table to use.
* @param parentSettings The parent settings.
*/
super(parentSettings);
// create a vector to hold all the components in use
fComponents = new ArrayList();
// create table for features and properties
fProperties = new HashMap();
// add default recognized features
final String[] recognizedFeatures = {
};
// set state for default features
// add default recognized properties
final String[] recognizedProperties = {
};
if (symbolTable == null) {
symbolTable = new SymbolTable();
}
} // <init>(SymbolTable)
/**
* Adds a component to the parser configuration. This method will
* also add all of the component's recognized features and properties
* to the list of default recognized features and properties.
*
* @param component The component to add.
*/
// don't add a component more than once
return;
}
// register component's recognized features
// register component's recognized properties
// set default values
if (recognizedFeatures != null) {
}
}
}
if (recognizedProperties != null) {
}
}
}
} // addComponent(XMLComponent)
//
// XMLParserConfiguration methods
//
/**
* Parse an XML document.
* <p>
* The parser can use this method to instruct this configuration
* to begin parsing an XML document from any valid input source
* (a character stream, a byte stream, or a URI).
* <p>
* Parsers may not invoke this method while a parse is in progress.
* Once a parse is complete, the parser may then parse another XML
* document.
* <p>
* This method is synchronous: it will not return until parsing
* has ended. If a client application wants to terminate
* parsing early, it should throw an exception.
*
* @param inputSource The input source for the top-level of the
* XML document.
*
* @exception XNIException Any XNI exception, possibly wrapping
* another exception.
* @exception IOException An IO exception from the parser, possibly
* from a byte stream or character stream
* supplied by the parser.
*/
throws XNIException, IOException;
/**
* Sets the document handler on the last component in the pipeline
* to receive information about the document.
*
* @param documentHandler The document handler.
*/
if (fLastComponent != null) {
if (fDocumentHandler !=null){
}
}
} // setDocumentHandler(XMLDocumentHandler)
/** Returns the registered document handler. */
return fDocumentHandler;
} // getDocumentHandler():XMLDocumentHandler
/**
* Sets the DTD handler.
*
* @param dtdHandler The DTD handler.
*/
} // setDTDHandler(XMLDTDHandler)
/** Returns the registered DTD handler. */
return fDTDHandler;
} // getDTDHandler():XMLDTDHandler
/**
* Sets the DTD content model handler.
*
* @param handler The DTD content model handler.
*/
} // setDTDContentModelHandler(XMLDTDContentModelHandler)
/** Returns the registered DTD content model handler. */
return fDTDContentModelHandler;
} // getDTDContentModelHandler():XMLDTDContentModelHandler
/**
* Sets the resolver used to resolve external entities. The EntityResolver
* interface supports resolution of public and system identifiers.
*
* @param resolver The new entity resolver. Passing a null value will
* uninstall the currently installed resolver.
*/
// REVISIT: Should this be a property?
} // setEntityResolver(XMLEntityResolver)
/**
* Return the current entity resolver.
*
* @return The current entity resolver, or null if none
* has been registered.
* @see #setEntityResolver
*/
// REVISIT: Should this be a property?
} // getEntityResolver():XMLEntityResolver
/**
* Allow an application to register an error event handler.
*
* <p>If the application does not register an error handler, all
* error events reported by the SAX parser will be silently
* ignored; however, normal processing may not continue. It is
* highly recommended that all SAX applications implement an
* error handler to avoid unexpected bugs.</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 errorHandler The error handler.
* @exception java.lang.NullPointerException If the handler
* argument is null.
* @see #getErrorHandler
*/
// REVISIT: Should this be a property?
} // setErrorHandler(XMLErrorHandler)
/**
* Return the current error handler.
*
* @return The current error handler, or null if none
* has been registered.
* @see #setErrorHandler
*/
// REVISIT: Should this be a property?
} // getErrorHandler():XMLErrorHandler
/**
* Set the state of a feature.
*
* Set the state of any feature in a SAX2 parser. The parser
* might not recognize the feature, and if it does recognize
* it, it might not be able to fulfill the request.
*
* @param featureId The unique identifier (URI) of the feature.
* @param state The requested state of the feature (true or false).
*
* @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the
* requested feature is not known.
*/
throws XMLConfigurationException {
// forward to every component
for (int i = 0; i < count; i++) {
}
// save state if noone "objects"
} // setFeature(String,boolean)
/**
* setProperty
*
* @param propertyId
* @param value
*/
throws XMLConfigurationException {
// forward to every component
for (int i = 0; i < count; i++) {
}
// store value if noone "objects"
} // setProperty(String,Object)
/**
* Set the locale to use for messages.
*
* @param locale The locale object to use for localization of messages.
*
* @exception XNIException Thrown if the parser does not support the
* specified locale.
*/
} // setLocale(Locale)
/** Returns the locale. */
return fLocale;
} // getLocale():Locale
//
// Protected methods
//
/**
* reset all components before parsing and namespace context
*/
// reset every component
for (int i = 0; i < count; i++) {
c.reset(this);
}
} // reset()
/**
* Check a property. If the property is known and supported, this method
* simply returns. Otherwise, the appropriate exception is thrown.
*
* @param propertyId The unique identifier (URI) of the property
* being set.
* @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the
* requested feature is not known or supported.
*/
throws XMLConfigurationException {
// special cases
//
// Value type: String
// Access: read-only
// Get the literal string of characters associated with the
// current event. If the parser recognises and supports this
// property but is not currently parsing text, it should return
// null (this is a good way to check for availability before the
// parse begins).
//
// REVISIT - we should probably ask xml-dev for a precise
// definition of what this is actually supposed to return, and
// in exactly which circumstances.
return PropertyState.NOT_SUPPORTED;
}
}
// check property
return super.checkProperty(propertyId);
} // checkProperty(String)
/**
* Check a feature. If feature is know and supported, this method simply
* returns. Otherwise, the appropriate exception is thrown.
*
* @param featureId The unique identifier (URI) of the feature.
*
* @throws XMLConfigurationException Thrown for configuration error.
* In general, components should
* only throw this exception if
* it is <strong>really</strong>
* a critical error.
*/
throws XMLConfigurationException {
//
// Xerces Features
//
//
// special performance feature: no one by component manager is allowed to set it
//
return FeatureState.NOT_SUPPORTED;
}
}
return super.checkFeature(featureId);
} // checkFeature(String)
} // class BasicParserConfiguration