APIdia Launch Partner
Top Description Fields Constructors Methods
javax.xml.stream

public abstract Class XMLEventFactory

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.xml.internal.stream.events.XMLEventFactoryImpl
Imports
com.sun.xml.internal.stream.events.XMLEventFactoryImpl, java.util.Iterator, javax.xml.namespace.NamespaceContext, .QName, javax.xml.stream.events.*

This interface defines a utility class for creating instances of XMLEvents
Author
Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
Since
1.6
Version
1.2
See Also
javax.xml.stream.events.StartElement, javax.xml.stream.events.EndElement, javax.xml.stream.events.ProcessingInstruction, javax.xml.stream.events.Comment, javax.xml.stream.events.Characters, javax.xml.stream.events.StartDocument, javax.xml.stream.events.EndDocument, javax.xml.stream.events.DTD

Field Summary

Modifier and TypeField and Description
pack-priv static final String
pack-priv static final String

Constructor Summary

AccessConstructor and Description
protected
XMLEventFactory()

Protected constructor to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
public abstract Attribute

Returns:

the Attribute with specified values
createAttribute
(String
the prefix of this attribute, may not be null
prefix
,
String
the attribute value is set to this value, may not be null
namespaceURI
,
String
the local name of the XML name of the attribute, localName cannot be null
localName
,
String
the attribute value to set, may not be null
value
)

Create a new Attribute

public abstract Attribute

Returns:

the Attribute with specified values
createAttribute
(String
the local name of the XML name of the attribute, localName cannot be null
localName
,
String
the attribute value to set, may not be null
value
)

Create a new Attribute

public abstract Attribute

Returns:

the Attribute with specified values
createAttribute
(QName
the qualified name of the attribute, may not be null
name
,
String
the attribute value to set, may not be null
value
)

Create a new Attribute

public abstract Characters

Returns:

a Characters event
createCData
(String
the string to create
content
)

Create a Characters event with the CData flag set to true

public abstract Characters

Returns:

a Characters event
createCharacters
(String
the string to create
content
)

Create a Characters event, this method does not check if the content is all whitespace.

public abstract Comment

Returns:

a Comment event
createComment
(String
The text of the comment
text
)

Create a comment.

public abstract DTD

Returns:

a DTD event
createDTD
(String
the text of the document type definition
dtd
)

Create a document type definition event This string contains the entire document type declaration that matches the doctypedecl in the XML 1.0 specification

public abstract EndDocument

Returns:

an EndDocument event
createEndDocument
()

Creates a new instance of an EndDocument event

public abstract EndElement

Returns:

an instance of the requested EndElement
createEndElement
(QName
the qualified name of the EndElement
name
,
Iterator<? extends Namespace>
an optional unordered set of objects that implement Namespace that have gone out of scope, may be null
namespaces
)

Create a new EndElement

public abstract EndElement

Returns:

an instance of the requested EndElement
createEndElement
(String
the prefix of the QName of the new StartElement
prefix
,
String
the uri of the QName of the new StartElement
namespaceUri
,
String
the local name of the QName of the new StartElement
localName
)

Create a new EndElement

public abstract EndElement

Returns:

an instance of the requested EndElement
createEndElement
(String
the prefix of the QName of the new StartElement
prefix
,
String
the uri of the QName of the new StartElement
namespaceUri
,
String
the local name of the QName of the new StartElement
localName
,
Iterator<? extends Namespace>
an unordered set of objects that implement Namespace that have gone out of scope, may be null
namespaces
)

Create a new EndElement

public abstract EntityReference

Returns:

an EntityReference event
createEntityReference
(String
The name of the reference
name
,
EntityDeclaration
the declaration for the event
declaration
)

Creates a new instance of a EntityReference event

public abstract Characters

Returns:

a Characters event
createIgnorableSpace
(String
the space to create
content
)

Create an ignorable space

public abstract Namespace

Returns:

the Namespace with the specified value
createNamespace
(String
the default namespace uri
namespaceURI
)

Create a new default Namespace

public abstract Namespace

Returns:

