XMLInputFactory (Java EE 5)

Java EE API


javax.xml.stream Class XMLInputFactory

java.lang.Object
  extended by javax.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

Version:
1.0
Author:
Copyright (c) 2003 by BEA Systems. All Rights Reserved.
See Also:
XMLOutputFactory, XMLEventReader, XMLStreamReader, EventFilter, XMLReporter, XMLResolver, XMLEventAllocator

Field Summary
static String
static String
static String
static String
static String
static String
static String
static String
static String
 
Constructor Summary
protected
 
Method Summary
abstract  XMLEventReader
abstract  XMLStreamReader
abstract  XMLEventReader
abstract  XMLEventReader
abstract  XMLEventReader
abstract  XMLEventReader
abstract  XMLEventReader
abstract  XMLEventReader
abstract  XMLEventReader
abstract  XMLStreamReader
abstract  XMLStreamReader
abstract  XMLStreamReader
abstract  XMLStreamReader
abstract  XMLStreamReader
abstract  XMLStreamReader
abstract  XMLEventAllocator
abstract  Object
abstract  XMLReporter
abstract  XMLResolver
abstract  boolean
static XMLInputFactory
static XMLInputFactory
abstract  void
abstract  void
abstract  void
abstract  void
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

IS_NAMESPACE_AWARE

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

See Also:
Constant Field Values


英文文档:

IS_VALIDATING

public static final String IS_VALIDATING
The property used to turn on/off implementation specific validation

See Also:
Constant Field Values


英文文档:

IS_COALESCING

public static final String IS_COALESCING
The property that requires the parser to coalesce adjacent character data sections

See Also:
Constant Field Values


英文文档:

IS_REPLACING_ENTITY_REFERENCES

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

See Also:
Constant Field Values


英文文档:

IS_SUPPORTING_EXTERNAL_ENTITIES

public static final String IS_SUPPORTING_EXTERNAL_ENTITIES
The property that requires the parser to resolve external parsed entities

See Also:
Constant Field Values


英文文档:

SUPPORT_DTD

public static final String SUPPORT_DTD
The property that requires the parser to support DTDs

See Also:
Constant Field Values


英文文档:

REPORTER

public static final String REPORTER
The property used to set/get the implementation of the XMLReporter interface

See Also:
Constant Field Values


英文文档:

RESOLVER

public static final String RESOLVER
The property used to set/get the implementation of the XMLResolver

See Also:
Constant Field Values


英文文档:

ALLOCATOR

public static final String ALLOCATOR
The property used to set/get the implementation of the allocator

See Also:
Constant Field Values

Constructor Detail

protected XMLInputFactory()
英文文档:

XMLInputFactory

protected XMLInputFactory()
Method Detail

public static XMLInputFactory newInstance() throws FactoryConfigurationError
创建一个新的工厂实例。此 static 方法创建一个新的工厂实例。此方法按照以下查找过程顺序来确定要加载的 XMLInputFactory 实现类:使用 javax.xml.stream.XMLInputFactory 系统属性。使用 JRE 目录中的属性文件 "lib/stax.properties"。此配置文件是标准的 java.util.Properties 格式,且包含实现类的完全限定名,其中实现类的键是上文定义的系统属性。如果 Services API(在 JAR 规范中进行了详细描述)可用,可以使用它来确定类名称。Services API 将在运行时可用的 jar 文件 META-INF/services/javax.xml.stream.XMLInputFactory 中查找类名称。平台默认的 XMLInputFactory 实例。应用程序获取对 XMLInputFactory 的引用后,它可以使用工厂来配置和获取流实例。
ThrowsFactoryConfigurationError: 如果无法加载此工厂的实例
英文文档:

newInstance

public static XMLInputFactory newInstance()
                                   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 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

public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
创建一个的新工厂实例。
factoryId 要查找的工厂的名称,与属性名称相同
classLoader 要使用的类加载器
return 工厂实现
ThrowsFactoryConfigurationError: 如果无法加载此工厂的实例
英文文档:

newInstance

public static XMLInputFactory newInstance(String factoryId,
                                          ClassLoader classLoader)
                                   throws FactoryConfigurationError
Create a new instance of the factory

Parameters:
factoryId - Name of the factory to find, same as a property name
classLoader - classLoader to use
Returns:
the factory implementation
Throws:
FactoryConfigurationError - if an instance of this factory cannot be loaded

abstract public XMLStreamReader createXMLStreamReader(java.io.Reader reader) throws XMLStreamException
根据 reader 创建一个新 XMLStreamReader。
reader 要从中读取 XMLEventReader 的 XML 数据
ThrowsXMLStreamException:
英文文档:

createXMLStreamReader

public abstract XMLStreamReader createXMLStreamReader(Reader reader)
                                               throws XMLStreamException
Create a new XMLStreamReader from a reader

Parameters:
reader - the XML data to read from
Throws:
XMLStreamException

abstract public XMLStreamReader createXMLStreamReader(javax.xml.transform.Source source) throws XMLStreamException
根据 JAXP 源创建一个新 XMLStreamReader。此方法是可选的。
source 要从中读取 XMLEventReader 的源
ThrowsUnsupportedOperationException: 如果 XMLInputFactory 不支持此方法
ThrowsXMLStreamException:
英文文档:

