Most visited

Recently visited

Added in API level 8

TypeInfoProvider

public abstract class TypeInfoProvider
extends Object

java.lang.Object
    javax.xml.validation.TypeInfoProvider


该课程提供对由 ValidatorHandler确定的类型信息的 ValidatorHandler

某些模式语言(如W3C XML模式)鼓励验证程序报告它分配给每个属性/元素的“类型”。 那些希望访问此类型信息的应用程序可以调用在此“接口”上定义的方法来访问此类型信息。

这个“接口”的实现可以通过 getTypeInfoProvider()方法获得。

也可以看看:

摘要(Summary)

Protected constructors

TypeInfoProvider()

派生类的构造函数。

公共方法(Public methods)

abstract TypeInfo getAttributeTypeInfo(int index)

返回当前元素的指定属性的不可变 TypeInfo对象。

abstract TypeInfo getElementTypeInfo()

返回当前元素的不可变 TypeInfo对象。

abstract boolean isIdAttribute(int index)

如果指定的属性被确定为ID,则返回 true

abstract boolean isSpecified(int index)

如果属性由验证器添加,则返回 false

继承方法(Inherited methods)

From class java.lang.Object

Protected constructors

TypeInfoProvider

Added in API level 8
TypeInfoProvider ()

派生类的构造函数。

构造函数什么都不做。

公共方法(Public methods)

getAttributeTypeInfo

Added in API level 8
TypeInfo getAttributeTypeInfo (int index)

返回当前元素的指定属性的不可变 TypeInfo对象。

该方法只能由应用程序设置为 ValidatorHandlerContentHandler的startElement事件 ValidatorHandler

参数(Parameters)
index int: The index of the attribute. The same index for the Attributes object passed to the startElement callback.
返回(Returns)
TypeInfo An immutable TypeInfo object that represents the type of the specified attribute. Note that the caller can keep references to the obtained TypeInfo longer than the callback scope. Otherwise, this method returns null if the validator is unable to determine the type.
抛出异常(Throws)
IndexOutOfBoundsException If the index is invalid.
IllegalStateException If this method is called from other ContentHandler methods.

getElementTypeInfo

Added in API level 8
TypeInfo getElementTypeInfo ()

返回当前元素的不可变 TypeInfo对象。

该方法只能由应用程序设置为 ValidatorHandlerContentHandler的startElement和endElement事件 ValidatorHandler

返回(Returns)
TypeInfo An immutable TypeInfo object that represents the type of the current element. Note that the caller can keep references to the obtained TypeInfo longer than the callback scope. Otherwise, this method returns null if the validator is unable to determine the type of the current element for some reason (for example, if the validator is recovering from an earlier error.)
抛出异常(Throws)
IllegalStateException If this method is called from other ContentHandler methods.

isIdAttribute

Added in API level 8
boolean isIdAttribute (int index)

如果指定的属性被确定为ID,则返回 true

“确定为ID”属性的确切方式取决于模式语言。 在W3C XML Schema的情况下,这意味着属性的实际类型是内置ID类型或其派生类型。

A DocumentBuilder使用此信息正确实施 isId()

该方法只能由应用程序设置为 ValidatorHandlerContentHandler的startElement事件 ValidatorHandler

参数(Parameters)
index int: The index of the attribute. The same index for the Attributes object passed to the startElement callback.
返回(Returns)
boolean true if the type of the specified attribute is ID.
抛出异常(Throws)
IndexOutOfBoundsException If the index is invalid.
IllegalStateException If this method is called from other ContentHandler methods.

isSpecified

Added in API level 8
boolean isSpecified (int index)

如果属性由验证器添加,则返回 false

此方法提供了 DocumentBuilder必需的信息,以确定DOM树应从 getSpecified()方法返回的 getSpecified()

该方法只能由应用程序设置为 ValidatorHandlerContentHandler的startElement事件 ValidatorHandler

验证器的一般准则是,如果属性最初出现在管道中,则返回true;如果验证器添加,则返回false。

参数(Parameters)
index int: The index of the attribute. The same index for the Attributes object passed to the startElement callback.
返回(Returns)
boolean true if the attribute was present before the validator processes input. false if the attribute was added by the validator.
抛出异常(Throws)
IndexOutOfBoundsException If the index is invalid.
IllegalStateException If this method is called from other ContentHandler methods.

Hooray!