the Namespace with the specified values
createNamespace
(String
the prefix of this namespace, may not be null
prefix
,
String
the attribute value is set to this value, may not be null
namespaceUri
)

Create a new Namespace

public abstract ProcessingInstruction

Returns:

a ProcessingInstruction event
createProcessingInstruction
(String
The target of the processing instruction
target
,
String
The text of the processing instruction
data
)

Create a processing instruction

public abstract Characters

Returns:

a Characters event
createSpace
(String
the content of the space to create
content
)

Create a Characters event with the isSpace flag set to true

public abstract StartDocument

Returns:

a StartDocument event
createStartDocument
()

Creates a new instance of a StartDocument event

public abstract StartDocument

Returns:

a StartDocument event
createStartDocument
(String
the encoding style
encoding
,
String
the XML version
version
,
boolean
the status of standalone may be set to "true" or "false"
standalone
)

Creates a new instance of a StartDocument event

public abstract StartDocument

Returns:

a StartDocument event
createStartDocument
(String
the encoding style
encoding
,
String
the XML version
version
)

Creates a new instance of a StartDocument event

public abstract StartDocument

Returns:

a StartDocument event
createStartDocument
(String
the encoding style
encoding
)

Creates a new instance of a StartDocument event

public abstract StartElement

Returns:

an instance of the requested StartElement
createStartElement
(QName
the qualified name of the attribute, may not be null
name
,
Iterator<? extends Attribute>
an optional unordered set of objects that implement Attribute to add to the new StartElement, may be null
attributes
,
Iterator<? extends Namespace>
an optional unordered set of objects that implement Namespace to add to the new StartElement, may be null
namespaces
)

Create a new StartElement.

public abstract StartElement

Returns:

an instance of the requested StartElement
createStartElement
(String
the prefix of the QName of the new StartElement
prefix
,
String
the uri of the QName of the new StartElement
namespaceUri
,
String
the local name of the QName of the new StartElement
localName
)

Create a new StartElement.

public abstract StartElement

Returns:

an instance of the requested StartElement
createStartElement
(String
the prefix of the QName of the new StartElement
prefix
,
String
the uri of the QName of the new StartElement
namespaceUri
,
String
the local name of the QName of the new StartElement
localName
,
Iterator<? extends Attribute>
an unordered set of objects that implement Attribute to add to the new StartElement
attributes
,
Iterator<? extends Namespace>
an unordered set of objects that implement Namespace to add to the new StartElement
namespaces
)

Create a new StartElement.

public abstract StartElement

Returns:

an instance of the requested StartElement
createStartElement
(String
the prefix of the QName of the new StartElement
prefix
,
String
the uri of the QName of the new StartElement
namespaceUri
,
String
the local name of the QName of the new StartElement
localName
,
Iterator<? extends Attribute>
an unordered set of objects that implement Attribute to add to the new StartElement, may be null
attributes
,
Iterator<? extends Namespace>
an unordered set of objects that implement Namespace to add to the new StartElement, may be null
namespaces
,
NamespaceContext
the namespace context of this element
context
)

Create a new StartElement.

public static XMLEventFactory

Returns:

A new instance of the XMLEventFactory builtin system-default implementation.
newDefaultFactory
()

Creates a new instance of the XMLEventFactory builtin system-default implementation.

public static XMLEventFactory

Returns:

an instance of the XMLEventFactory
newFactory
()

Creates a new instance of the factory.

public static XMLEventFactory

Returns:

the factory implementation
newFactory
(String
Name of the factory to find, same as a property name
factoryId
,
ClassLoader
classLoader to use
classLoader
)

Create a new instance of the factory.

public static XMLEventFactory

Returns:

an instance of the XMLEventFactory
newInstance
()

Creates a new instance of the factory in exactly the same manner as the newFactory() method.

public static XMLEventFactory

Returns:

the factory implementation
newInstance
(String
Name of the factory to find, same as a property name
factoryId
,
ClassLoader
classLoader to use
classLoader
)
Deprecated since 1.7. This method has been deprecated to maintain API consistency.

Create a new instance of the factory

