FileDocCategorySizeDatePackage
XMLInputFactory.javaAPI DocJava SE 6 API14015Tue Jun 10 00:27:10 BST 2008javax.xml.stream

XMLInputFactory

public abstract class XMLInputFactory extends Object
Defines an abstract implementation of a factory for getting streams. The following table defines the standard properties of this specification. Each property varies in the level of support required by each implementation. The level of support required is described in the 'Required' column.
Configuration parameters
Property Name Behavior Return type Default Value Required
javax.xml.stream.isValidatingTurns on/off implementation specific DTD validationBooleanFalseNo
javax.xml.stream.isNamespaceAwareTurns on/off namespace processing for XML 1.0 supportBooleanTrueTrue (required) / False (optional)
javax.xml.stream.isCoalescingRequires the processor to coalesce adjacent character dataBooleanFalseYes
javax.xml.stream.isReplacingEntityReferencesreplace internal entity references with their replacement text and report them as charactersBooleanTrueYes
javax.xml.stream.isSupportingExternalEntitiesResolve external parsed entitiesBooleanUnspecifiedYes
javax.xml.stream.supportDTDUse this property to request processors that do not support DTDsBooleanTrueYes
javax.xml.stream.reportersets/gets the impl of the XMLReporter javax.xml.stream.XMLReporterNullYes
javax.xml.stream.resolversets/gets the impl of the XMLResolver interfacejavax.xml.stream.XMLResolverNullYes
javax.xml.stream.allocatorsets/gets the impl of the XMLEventAllocator interfacejavax.xml.stream.util.XMLEventAllocatorNullYes
version
1.0
author
Copyright (c) 2003 by BEA Systems. All Rights Reserved.
see
XMLOutputFactory
see
XMLEventReader
see
XMLStreamReader
see
EventFilter
see
XMLReporter
see
XMLResolver
see
javax.xml.stream.util.XMLEventAllocator
since
1.6

Fields Summary
public static final String
IS_NAMESPACE_AWARE
The property used to turn on/off namespace support, this is to support XML 1.0 documents, only the true setting must be supported
public static final String
IS_VALIDATING
The property used to turn on/off implementation specific validation
public static final String
IS_COALESCING
The property that requires the parser to coalesce adjacent character data sections
public static final String
IS_REPLACING_ENTITY_REFERENCES
Requires the parser to replace internal entity references with their replacement text and report them as characters
public static final String
IS_SUPPORTING_EXTERNAL_ENTITIES
The property that requires the parser to resolve external parsed entities
public static final String
SUPPORT_DTD
The property that requires the parser to support DTDs
public static final String
REPORTER
The property used to set/get the implementation of the XMLReporter interface
public static final String
RESOLVER
The property used to set/get the implementation of the XMLResolver
public static final String
ALLOCATOR
The property used to set/get the implementation of the allocator
Constructors Summary
protected XMLInputFactory()


   
Methods Summary
public abstract javax.xml.stream.XMLStreamReadercreateFilteredReader(javax.xml.stream.XMLStreamReader reader, javax.xml.stream.StreamFilter filter)
Create a filtered reader that wraps the filter around the reader

param
reader the reader to filter
param
filter the filter to apply to the reader
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateFilteredReader(javax.xml.stream.XMLEventReader reader, javax.xml.stream.EventFilter filter)
Create a filtered event reader that wraps the filter around the event reader

param
reader the event reader to wrap
param
filter the filter to apply to the event reader
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(java.io.Reader reader)
Create a new XMLEventReader from a reader

param
reader the XML data to read from
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(java.lang.String systemId, java.io.Reader reader)
Create a new XMLEventReader from a reader

param
systemId the system ID of the input
param
reader the XML data to read from
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(javax.xml.stream.XMLStreamReader reader)
Create a new XMLEventReader from an XMLStreamReader. After being used to construct the XMLEventReader instance returned from this method the XMLStreamReader must not be used.

param
reader the XMLStreamReader to read from (may not be modified)
return
a new XMLEventReader
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(javax.xml.transform.Source source)
Create a new XMLEventReader from a JAXP source. Support of this method is optional.

param
source the source to read from
throws
UnsupportedOperationException if this method is not supported by this XMLInputFactory

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(java.io.InputStream stream)
Create a new XMLEventReader from a java.io.InputStream

param
stream the InputStream to read from
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(java.io.InputStream stream, java.lang.String encoding)
Create a new XMLEventReader from a java.io.InputStream

param
stream the InputStream to read from
param
encoding the character encoding of the stream
throws
XMLStreamException

