package javax.xml.stream;
import javax.xml.stream.events.*;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import java.util.Iterator;
/**
* This interface defines a utility class for creating instances of
* XMLEvents
* @version 1.0
* @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
* @see javax.xml.stream.events.StartElement
* @see javax.xml.stream.events.EndElement
* @see javax.xml.stream.events.ProcessingInstruction
* @see javax.xml.stream.events.Comment
* @see javax.xml.stream.events.Characters
* @see javax.xml.stream.events.StartDocument
* @see javax.xml.stream.events.EndDocument
* @see javax.xml.stream.events.DTD
* @since 1.6
*/
public abstract class XMLEventFactory {
protected XMLEventFactory(){}
/**
* Create a new instance of the factory
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded
*/
public static XMLEventFactory newInstance()
throws FactoryConfigurationError
{
return (XMLEventFactory) FactoryFinder.find(
"javax.xml.stream.XMLEventFactory",
"com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
}
/**
* Create a new instance of the factory
*
* @param factoryId Name of the factory to find, same as
* a property name
* @param classLoader classLoader to use
* @return the factory implementation
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded
*/
public static XMLEventFactory newInstance(String factoryId,
ClassLoader classLoader)
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
return (XMLEventFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
}
}
/**
* This method allows setting of the Location on each event that
* is created by this factory. The values are copied by value into
* the events created by this factory. To reset the location
* information set the location to null.
* @param location the location to set on each event created
*/
public abstract void setLocation(Location location);
/**
* Create a new Attribute
* @param prefix the prefix of this attribute, may not be null
* @param namespaceURI the attribute value is set to this value, may not be null
* @param localName the local name of the XML name of the attribute, localName cannot be null
* @param value the attribute value to set, may not be null
* @return the Attribute with specified values
*/
public abstract Attribute createAttribute(String prefix, String namespaceURI, String localName, String value);
/**
* Create a new Attribute
* @param localName the local name of the XML name of the attribute, localName cannot be null
* @param value the attribute value to set, may not be null
* @return the Attribute with specified values
*/
public abstract Attribute createAttribute(String localName, String value);
/**
* Create a new Attribute
* @param name the qualified name of the attribute, may not be null
* @param value the attribute value to set, may not be null
* @return the Attribute with specified values
*/
public abstract Attribute createAttribute(QName name, String value);
/**
* Create a new default Namespace
* @param namespaceURI the default namespace uri
* @return the Namespace with the specified value
*/
public abstract Namespace createNamespace(String namespaceURI);
/**
* Create a new Namespace
=1= |