JavaTM 2 Platform
Standard Ed. 6

org.xml.sax.ext
类 Attributes2Impl

java.lang.Object
  继承者 org.xml.sax.helpers.AttributesImpl
      继承者 org.xml.sax.ext.Attributes2Impl
所有已实现的接口:
Attributes, Attributes2

public class Attributes2Impl
extends AttributesImpl
implements Attributes2

用于附加的 Attributes 信息的、实现 Attributes2 接口的 SAX2 扩展帮助器。

此模块(包括源代码和文档)在公共域中,同时 没有担保

这不是仅核心 SAX2 分发的一部分。

每个属性的指定的 标志将总为 true,除非使用副本构造方法或 setSpecified(int, boolean) 将它设置为 false。类似地,每个属性的声明的 标志将总为 false,默认的属性(指定为 false)、非 CDATA 属性或使用 setDeclared(int, boolean) 将其设置为 true 时除外。如果手工更改属性的类型,则为了相符可能需要修改其声明的 标志。

从以下版本开始:
SAX 2.0 (extensions 1.1 alpha)

构造方法摘要
Attributes2Impl()
          构造一个新的空 Attributes2Impl 对象。
Attributes2Impl(Attributes atts)
          复制现有属性或 Attributes2 对象。
 
方法摘要
 void addAttribute(String uri, String localName, String qName, String type, String value)
          将属性添回到列表的末尾,将其“指定的”标志设置为 true。
 boolean isDeclared(int index)
          返回属性的“声明的”标志的当前值。
 boolean isDeclared(String qName)
          返回属性的“声明的”标志的当前值。
 boolean isDeclared(String uri, String localName)
          返回属性的“声明的”标志的当前值。
 boolean isSpecified(int index)
          返回属性的“指定的”标志的当前值。
 boolean isSpecified(String qName)
          返回属性的“指定的”标志的当前值。
 boolean isSpecified(String uri, String localName)
          返回属性的“指定的”标志的当前值。
 void removeAttribute(int index)
          从列表移除属性。
 void setAttributes(Attributes atts)
          复制整个属性对象。
 void setDeclared(int index, boolean value)
          将值分配给特定属性的“声明的”标志。
 void setSpecified(int index, boolean value)
          将值分配给特定属性的“指定的”标志。
 
从类 org.xml.sax.helpers.AttributesImpl 继承的方法
clear, getIndex, getIndex, getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValue, setAttribute, setLocalName, setQName, setType, setURI, setValue
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.xml.sax.Attributes 继承的方法
getIndex, getIndex, getLength, getLocalName, getQName, getType, getType, getType, getURI, getValue, getValue, getValue
 

构造方法详细信息

Attributes2Impl

public Attributes2Impl()
构造一个新的空 Attributes2Impl 对象。


Attributes2Impl

public Attributes2Impl(Attributes atts)
复制现有属性或 Attributes2 对象。如果对象实现 Attributes2,则复制每个属性的指定的声明的 标志的值。否则,标志值默认假定没有使用任何 DTD,除非有相反证据(例如,属性具有除 CDATA 之外的类型,但它们必须已经声明)。

startElement 事件中,此构造方法特别有用。

参数:
atts - 现有 Attributes 对象。
方法详细信息

isDeclared

public boolean isDeclared(int index)
返回属性的“声明的”标志的当前值。

指定者:
接口 Attributes2 中的 isDeclared
参数:
index - 属性索引(从零开始)。
返回:
如果在 DTD 中声明属性,则返回 true,否则返回 false。

isDeclared

public boolean isDeclared(String uri,
                          String localName)
返回属性的“声明的”标志的当前值。

指定者:
接口 Attributes2 中的 isDeclared
参数:
uri - 名称空间 URI,如果该名称没有名称空间 URI,则为空字符串。
localName - 属性的本地名称。
返回:
如果在 DTD 中声明属性,则返回 true,否则返回 false。

isDeclared

public boolean isDeclared(String qName)
返回属性的“声明的”标志的当前值。

指定者:
接口 Attributes2 中的 isDeclared
参数:
qName - XML 限定(加前缀的)名称。
返回:
如果在 DTD 中声明属性,则返回 true,否则返回 false。

isSpecified

public boolean isSpecified(int index)
返回属性的“指定的”标志的当前值。

指定者:
接口 Attributes2 中的 isSpecified
参数:
index - 属性索引(从零开始)。
返回:
当前的标志值
抛出:
ArrayIndexOutOfBoundsException - 当提供的索引不标识属性时。

isSpecified

public boolean isSpecified(String uri,
                           String localName)
返回属性的“指定的”标志的当前值。

指定者:
接口 Attributes2 中的 isSpecified
参数:
uri - 名称空间 URI,如果该名称没有名称空间 URI,则为空字符串。
localName - 属性的本地名称。
返回:
当前标志值
抛出:
IllegalArgumentException - 当提供的名称不标识属性时。

isSpecified

public boolean isSpecified(String qName)
返回属性的“指定的”标志的当前值。

指定者:
接口 Attributes2 中的 isSpecified
参数:
qName - XML 限定(加前缀的)名称。
返回:
当前标志值
抛出:
IllegalArgumentException - 当提供的名称不标识属性时。

setAttributes

public void setAttributes(Attributes atts)
复制整个属性对象。将 true 分配给“指定的”标志,将 false 分配给“声明的”标志(属性的类型不是 CDATA 时除外),除非对象是 Attributes2 对象。在此情况下,完全复制这些标志值。

覆盖:
AttributesImpl 中的 setAttributes
参数:
atts - 要复制的属性。
另请参见:
AttributesImpl.setAttributes(org.xml.sax.Attributes)

addAttribute

public void addAttribute(String uri,
                         String localName,
                         String qName,
                         String type,
                         String value)
将属性添回到列表的末尾,将其“指定的”标志设置为 true。要将标志的值设置为 false,使用 setSpecified(int, boolean)

除非属性类型 是 CDATA,才按照 DTD 中声明的那样标记此属性。要将该标志值设置为 true,使用 setDeclared(int, boolean)

覆盖:
AttributesImpl 中的 addAttribute
参数:
uri - 名称空间 URI,如果没有可用的,或不是正在执行名称空间处理,则为空字符串。
localName - 本地名称,如果不是正在执行名称空间处理,则为空字符串。
qName - 限定(加前缀的)名称,如果限定名称不可用,则为空字符串。
type - 字符串形式的属性类型。
value - 属性值。
另请参见:
AttributesImpl.addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

removeAttribute

public void removeAttribute(int index)
从类 AttributesImpl 复制的描述
从列表移除属性。

覆盖:
AttributesImpl 中的 removeAttribute
参数:
index - 属性的索引(从零开始)。

setDeclared

public void setDeclared(int index,
                        boolean value)
将值分配给特定属性的“声明的”标志。通常,仅有类型 CDATA 的属性需要此操作,包括其类型更改为 CDATA 或从 CDATA 更改来的属性。

参数:
index - 属性的索引(从零开始)。
value - 需要的标志值。
抛出:
ArrayIndexOutOfBoundsException - 当提供的索引不标识属性时。
另请参见:
AttributesImpl.setType(int, java.lang.String)

setSpecified

public void setSpecified(int index,
                         boolean value)
将值分配给特定属性的“指定的”标志。这是能够清除此标志的唯一方法,使用复制构造方法通过初始化进行的清除除外。

参数:
index - 属性的索引(从零开始)。
value - 需要的标志值。
抛出:
ArrayIndexOutOfBoundsException - 当提供的索引不标识属性时。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策