You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by ha...@apache.org on 2001/11/12 01:02:37 UTC
cvs commit: jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/sax SAXParserFactory.java
hammant 01/11/11 16:02:37
Added: src/java/org/apache/avalon/cornerstone/blocks/sax
SAXParserFactoryImpl.java
SAXParserFactoryImpl.xinfo
src/java/org/apache/avalon/cornerstone/services/sax
SAXParserFactory.java
Log:
Initial impl of SAX Factory.
Revision Changes Path
1.1 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/sax/SAXParserFactoryImpl.java
Index: SAXParserFactoryImpl.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.cornerstone.blocks.sax;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.phoenix.Block;
import org.apache.avalon.cornerstone.services.sax.SAXParserFactory;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import javax.xml.parsers.ParserConfigurationException;
/**
* Block implementation of the SAXParserFactory service. That service being
* a non abstract/static clone of the javax.xml.parsers class of the same name.
*
* @author <a href="mailto:Paul_Hammant@yahoo.com">Paul Hammant</a>
*/
public class SAXParserFactoryImpl
extends AbstractLogEnabled
implements Block, Configurable, SAXParserFactory
{
protected javax.xml.parsers.SAXParserFactory m_saxParserFactory;
public void dispose()
{
m_saxParserFactory = null;
}
public void configure( Configuration configuration )
throws ConfigurationException
{
// org.apache.crimson.jaxp.SAXParserFactoryImpl is an example of a
// string that's valid (classpath considered) as a parameter on config.xml
final String saxClass =
configuration.getChild("saxClass").getValue();
try
{
m_saxParserFactory =
(javax.xml.parsers.SAXParserFactory)Class.forName(saxClass).newInstance();
}
catch( final ClassNotFoundException cnfe )
{
throw new ConfigurationException( "ClassNotFoundException for SAX " +
"parser factory",
cnfe );
}
catch( final InstantiationException ie )
{
throw new ConfigurationException( "InstantiationException for SAX " +
"parser factory",
ie );
}
catch( final IllegalAccessException ie )
{
throw new ConfigurationException( "IllegalAccessException for SAX " +
"parser factory",
ie );
}
}
public void setNamespaceAware(boolean awareness) {
m_saxParserFactory.setNamespaceAware(awareness);
}
public void setValidating(boolean validating) {
m_saxParserFactory.setValidating(validating);
}
public boolean isNamespaceAware() {
return m_saxParserFactory.isNamespaceAware();
}
public boolean isValidating() {
return m_saxParserFactory.isValidating();
}
public void setFeature(String name, boolean value)
throws ParserConfigurationException,
SAXNotRecognizedException, SAXNotSupportedException {
m_saxParserFactory.setFeature(name,value);
}
public boolean getFeature(String name)
throws ParserConfigurationException, SAXNotRecognizedException,
SAXNotSupportedException {
return m_saxParserFactory.getFeature(name);
}
}
1.1 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/sax/SAXParserFactoryImpl.xinfo
Index: SAXParserFactoryImpl.xinfo
===================================================================
<?xml version="1.0"?>
<blockinfo>
<!-- section to describe block -->
<block>
<version>1.0</version>
</block>
<!-- services that are offered by this block -->
<services>
<service name="org.apache.avalon.cornerstone.services.sax.SAXParserFactory" version="1.0" />
</services>
</blockinfo>
1.1 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/sax/SAXParserFactory.java
Index: SAXParserFactory.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.cornerstone.services.sax;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXNotRecognizedException;
import javax.xml.parsers.ParserConfigurationException;
public interface SAXParserFactory {
/**
* Specifies that the parser produced by this code will
* provide support for XML namespaces. By default the value of this is set
* to <code>false</code>.
*
* @param awareness true if the parser produced by this code will
* provide support for XML namespaces; false otherwise.
*/
void setNamespaceAware(boolean awareness);
/**
* Specifies that the parser produced by this code will
* validate documents as they are parsed. By default the value of this is
* set to <code>false</code>.
*
* @param validating true if the parser produced by this code will
* validate documents as they are parsed; false otherwise.
*/
void setValidating(boolean validating);
/**
* Indicates whether or not the factory is configured to produce
* parsers which are namespace aware.
*
* @return true if the factory is configured to produce
* parsers which are namespace aware; false otherwise.
*/
boolean isNamespaceAware();
/**
* Indicates whether or not the factory is configured to produce
* parsers which validate the XML content during parse.
*
* @return true if the factory is configured to produce parsers which validate
* the XML content during parse; false otherwise.
*/
boolean isValidating();
/**
*
* Sets the particular feature in the underlying implementation of
* org.xml.sax.XMLReader.
* A list of the core features and properties can be found at
* <a href="http://www.megginson.com/SAX/Java/features.html"> http://www.megginson.com/SAX/Java/features.html </a>
*
* @param name The name of the feature to be set.
* @param value The value of the feature to be set.
* @exception SAXNotRecognizedException When the underlying XMLReader does
* not recognize the property name.
*
* @exception SAXNotSupportedException When the underlying XMLReader
* recognizes the property name but doesn't support the
* property.
*
* @see org.xml.sax.XMLReader#setFeature
*/
void setFeature(String name, boolean value)
throws ParserConfigurationException, SAXNotRecognizedException,
SAXNotSupportedException;
/**
*
* Returns the particular property requested for in the underlying
* implementation of org.xml.sax.XMLReader.
*
* @param name The name of the property to be retrieved.
* @return Value of the requested property.
*
* @exception SAXNotRecognizedException When the underlying XMLReader does
* not recognize the property name.
*
* @exception SAXNotSupportedException When the underlying XMLReader
* recognizes the property name but doesn't support the
* property.
*
* @see org.xml.sax.XMLReader#getProperty
*/
boolean getFeature(String name)
throws ParserConfigurationException, SAXNotRecognizedException,
SAXNotSupportedException;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>