to top
Android APIs
public class

XmlPullParserFactory

extends Object
java.lang.Object
   ↳ org.xmlpull.v1.XmlPullParserFactory

Class Overview

This class is used to create implementations of XML Pull Parser defined in XMPULL V1 API. The name of actual factory class will be determined based on several parameters. It works similar to JAXP but tailored to work in J2ME environments (no access to system properties or file system) so name of parser class factory to use and its class used for loading (no class loader - on J2ME no access to context class loaders) must be passed explicitly. If no name of parser factory was passed (or is null) it will try to find name by searching in CLASSPATH for META-INF/services/org.xmlpull.v1.XmlPullParserFactory resource that should contain a comma separated list of class names of factories or parsers to try (in order from left to the right). If none found, it will throw an exception.
NOTE:In J2SE or J2EE environments, you may want to use newInstance(property, classLoaderCtx) where first argument is System.getProperty(XmlPullParserFactory.PROPERTY_NAME) and second is Thread.getContextClassLoader().getClass() .

See Also

Summary

Constants
String PROPERTY_NAME Name of the system or midlet property that should be used for a system property containing a comma separated list of factory or parser class names (value: org.xmlpull.v1.XmlPullParserFactory).
Fields
protected String classNamesLocation
protected HashMap features
protected ArrayList parserClasses
protected ArrayList serializerClasses
Protected Constructors
XmlPullParserFactory()
Protected constructor to be called by factory implementations.
Public Methods
boolean getFeature(String name)
Return the current value of the feature with given name.
boolean isNamespaceAware()
Indicates whether or not the factory is configured to produce parsers which are namespace aware (it simply set feature XmlPullParser.FEATURE_PROCESS_NAMESPACES to true or false).
boolean isValidating()
Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.
static XmlPullParserFactory newInstance()
Create a new instance of a PullParserFactory that can be used to create XML pull parsers (see class description for more details).
static XmlPullParserFactory newInstance(String classNames, Class context)
XmlPullParser newPullParser()
Creates a new instance of a XML Pull Parser using the currently configured factory features.
XmlSerializer newSerializer()
Creates a new instance of a XML Serializer.
void setFeature(String name, boolean state)
Set the features to be set when XML Pull Parser is created by this factory.
void setNamespaceAware(boolean awareness)
Specifies that the parser produced by this factory will provide support for XML namespaces.
void setValidating(boolean validating)
Specifies that the parser produced by this factory will be validating (it simply set feature XmlPullParser.FEATURE_VALIDATION to true or false).
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String PROPERTY_NAME

Since: API Level 1

Name of the system or midlet property that should be used for a system property containing a comma separated list of factory or parser class names (value: org.xmlpull.v1.XmlPullParserFactory).

Constant Value: "org.xmlpull.v1.XmlPullParserFactory"

Fields

protected String classNamesLocation

Since: API Level 1

protected HashMap features

Since: API Level 1

protected ArrayList parserClasses

Since: API Level 1

protected ArrayList serializerClasses

Since: API Level 1

Protected Constructors

protected XmlPullParserFactory ()

Since: API Level 1

Protected constructor to be called by factory implementations.

Public Methods

public boolean getFeature (String name)

Since: API Level 1

Return the current value of the feature with given name.

NOTE: factory features are not used for XML Serializer.

Parameters
name The name of feature to be retrieved.
Returns
  • The value of named feature. Unknown features are always returned as false

public boolean isNamespaceAware ()

Since: API Level 1

Indicates whether or not the factory is configured to produce parsers which are namespace aware (it simply set feature XmlPullParser.FEATURE_PROCESS_NAMESPACES to true or false).

Returns
  • true if the factory is configured to produce parsers which are namespace aware; false otherwise.

public boolean isValidating ()

Since: API Level 1

Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.

Returns
  • true if the factory is configured to produce parsers which validate the XML content during parse; false otherwise.

public static XmlPullParserFactory newInstance ()

Since: API Level 1

Create a new instance of a PullParserFactory that can be used to create XML pull parsers (see class description for more details).

Returns
  • a new instance of a PullParserFactory, as returned by newInstance (null, null);

public static XmlPullParserFactory newInstance (String classNames, Class context)

Since: API Level 1

public XmlPullParser newPullParser ()

Since: API Level 1

Creates a new instance of a XML Pull Parser using the currently configured factory features.

Returns
  • A new instance of a XML Pull Parser.
Throws
XmlPullParserException if a parser cannot be created which satisfies the requested configuration.

public XmlSerializer newSerializer ()

Since: API Level 1

Creates a new instance of a XML Serializer.

NOTE: factory features are not used for XML Serializer.

Returns
  • A new instance of a XML Serializer.
Throws
XmlPullParserException if a parser cannot be created which satisfies the requested configuration.

public void setFeature (String name, boolean state)

Since: API Level 1

Set the features to be set when XML Pull Parser is created by this factory.

NOTE: factory features are not used for XML Serializer.

Parameters
name string with URI identifying feature
state if true feature will be set; if false will be ignored

public void setNamespaceAware (boolean awareness)

Since: API Level 1

Specifies that the parser produced by this factory will provide support for XML namespaces. By default the value of this is set to false.

Parameters
awareness true if the parser produced by this code will provide support for XML namespaces; false otherwise.

public void setValidating (boolean validating)

Since: API Level 1

Specifies that the parser produced by this factory will be validating (it simply set feature XmlPullParser.FEATURE_VALIDATION to true or false). By default the value of this is set to false.

Parameters
validating - if true the parsers created by this factory must be validating.