createXMLStreamReader

public abstract XMLStreamReader createXMLStreamReader(Source source)
                                               throws XMLStreamException
Create a new XMLStreamReader from a JAXP source. This method is optional.

Parameters:
source - the source to read from
Throws:
UnsupportedOperationException - if this method is not supported by this XMLInputFactory
XMLStreamException

abstract public XMLStreamReader createXMLStreamReader(java.io.InputStream stream) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLStreamReader。
stream 要从中读取 XMLEventReader 的 InputStream
ThrowsXMLStreamException:
英文文档:

createXMLStreamReader

public abstract XMLStreamReader createXMLStreamReader(InputStream stream)
                                               throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream

Parameters:
stream - the InputStream to read from
Throws:
XMLStreamException

abstract public XMLStreamReader createXMLStreamReader(java.io.InputStream stream, String encoding) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLStreamReader。
stream 要从中读取 XMLEventReader 的 InputStream
encoding 流的字符编码
ThrowsXMLStreamException:
英文文档:

createXMLStreamReader

public abstract XMLStreamReader createXMLStreamReader(InputStream stream,
                                                      String encoding)
                                               throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream

Parameters:
stream - the InputStream to read from
encoding - the character encoding of the stream
Throws:
XMLStreamException

abstract public XMLStreamReader createXMLStreamReader(String systemId, java.io.InputStream stream) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLStreamReader。
systemId 流的系统 ID
stream 要从中读取 XMLEventReader 的 InputStream
英文文档:

createXMLStreamReader

public abstract XMLStreamReader createXMLStreamReader(String systemId,
                                                      InputStream stream)
                                               throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream

Parameters:
systemId - the system ID of the stream
stream - the InputStream to read from
Throws:
XMLStreamException

abstract public XMLStreamReader createXMLStreamReader(String systemId, java.io.Reader reader) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLStreamReader。
systemId 流的系统 ID
reader 要从中读取 XMLEventReader 的 InputStream
英文文档:

createXMLStreamReader

public abstract XMLStreamReader createXMLStreamReader(String systemId,
                                                      Reader reader)
                                               throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream

Parameters:
systemId - the system ID of the stream
reader - the InputStream to read from
Throws:
XMLStreamException

abstract public XMLEventReader createXMLEventReader(java.io.Reader reader) throws XMLStreamException
根据 reader 创建一个新 XMLEventReader。
reader 要从中读取 XMLEventReader 的 XML 数据
ThrowsXMLStreamException:
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(Reader reader)
                                             throws XMLStreamException
Create a new XMLEventReader from a reader

Parameters:
reader - the XML data to read from
Throws:
XMLStreamException

abstract public XMLEventReader createXMLEventReader(String systemId, java.io.Reader reader) throws XMLStreamException
根据 reader 创建一个新 XMLEventReader。
systemId 输入的系统 ID
reader 要从中读取 XMLEventReader 的 XML 数据
ThrowsXMLStreamException:
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(String systemId,
                                                    Reader reader)
                                             throws XMLStreamException
Create a new XMLEventReader from a reader

Parameters:
systemId - the system ID of the input
reader - the XML data to read from
Throws:
XMLStreamException

abstract public XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException
根据 XMLStreamReader 创建一个新 XMLEventReader。在被用来构造此方法返回的 XMLEventReader 实例后,MLStreamReader 不得再次使用。
reader 要从中读取数据的 XMLStreamReader (不能修改)
return 新 XMLEventReader
ThrowsXMLStreamException:
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader)
                                             throws XMLStreamException
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.

Parameters:
reader - the XMLStreamReader to read from (may not be modified)
Returns:
a new XMLEventReader
Throws:
XMLStreamException

abstract public XMLEventReader createXMLEventReader(javax.xml.transform.Source source) throws XMLStreamException
根据 JAXP 源创建一个新 XMLEventReader。对此方法的支持是可选的。
source 要从中读取 XMLEventReader 的源
ThrowsUnsupportedOperationException: 如果 XMLInputFactory 不支持此方法
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(Source source)
                                             throws XMLStreamException
Create a new XMLEventReader from a JAXP source. Support of this method is optional.

Parameters:
source - the source to read from
Throws:
UnsupportedOperationException - if this method is not supported by this XMLInputFactory
XMLStreamException

abstract public XMLEventReader createXMLEventReader(java.io.InputStream stream) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLEventReader。
stream 要从中读取 XMLEventReader 的 InputStream
ThrowsXMLStreamException:
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(InputStream stream)
                                             throws XMLStreamException
Create a new XMLEventReader from a java.io.InputStream

Parameters:
stream - the InputStream to read from
Throws:
XMLStreamException

abstract public XMLEventReader createXMLEventReader(java.io.InputStream stream, String encoding) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLEventReader。
stream 要从中读取 XMLEventReader 的 InputStream
encoding 流的字符编码
ThrowsXMLStreamException:
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(InputStream stream,
                                                    String encoding)
                                             throws XMLStreamException