public abstract javax.xml.stream.XMLEventReadercreateXMLEventReader(java.lang.String systemId, java.io.InputStream stream)
Create a new XMLEventReader from a java.io.InputStream

param
systemId the system ID of the stream
param
stream the InputStream to read from
throws
XMLStreamException

public abstract javax.xml.stream.XMLStreamReadercreateXMLStreamReader(java.io.Reader reader)
Create a new XMLStreamReader from a reader

param
reader the XML data to read from
throws
XMLStreamException

public abstract javax.xml.stream.XMLStreamReadercreateXMLStreamReader(javax.xml.transform.Source source)
Create a new XMLStreamReader from a JAXP source. This method is optional.

param
source the source to read from
throws
UnsupportedOperationException if this method is not supported by this XMLInputFactory
throws
XMLStreamException

public abstract javax.xml.stream.XMLStreamReadercreateXMLStreamReader(java.io.InputStream stream)
Create a new XMLStreamReader from a java.io.InputStream

param
stream the InputStream to read from
throws
XMLStreamException

public abstract javax.xml.stream.XMLStreamReadercreateXMLStreamReader(java.io.InputStream stream, java.lang.String encoding)
Create a new XMLStreamReader from a java.io.InputStream

param
stream the InputStream to read from
param
encoding the character encoding of the stream
throws
XMLStreamException

public abstract javax.xml.stream.XMLStreamReadercreateXMLStreamReader(java.lang.String systemId, java.io.InputStream stream)
Create a new XMLStreamReader from a java.io.InputStream

param
systemId the system ID of the stream
param
stream the InputStream to read from

public abstract javax.xml.stream.XMLStreamReadercreateXMLStreamReader(java.lang.String systemId, java.io.Reader reader)
Create a new XMLStreamReader from a java.io.InputStream

param
systemId the system ID of the stream
param
reader the InputStream to read from

public abstract javax.xml.stream.util.XMLEventAllocatorgetEventAllocator()
Gets the allocator used by streams created with this factory

public abstract java.lang.ObjectgetProperty(java.lang.String name)
Get the value of a feature/property from the underlying implementation

param
name The name of the property (may not be null)
return
The value of the property
throws
IllegalArgumentException if the property is not supported

public abstract javax.xml.stream.XMLReportergetXMLReporter()
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public abstract javax.xml.stream.XMLResolvergetXMLResolver()
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public abstract booleanisPropertySupported(java.lang.String name)
Query the set of properties that this factory supports.

param
name The name of the property (may not be null)
return
true if the property is supported and false otherwise

public static javax.xml.stream.XMLInputFactorynewInstance()
Create a new instance of the factory. This static method creates a new factory instance. This method uses the following ordered lookup procedure to determine the XMLInputFactory implementation class to load: Use the javax.xml.stream.XMLInputFactory system property. Use the properties file "lib/stax.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.stream.XMLInputFactory in jars available to the runtime. Platform default XMLInputFactory instance. Once an application has obtained a reference to a XMLInputFactory it can use the factory to configure and obtain stream instances.

throws
FactoryConfigurationError if an instance of this factory cannot be loaded

    return (XMLInputFactory) FactoryFinder.find(
      "javax.xml.stream.XMLInputFactory",
      "com.sun.xml.internal.stream.XMLInputFactoryImpl");
  
public static javax.xml.stream.XMLInputFactorynewInstance(java.lang.String factoryId, java.lang.ClassLoader classLoader)
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

      try {
          //do not fallback if given classloader can't find the class, throw exception
          return (XMLInputFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
      } catch (FactoryFinder.ConfigurationError e) {
          throw new FactoryConfigurationError(e.getException(),
                  e.getMessage());
      }
  
public abstract voidsetEventAllocator(javax.xml.stream.util.XMLEventAllocator allocator)
Set a user defined event allocator for events

param
allocator the user defined allocator

public abstract voidsetProperty(java.lang.String name, java.lang.Object value)
Allows the user to set specific feature/property on the underlying implementation. The underlying implementation is not required to support every setting of every property in the specification and may use IllegalArgumentException to signal that an unsupported property may not be set with the specified value.

param
name The name of the property (may not be null)
param
value The value of the property
throws
java.lang.IllegalArgumentException if the property is not supported

public abstract voidsetXMLReporter(javax.xml.stream.XMLReporter reporter)
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

param
reporter the resolver to use to report non fatal errors

public abstract voidsetXMLResolver(javax.xml.stream.XMLResolver resolver)
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

param
resolver the resolver to use to resolve references