Most visited

Recently visited

Added in API level 1

CharacterData

public interface CharacterData
implements Node

org.w3c.dom.CharacterData
Known Indirect Subclasses


CharacterData接口使用一组用于访问DOM中字符数据的属性和方法来扩展Node。 为了清楚起见,这里定义了这个集合,而不是每个使用这些属性和方法的对象。 没有DOM对象直接对应于CharacterData ,尽管Text和其他人继承了它的接口。 这个接口中的所有offsets0开始。

正如DOMString接口中所解释的,DOM中的文本字符串以UTF-16表示,即以16位单元的序列表示。 在下文中,术语16位单元在必要时用于指示在CharacterData上的索引是以16位为单位完成的。

另见 Document Object Model (DOM) Level 3 Core Specification

摘要(Summary)

Inherited constants

From interface org.w3c.dom.Node

公共方法(Public methods)

abstract void appendData(String arg)

将字符串追加到节点的字符数据的末尾。

abstract void deleteData(int offset, int count)

从节点中删除一系列的16位单元。

abstract String getData()

实现此接口的节点的字符数据。

abstract int getLength()

通过 data和下面的 substringData方法可用的16位单元的数量。

abstract void insertData(int offset, String arg)

以指定的16位单位偏移量插入一个字符串。

abstract void replaceData(int offset, int count, String arg)

用指定的字符串替换从指定的16位单位偏移量开始的字符。

abstract void setData(String data)

实现此接口的节点的字符数据。

abstract String substringData(int offset, int count)

从节点中提取一系列数据。

继承方法(Inherited methods)

From interface org.w3c.dom.Node

公共方法(Public methods)

appendData

Added in API level 1
void appendData (String arg)

将字符串追加到节点的字符数据的末尾。 一旦成功, data提供访问指定的dataDOMString的级联。

参数(Parameters)
arg String: The DOMString to append.
抛出异常(Throws)
DOMException NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

deleteData

Added in API level 1
void deleteData (int offset, 
                int count)

从节点中删除一系列的16位单元。 一旦成功, datalength反映了这一变化。

参数(Parameters)
offset int: The offset from which to start removing.
count int: The number of 16-bit units to delete. If the sum of offset and count exceeds length then all 16-bit units from offset to the end of the data are deleted.
抛出异常(Throws)
DOMException INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

getData

Added in API level 1
String getData ()

实现此接口的节点的字符数据。 DOM实现可能不会对可能存储在CharacterData节点中的数据量施加任意限制。 但是,实施限制可能意味着整个节点的数据可能不适合单个DOMString 在这种情况下,用户可以拨打substringData来检索大小合适的数据。

返回(Returns)
String
抛出异常(Throws)
DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.

getLength

Added in API level 1
int getLength ()

通过data和下面的substringData方法可用的16位单元的数量。 这可能具有零值,即CharacterData节点可能为空。

返回(Returns)
int

insertData

Added in API level 1
void insertData (int offset, 
                String arg)

以指定的16位单位偏移量插入一个字符串。

参数(Parameters)
offset int: The character offset at which to insert.
arg String: The DOMString to insert.
抛出异常(Throws)
DOMException INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

replaceData

Added in API level 1
void replaceData (int offset, 
                int count, 
                String arg)

用指定的字符串替换从指定的16位单位偏移量开始的字符。

参数(Parameters)
offset int: The offset from which to start replacing.
count int: The number of 16-bit units to replace. If the sum of offset and count exceeds length, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a remove method call with the same range, followed by an append method invocation).
arg String: The DOMString with which the range must be replaced.
抛出异常(Throws)
DOMException INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

setData

Added in API level 1
void setData (String data)

实现此接口的节点的字符数据。 DOM实现可能不会对可能存储在CharacterData节点中的数据量施加任意限制。 但是,实施限制可能意味着整个节点的数据可能不适合单个DOMString 在这种情况下,用户可以拨打substringData来检索大小合适的数据。

参数(Parameters)
data String
抛出异常(Throws)
DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

substringData

Added in API level 1
String substringData (int offset, 
                int count)

从节点中提取一系列数据。

参数(Parameters)
offset int: Start offset of substring to extract.
count int: The number of 16-bit units to extract.
返回(Returns)
String The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.
抛出异常(Throws)
DOMException INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a DOMString.

Hooray!