public abstract void
setLocation(Location
the location to set on each event created
location
)

This method allows setting of the Location on each event that is created by this factory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULIMPLback to summary
pack-priv static final String DEFAULIMPL
JAXPFACTORYIDback to summary
pack-priv static final String JAXPFACTORYID

Constructor Detail

XMLEventFactoryback to summary
protected XMLEventFactory()

Protected constructor to prevent instantiation. Use newFactory() instead.

Method Detail

createAttributeback to summary
public abstract Attribute createAttribute(String prefix, String namespaceURI, String localName, String value)

Create a new Attribute

Parameters
prefix:String

the prefix of this attribute, may not be null

namespaceURI:String

the attribute value is set to this value, may not be null

localName:String

the local name of the XML name of the attribute, localName cannot be null

value:String

the attribute value to set, may not be null

Returns:Attribute

the Attribute with specified values

createAttributeback to summary
public abstract Attribute createAttribute(String localName, String value)

Create a new Attribute

Parameters
localName:String

the local name of the XML name of the attribute, localName cannot be null

value:String

the attribute value to set, may not be null

Returns:Attribute

the Attribute with specified values

createAttributeback to summary
public abstract Attribute createAttribute(QName name, String value)

Create a new Attribute

Parameters
name:QName

the qualified name of the attribute, may not be null

value:String

the attribute value to set, may not be null

Returns:Attribute

the Attribute with specified values

createCDataback to summary
public abstract Characters createCData(String content)

Create a Characters event with the CData flag set to true

Parameters
content:String

the string to create

Returns:Characters

a Characters event

createCharactersback to summary
public abstract Characters createCharacters(String content)

Create a Characters event, this method does not check if the content is all whitespace. To create a space event use #createSpace(String)

Parameters
content:String

the string to create

Returns:Characters

a Characters event

createCommentback to summary
public abstract Comment createComment(String text)

Create a comment.

Parameters
text:String

The text of the comment

Returns:Comment

a Comment event

createDTDback to summary
public abstract DTD createDTD(String dtd)

Create a document type definition event This string contains the entire document type declaration that matches the doctypedecl in the XML 1.0 specification

Parameters
dtd:String

the text of the document type definition

Returns:DTD

a DTD event

createEndDocumentback to summary
public abstract EndDocument createEndDocument()

Creates a new instance of an EndDocument event

Returns:EndDocument

an EndDocument event

createEndElementback to summary
public abstract EndElement createEndElement(QName name, Iterator<? extends Namespace> namespaces)

Create a new EndElement

Parameters
name:QName

the qualified name of the EndElement

namespaces:Iterator<? extends Namespace>

an optional unordered set of objects that implement Namespace that have gone out of scope, may be null

Returns:EndElement

an instance of the requested EndElement

createEndElementback to summary
public abstract EndElement createEndElement(String prefix, String namespaceUri, String localName)

Create a new EndElement

Parameters
prefix:String

the prefix of the QName of the new StartElement

namespaceUri:String

the uri of the QName of the new StartElement

localName:String

the local name of the QName of the new StartElement

Returns:EndElement

an instance of the requested EndElement

createEndElementback to summary
public abstract EndElement createEndElement(String prefix, String namespaceUri, String localName, Iterator<? extends Namespace> namespaces)

Create a new EndElement

Parameters
prefix:String

the prefix of the QName of the new StartElement

namespaceUri:String

the uri of the QName of the new StartElement

localName:String

the local name of the QName of the new StartElement

namespaces:Iterator<? extends Namespace>

an unordered set of objects that implement Namespace that have gone out of scope, may be null

Returns:EndElement

an instance of the requested EndElement

createEntityReferenceback to summary
public abstract EntityReference createEntityReference(String name, EntityDeclaration declaration)

Creates a new instance of a EntityReference event

Parameters
name:String

The name of the reference

declaration:EntityDeclaration

the declaration for the event

Returns:EntityReference

an EntityReference event

createIgnorableSpaceback to summary
public abstract Characters createIgnorableSpace(String content)

Create an ignorable space

Parameters
content:String