Create a new XMLEventReader from a java.io.InputStream

Parameters:
stream - the InputStream to read from
encoding - the character encoding of the stream
Throws:
XMLStreamException

abstract public XMLEventReader createXMLEventReader(String systemId, java.io.InputStream stream) throws XMLStreamException
根据 java.io.InputStream 创建一个新 XMLEventReader。
systemId 流的系统 ID
stream 要从中读取 XMLEventReader 的 InputStream
ThrowsXMLStreamException:
英文文档:

createXMLEventReader

public abstract XMLEventReader createXMLEventReader(String systemId,
                                                    InputStream stream)
                                             throws XMLStreamException
Create a new XMLEventReader from a java.io.InputStream

Parameters:
systemId - the system ID of the stream
stream - the InputStream to read from
Throws:
XMLStreamException

abstract public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException
创建过滤的 reader,它用过滤器包装 reader。
reader 要过滤的 reader
filter 要应用到 reader 的过滤器
ThrowsXMLStreamException:
英文文档:

createFilteredReader

public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader,
                                                     StreamFilter filter)
                                              throws XMLStreamException
Create a filtered reader that wraps the filter around the reader

Parameters:
reader - the reader to filter
filter - the filter to apply to the reader
Throws:
XMLStreamException

abstract public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException
创建过滤的事件 reader,它用过滤器包装事件 reader。
reader 要包装的事件 reader
filter 要应用到事件 reader 的过滤器
ThrowsXMLStreamException:
英文文档:

createFilteredReader

public abstract XMLEventReader createFilteredReader(XMLEventReader reader,
                                                    EventFilter filter)
                                             throws XMLStreamException
Create a filtered event reader that wraps the filter around the event reader

Parameters:
reader - the event reader to wrap
filter - the filter to apply to the event reader
Throws:
XMLStreamException

abstract public XMLResolver getXMLResolver()
要在此工厂实例创建的任何 XMLStreamReader 或 XMLEventReader 上进行设置的解析器。
英文文档:

getXMLResolver

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


abstract public void setXMLResolver(XMLResolver resolver)
要在此工厂实例创建的任何 XMLStreamReader 或 XMLEventReader 上进行设置的解析器。
resolver 要用于解析引用的解析器
英文文档:

setXMLResolver

public abstract void setXMLResolver(XMLResolver resolver)
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Parameters:
resolver - the resolver to use to resolve references

abstract public XMLReporter getXMLReporter()
要在此工厂实例创建的任何 XMLStreamReader 或 XMLEventReader 上进行设置的报告器。
英文文档:

getXMLReporter

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


abstract public void setXMLReporter(XMLReporter reporter)
要在此工厂实例创建的任何 XMLStreamReader 或 XMLEventReader 上进行设置的报告器。
reporter 要用来报告非严重错误的解析器
英文文档:

setXMLReporter

public abstract void setXMLReporter(XMLReporter reporter)
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Parameters:
reporter - the resolver to use to report non fatal errors

abstract public void setProperty(String name, Object value) throws IllegalArgumentException
允许用户在底层实现上设置特定功能/属性。底层实现不需要支持规范中每个属性的每个设置,可以使用 IllegalArgumentException 来表示一个不受支持的属性不能用指定的值进行设置。
name 属性的名称(不可以为 null)
value 属性的值
ThrowsIllegalArgumentException: 如果属性不受支持
英文文档:

setProperty

public abstract void setProperty(String name,
                                 Object value)
                          throws IllegalArgumentException
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.

Parameters:
name - The name of the property (may not be null)
value - The value of the property
Throws:
IllegalArgumentException - if the property is not supported

abstract public Object getProperty(String name) throws IllegalArgumentException
从底层实现获取功能/属性的值。
name 属性的名称(不可以为 null)
return 属性的值
ThrowsIllegalArgumentException: 如果属性不受支持
英文文档:

getProperty

public abstract Object getProperty(String name)
                            throws IllegalArgumentException
Get the value of a feature/property from the underlying implementation

Parameters:
name - The name of the property (may not be null)
Returns:
The value of the property
Throws:
IllegalArgumentException - if the property is not supported

abstract public boolean isPropertySupported(String name)
查询此工厂支持的属性集合。
name 属性的名称(不可以为 null)
return 如果此属性受支持,则返回 true,否则返回 false
英文文档:

isPropertySupported

public abstract boolean isPropertySupported(String name)
Query the set of properties that this factory supports.

Parameters:
name - The name of the property (may not be null)
Returns:
true if the property is supported and false otherwise

abstract public void setEventAllocator(XMLEventAllocator allocator)
为事件设置一个用户定义的事件分配器。
allocator 用户定义的分配器
英文文档:

setEventAllocator

public abstract void setEventAllocator(XMLEventAllocator allocator)
Set a user defined event allocator for events

Parameters:
allocator - the user defined allocator

abstract public XMLEventAllocator getEventAllocator()
获取用此工厂创建的流所使用的分配器。
英文文档:

getEventAllocator

public abstract XMLEventAllocator getEventAllocator()
Gets the allocator used by streams created with this factory



Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!