- java.lang.Object
-
- javax.xml.stream.XMLEventFactory
-
public abstract class XMLEventFactory extends Object
This interface defines a utility class for creating instances of XMLEvents- Since:
- 1.6
- See Also:
StartElement
,EndElement
,ProcessingInstruction
,Comment
,Characters
,StartDocument
,EndDocument
,DTD
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
XMLEventFactory()
-
Method Summary
Methods Modifier and Type Method and Description abstract Attribute
createAttribute(QName name, String value)
Create a new Attributeabstract Attribute
createAttribute(String localName, String value)
Create a new Attributeabstract Attribute
createAttribute(String prefix, String namespaceURI, String localName, String value)
Create a new Attributeabstract Characters
createCData(String content)
Create a Characters event with the CData flag set to trueabstract Characters
createCharacters(String content)
Create a Characters event, this method does not check if the content is all whitespace.abstract Comment
createComment(String text)
Create a commentabstract 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 specificationabstract EndDocument
createEndDocument()
Creates a new instance of an EndDocument eventabstract EndElement
createEndElement(QName name, Iterator namespaces)
Create a new EndElementabstract EndElement
createEndElement(String prefix, String namespaceUri, String localName)
Create a new EndElementabstract EndElement
createEndElement(String prefix, String namespaceUri, String localName, Iterator namespaces)
Create a new EndElementabstract EntityReference
createEntityReference(String name, EntityDeclaration declaration)
Creates a new instance of a EntityReference eventabstract Characters
createIgnorableSpace(String content)
Create an ignorable spaceabstract Namespace
createNamespace(String namespaceURI)
Create a new default Namespaceabstract Namespace
createNamespace(String prefix, String namespaceUri)
Create a new Namespaceabstract ProcessingInstruction
createProcessingInstruction(String target, String data)
Create a processing instructionabstract Characters
createSpace(String content)
Create a Characters event with the isSpace flag set to trueabstract StartDocument
createStartDocument()
Creates a new instance of a StartDocument eventabstract StartDocument
createStartDocument(String encoding)
Creates a new instance of a StartDocument eventabstract StartDocument
createStartDocument(String encoding, String version)
Creates a new instance of a StartDocument eventabstract StartDocument
createStartDocument(String encoding, String version, boolean standalone)
Creates a new instance of a StartDocument eventabstract StartElement
createStartElement(QName name, Iterator attributes, Iterator namespaces)
Create a new StartElement.abstract StartElement
createStartElement(String prefix, String namespaceUri, String localName)
Create a new StartElement.abstract StartElement
createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator namespaces)
Create a new StartElement.abstract StartElement
createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator namespaces, NamespaceContext context)
Create a new StartElement.static XMLEventFactory
newFactory()
Create a new instance of the factory.static XMLEventFactory
newFactory(String factoryId, ClassLoader classLoader)
Create a new instance of the factory.static XMLEventFactory
newInstance()
Create a new instance of the factorystatic XMLEventFactory
newInstance(String factoryId, ClassLoader classLoader)
Deprecated.This method has been deprecated to maintain API consistency. All newInstance methods have been replaced with corresponding newFactory methods. The replacementnewFactory(java.lang.String, java.lang.ClassLoader)
method defines no changes in behavior.abstract void
setLocation(Location location)
This method allows setting of the Location on each event that is created by this factory.
-
-
-
Method Detail
-
newInstance
public static XMLEventFactory newInstance() throws FactoryConfigurationError
Create a new instance of the factory- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newFactory
public static XMLEventFactory newFactory() throws FactoryConfigurationError
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 XMLEventFactory implementation class to load: Use the javax.xml.stream.XMLEventFactory 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.XMLEventFactory in jars available to the runtime. Platform default XMLEventFactory instance. Once an application has obtained a reference to a XMLEventFactory it can use the factory to configure and obtain stream instances. Note that this is a new method that replaces the deprecated newInstance() method. No changes in behavior are defined by this replacement method relative to the deprecated method.- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newInstance
public static XMLEventFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
Deprecated. This method has been deprecated to maintain API consistency. All newInstance methods have been replaced with corresponding newFactory methods. The replacementnewFactory(java.lang.String, java.lang.ClassLoader)
method defines no changes in behavior.Create a new instance of the factory- Parameters:
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to use- Returns:
- the factory implementation
- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newFactory
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. 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.- Parameters:
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to use- Returns:
- the factory implementation
- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
setLocation
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
- the location to set on each event created
-
createAttribute
public abstract Attribute createAttribute(String prefix, String namespaceURI, String localName, String value)
Create a new Attribute- Parameters:
prefix
- the prefix of this attribute, may not be nullnamespaceURI
- the attribute value is set to this value, may not be nulllocalName
- the local name of the XML name of the attribute, localName cannot be nullvalue
- the attribute value to set, may not be null- Returns:
- the Attribute with specified values
-
createAttribute
public abstract Attribute createAttribute(String localName, String value)
Create a new Attribute- Parameters:
localName
- the local name of the XML name of the attribute, localName cannot be nullvalue
- the attribute value to set, may not be null- Returns:
- the Attribute with specified values
-
createAttribute
public abstract Attribute createAttribute(QName name, String value)
Create a new Attribute- Parameters:
name
- the qualified name of the attribute, may not be nullvalue
- the attribute value to set, may not be null- Returns:
- the Attribute with specified values
-
createNamespace
public abstract Namespace createNamespace(String namespaceURI)
Create a new default Namespace- Parameters:
namespaceURI
- the default namespace uri- Returns:
- the Namespace with the specified value
-
createNamespace
public abstract Namespace createNamespace(String prefix, String namespaceUri)
Create a new Namespace- Parameters:
prefix
- the prefix of this namespace, may not be nullnamespaceUri
- the attribute value is set to this value, may not be null- Returns:
- the Namespace with the specified values
-
createStartElement
public abstract StartElement createStartElement(QName name, Iterator attributes, Iterator 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
- the qualified name of the attribute, may not be nullattributes
- an optional unordered set of objects that implement Attribute to add to the new StartElement, may be nullnamespaces
- an optional unordered set of objects that implement Namespace to add to the new StartElement, may be null- Returns:
- an instance of the requested StartElement
-
createStartElement
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:
namespaceUri
- the uri of the QName of the new StartElementlocalName
- the local name of the QName of the new StartElementprefix
- the prefix of the QName of the new StartElement- Returns:
- an instance of the requested StartElement
-
createStartElement
public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator 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:
namespaceUri
- the uri of the QName of the new StartElementlocalName
- the local name of the QName of the new StartElementprefix
- the prefix of the QName of the new StartElementattributes
- an unordered set of objects that implement Attribute to add to the new StartElementnamespaces
- an unordered set of objects that implement Namespace to add to the new StartElement- Returns:
- an instance of the requested StartElement
-
createStartElement
public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator attributes, Iterator 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:
namespaceUri
- the uri of the QName of the new StartElementlocalName
- the local name of the QName of the new StartElementprefix
- the prefix of the QName of the new StartElementattributes
- an unordered set of objects that implement Attribute to add to the new StartElement, may be nullnamespaces
- an unordered set of objects that implement Namespace to add to the new StartElement, may be nullcontext
- the namespace context of this element- Returns:
- an instance of the requested StartElement
-
createEndElement
public abstract EndElement createEndElement(QName name, Iterator namespaces)
Create a new EndElement- Parameters:
name
- the qualified name of the EndElementnamespaces
- an optional unordered set of objects that implement Namespace that have gone out of scope, may be null- Returns:
- an instance of the requested EndElement
-
createEndElement
public abstract EndElement createEndElement(String prefix, String namespaceUri, String localName)
Create a new EndElement- Parameters:
namespaceUri
- the uri of the QName of the new StartElementlocalName
- the local name of the QName of the new StartElementprefix
- the prefix of the QName of the new StartElement- Returns:
- an instance of the requested EndElement
-
createEndElement
public abstract EndElement createEndElement(String prefix, String namespaceUri, String localName, Iterator namespaces)
Create a new EndElement- Parameters:
namespaceUri
- the uri of the QName of the new StartElementlocalName
- the local name of the QName of the new StartElementprefix
- the prefix of the QName of the new StartElementnamespaces
- an unordered set of objects that implement Namespace that have gone out of scope, may be null- Returns:
- an instance of the requested EndElement
-
createCharacters
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
- the string to create- Returns:
- a Characters event
-
createCData
public abstract Characters createCData(String content)
Create a Characters event with the CData flag set to true- Parameters:
content
- the string to create- Returns:
- a Characters event
-
createSpace
public abstract Characters createSpace(String content)
Create a Characters event with the isSpace flag set to true- Parameters:
content
- the content of the space to create- Returns:
- a Characters event
-
createIgnorableSpace
public abstract Characters createIgnorableSpace(String content)
Create an ignorable space- Parameters:
content
- the space to create- Returns:
- a Characters event
-
createStartDocument
public abstract StartDocument createStartDocument()
Creates a new instance of a StartDocument event- Returns:
- a StartDocument event
-
createStartDocument
public abstract StartDocument createStartDocument(String encoding, String version, boolean standalone)
Creates a new instance of a StartDocument event- Parameters:
encoding
- the encoding styleversion
- the XML versionstandalone
- the status of standalone may be set to "true" or "false"- Returns:
- a StartDocument event
-
createStartDocument
public abstract StartDocument createStartDocument(String encoding, String version)
Creates a new instance of a StartDocument event- Parameters:
encoding
- the encoding styleversion
- the XML version- Returns:
- a StartDocument event
-
createStartDocument
public abstract StartDocument createStartDocument(String encoding)
Creates a new instance of a StartDocument event- Parameters:
encoding
- the encoding style- Returns:
- a StartDocument event
-
createEndDocument
public abstract EndDocument createEndDocument()
Creates a new instance of an EndDocument event- Returns:
- an EndDocument event
-
createEntityReference
public abstract EntityReference createEntityReference(String name, EntityDeclaration declaration)
Creates a new instance of a EntityReference event- Parameters:
name
- The name of the referencedeclaration
- the declaration for the event- Returns:
- an EntityReference event
-
createComment
public abstract Comment createComment(String text)
Create a comment- Parameters:
text
- The text of the comment a Comment event
-
createProcessingInstruction
public abstract ProcessingInstruction createProcessingInstruction(String target, String data)
Create a processing instruction- Parameters:
target
- The target of the processing instructiondata
- The text of the processing instruction- Returns:
- a ProcessingInstruction event
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/xml/stream/xmleventfactory.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.