the space to create

Returns:Characters

a Characters event

createNamespaceback to summary
public abstract Namespace createNamespace(String namespaceURI)

Create a new default Namespace

Parameters
namespaceURI:String

the default namespace uri

Returns:Namespace

the Namespace with the specified value

createNamespaceback to summary
public abstract Namespace createNamespace(String prefix, String namespaceUri)

Create a new Namespace

Parameters
prefix:String

the prefix of this namespace, may not be null

namespaceUri:String

the attribute value is set to this value, may not be null

Returns:Namespace

the Namespace with the specified values

createProcessingInstructionback to summary
public abstract ProcessingInstruction createProcessingInstruction(String target, String data)

Create a processing instruction

Parameters
target:String

The target of the processing instruction

data:String

The text of the processing instruction

Returns:ProcessingInstruction

a ProcessingInstruction event

createSpaceback to summary
public abstract Characters createSpace(String content)

Create a Characters event with the isSpace flag set to true

Parameters
content:String

the content of the space to create

Returns:Characters

a Characters event

createStartDocumentback to summary
public abstract StartDocument createStartDocument()

Creates a new instance of a StartDocument event

Returns:StartDocument

a StartDocument event

createStartDocumentback to summary
public abstract StartDocument createStartDocument(String encoding, String version, boolean standalone)

Creates a new instance of a StartDocument event

Parameters
encoding:String

the encoding style

version:String

the XML version

standalone:boolean

the status of standalone may be set to "true" or "false"

Returns:StartDocument

a StartDocument event

createStartDocumentback to summary
public abstract StartDocument createStartDocument(String encoding, String version)

Creates a new instance of a StartDocument event

Parameters
encoding:String

the encoding style

version:String

the XML version

Returns:StartDocument

a StartDocument event

createStartDocumentback to summary
public abstract StartDocument createStartDocument(String encoding)

Creates a new instance of a StartDocument event

Parameters
encoding:String

the encoding style

Returns:StartDocument

a StartDocument event

createStartElementback to summary
public abstract StartElement createStartElement(QName name, Iterator<? extends Attribute> attributes, Iterator<? extends Namespace> namespaces)

Create a new StartElement. Namespaces can be added to this StartElement by passing in an Iterator that walks over a set of Namespace interfaces. Attributes can be added to this StartElement by passing an iterator that walks over a set of Attribute interfaces.

Parameters
name:QName

the qualified name of the attribute, may not be null

attributes:Iterator<? extends Attribute>

an optional unordered set of objects that implement Attribute to add to the new StartElement, may be null

namespaces:Iterator<? extends Namespace>

an optional unordered set of objects that implement Namespace to add to the new StartElement, may be null

Returns:StartElement

an instance of the requested StartElement

createStartElementback to summary
public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName)

Create a new StartElement. This defaults the NamespaceContext to an empty NamespaceContext. Querying this event for its namespaces or attributes will result in an empty iterator being returned.

Parameters
prefix:String

the prefix of the QName of the new StartElement

namespaceUri:String

the uri of the QName of the new StartElement

localName:String

the local name of the QName of the new StartElement

Returns:StartElement

an instance of the requested StartElement

createStartElementback to summary
public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator<? extends Attribute> attributes, Iterator<? extends Namespace> namespaces)

Create a new StartElement. Namespaces can be added to this StartElement by passing in an Iterator that walks over a set of Namespace interfaces. Attributes can be added to this StartElement by passing an iterator that walks over a set of Attribute interfaces.

Parameters
prefix:String

the prefix of the QName of the new StartElement

namespaceUri:String

the uri of the QName of the new StartElement

localName:String

the local name of the QName of the new StartElement

attributes:Iterator<? extends Attribute>

an unordered set of objects that implement Attribute to add to the new StartElement

namespaces:Iterator<? extends Namespace>

an unordered set of objects that implement Namespace to add to the new StartElement

Returns:StartElement

an instance of the requested StartElement

createStartElementback to summary
public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator<? extends Attribute> attributes, Iterator<? extends Namespace> namespaces, NamespaceContext context)

