public class AttributesImpl extends Object implements Attributes
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
这个类提供了Attributes
SAX2接口的默认实现,随着机器人的加入使列表可以修改或重用。
这个类有两个典型的用途:
startElement
事件属性的对象持久性快照;或这类取代了过时的SAX1 AttributeListImpl
类;除了支持更新的属性接口而不是过时的AttributeList
界面,它还包括一个更有效的实现使用一个数组而不是一组向量。
Constructor and Description |
---|
AttributesImpl()
构建一个新的、空的attributesimpl对象。
|
AttributesImpl(Attributes atts)
复制一个现有的属性对象。
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String uri, String localName, String qName, String type, String value)
向列表的结尾添加一个属性。
|
void |
clear()
清除重用的属性列表。
|
int |
getIndex(String qName)
查一个属性指标合格(前缀)的名字。
|
int |
getIndex(String uri, String localName)
用命名空间名称查找属性的索引。
|
int |
getLength()
返回列表中的属性的数目。
|
String |
getLocalName(int index)
返回一个属性的本地名称。
|
String |
getQName(int index)
返回一个属性的合格(前缀)的名字。
|
String |
getType(int index)
通过索引返回一个属性的类型。
|
String |
getType(String qName)
看了一个属性类型由合格的(前缀)的名字。
|
String |
getType(String uri, String localName)
通过命名空间限定名称查找属性的类型。
|
String |
getURI(int index)
返回一个属性的命名空间URI。
|
String |
getValue(int index)
通过索引返回一个属性的值。
|
String |
getValue(String qName)
查一个属性的值由合格的(前缀)的名字。
|
String |
getValue(String uri, String localName)
用命名空间限定名称查找属性的值。
|
void |
removeAttribute(int index)
从列表中删除一个属性。
|
void |
setAttribute(int index, String uri, String localName, String qName, String type, String value)
在列表中设置一个属性。
|
void |
setAttributes(Attributes atts)
复制一个完整的属性对象。
|
void |
setLocalName(int index, String localName)
设置一个特定属性的本地名称。
|
void |
setQName(int index, String qName)
设置特定属性的限定名称。
|
void |
setType(int index, String type)
设置特定属性的类型。
|
void |
setURI(int index, String uri)
设置一个特定属性的命名空间URI。
|
void |
setValue(int index, String value)
设置一个特定属性的值。
|
public AttributesImpl()
public AttributesImpl(Attributes atts)
这个构造函数是特别有用的在startElement
事件。
atts
-现有属性的对象。
public int getLength()
getLength
接口
Attributes
Attributes.getLength()
public String getURI(int index)
getURI
接口
Attributes
index
-属性的索引(从零开始)。
Attributes.getURI(int)
public String getLocalName(int index)
getLocalName
接口
Attributes
index
-属性的索引(从零开始)。
Attributes.getLocalName(int)
public String getQName(int index)
getQName
接口
Attributes
index
-属性的索引(从零开始)。
Attributes.getQName(int)
public String getType(int index)
getType
接口
Attributes
index
-属性的索引(从零开始)。
Attributes.getType(int)
public String getValue(int index)
getValue
接口
Attributes
index
-属性的索引(从零开始)。
Attributes.getValue(int)
public int getIndex(String uri, String localName)
在许多情况下,查找这个名称的效率会更高,使用索引查询方法,而不是使用重复的名称查询方法。
getIndex
接口
Attributes
uri
-属性的命名空间URI或空字符串,如果没有可用的。
localName
-属性的本地名称。
Attributes.getIndex(java.lang.String,java.lang.String)
public int getIndex(String qName)
getIndex
接口
Attributes
qName
-名称。
Attributes.getIndex(java.lang.String)
public String getType(String uri, String localName)
getType
接口
Attributes
uri
的命名空间URI或空字符串为没有明确的命名空间URI的名字。
localName
的本地名称。
Attributes.getType(java.lang.String,java.lang.String)
public String getType(String qName)
getType
接口
Attributes
qName
-名称。
Attributes.getType(java.lang.String)
public String getValue(String uri, String localName)
getValue
接口
Attributes
uri
的命名空间URI或空字符串为没有明确的命名空间URI的名字。
localName
的本地名称。
Attributes.getValue(java.lang.String,java.lang.String)
public String getValue(String qName)
getValue
接口
Attributes
qName
-名称。
Attributes.getValue(java.lang.String)
public void clear()
请注意,小内存是由这个调用:目前的数组保存,所以它可以重复使用。
public void setAttributes(Attributes atts)
它可能是更有效地重用现有的对象,而不是不断分配新的。
atts
-复制属性。
public void addAttribute(String uri, String localName, String qName, String type, String value)
为了加快速度,这种方法不检查属性是否已经在列表中:这是应用程序的责任。
uri
的命名空间URI或空字符串,如果没有可用的或命名空间处理不执行。
localName
的本地名称、命名空间或空字符串,如果不进行处理。
qName
-合格(前缀)的名字,或空字符串,如果名称不可用。
type
的属性类型为字符串。
value
-属性值。
public void setAttribute(int index, String uri, String localName, String qName, String type, String value)
为了速度,此方法不检查名称冲突或合法性:这种检查是应用程序的责任。
index
-属性的索引(从零开始)。
uri
的命名空间URI或空字符串,如果没有可用的或命名空间处理不执行。
localName
的本地名称、命名空间或空字符串,如果不进行处理。
qName
的限定名,或空字符串,如果名称不可用。
type
的属性类型为字符串。
value
-属性值。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
public void removeAttribute(int index)
index
-属性的索引(从零开始)。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
public void setURI(int index, String uri)
index
-属性的索引(从零开始)。
uri
-属性的命名空间URI或空字符串没有。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
public void setLocalName(int index, String localName)
index
-属性的索引(从零开始)。
localName
-属性的本地名称,或空字符串没有。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
public void setQName(int index, String qName)
index
-属性的索引(从零开始)。
qName
-属性的名称,或空字符串没有。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
public void setType(int index, String type)
index
-属性的索引(从零开始)。
type
-属性的类型。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
public void setValue(int index, String value)
index
-属性的索引(从零开始)。
value
-属性的值。
ArrayIndexOutOfBoundsException
-当提供的指标没有指向列表中的一个属性。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.