Create a new StartElement. Namespaces can be added to this StartElement by passing in an Iterator that walks over a set of Namespace interfaces. Attributes can be added to this StartElement by passing an iterator that walks over a set of Attribute interfaces.

Parameters
prefix:String

the prefix of the QName of the new StartElement

namespaceUri:String

the uri of the QName of the new StartElement

localName:String

the local name of the QName of the new StartElement

attributes:Iterator<? extends Attribute>

an unordered set of objects that implement Attribute to add to the new StartElement, may be null

namespaces:Iterator<? extends Namespace>

an unordered set of objects that implement Namespace to add to the new StartElement, may be null

context:NamespaceContext

the namespace context of this element

Returns:StartElement

an instance of the requested StartElement

newDefaultFactoryback to summary
public static XMLEventFactory newDefaultFactory()

Creates a new instance of the XMLEventFactory builtin system-default implementation.

Returns:XMLEventFactory

A new instance of the XMLEventFactory builtin system-default implementation.

Since
9
newFactoryback to summary
public static XMLEventFactory newFactory() throws FactoryConfigurationError

Creates a new instance of the factory. This method uses the JAXP Lookup Mechanism to determine the XMLEventFactory implementation class to load.

Once an application has obtained a reference to a XMLEventFactory, it can use the factory to configure and obtain stream instances.

Returns:XMLEventFactory

an instance of the XMLEventFactory

Exceptions
FactoryConfigurationError:
in case of service configuration error or if the implementation is not available or cannot be instantiated.
newFactoryback to summary
public static XMLEventFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError

Create a new instance of the factory. If the classLoader argument is null, then the ContextClassLoader is used.

This method uses the following ordered lookup procedure to determine the XMLEventFactory implementation class to load:

  • Use the value of the system property identified by factoryId.
  • Use the value of the property factoryId set in the configuration file, jaxp.properties by default. If the file exists and the property factoryId is specified in the file, its value will be used as the implementation class.

  • If factoryId is "javax.xml.stream.XMLEventFactory", use the service-provider loading facility, defined by the java.util.ServiceLoader class, to attempt to locate and load an implementation of the service using the specified ClassLoader. If classLoader is null, the default loading mechanism will apply: That is, the service-provider loading facility will use the current thread's context class loader to attempt to load the service. If the context class loader is null, the system class loader will be used.

  • Otherwise, throws a FactoryConfigurationError.

Note that this is a new method that replaces the deprecated newInstance(String factoryId, ClassLoader classLoader) method. No changes in behavior are defined by this replacement method relative to the deprecated method.

API Note

The parameter factoryId defined here is inconsistent with that of other JAXP factories where the first parameter is fully qualified factory class name that provides implementation of the factory.

Parameters
factoryId:String

Name of the factory to find, same as a property name

classLoader:ClassLoader

classLoader to use

Returns:XMLEventFactory

the factory implementation

Exceptions
FactoryConfigurationError:
in case of service configuration error or if the implementation is not available or cannot be instantiated.
newInstanceback to summary
public static XMLEventFactory newInstance() throws FactoryConfigurationError

Creates a new instance of the factory in exactly the same manner as the newFactory() method.

Returns:XMLEventFactory

an instance of the XMLEventFactory

Exceptions
FactoryConfigurationError:
if an instance of this factory cannot be loaded
newInstanceback to summary
public static XMLEventFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError

Deprecated

since 1.7.

This method has been deprecated to maintain API consistency. All newInstance methods have been replaced with corresponding newFactory methods. The replacement newFactory(java.lang.String, java.lang.ClassLoader) method defines no changes in behavior.

Create a new instance of the factory

Parameters
factoryId:String

Name of the factory to find, same as a property name

classLoader:ClassLoader

classLoader to use

Returns:XMLEventFactory

the factory implementation

Annotations
@Deprecated
since:1.7
Exceptions
FactoryConfigurationError:
if an instance of this factory cannot be loaded
setLocationback to summary
public abstract void setLocation(Location location)

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.

Parameters
location:Location

the location to set on each event created