|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
public interface CharacterData
CharacterData 介面使用屬性集合和用於存取 DOM 中字元資料的方法擴展節點。為了清楚起見,在這裡定義此集合,而不是在使用這些屬性和方法的每個物件上定義。任何 DOM 物件都不會直接對應於 CharacterData,儘管 Text 和其他的物件是從它繼承該介面的。此介面中的所有 offset 都從 0 開始。
如 DOMString 介面中所述,DOM 中的文本字元串以 UTF-16(即 16 位單元序列)表示。在下述情況下,每當需要指示以 16 位單元在 CharacterData 上進行索引時就使用術語 16 位單元。
另請參見 Document Object Model (DOM) Level 3 Core Specification。
| 欄位摘要 |
|---|
| 方法摘要 | |
|---|---|
void |
appendData(String arg)
將字元串追加到節點的字元資料的結尾。 |
void |
deleteData(int offset,
int count)
從該節點移除某個範圍的 16 位單元。 |
String |
getData()
實作此介面的節點的字元資料。 |
int |
getLength()
通過下面的 data 和 substringData 方法可使用的 16 位單元數。 |
void |
insertData(int offset,
String arg)
在指定的 16 位單元偏移量位置插入一個字元串。 |
void |
replaceData(int offset,
int count,
String arg)
用指定的字元串替換從指定 16 位單元偏移量起始的字元。 |
void |
setData(String data)
實作此介面的節點的字元資料。 |
String |
substringData(int offset,
int count)
從該節點提取某個範圍的資料。 |
| 方法詳細資訊 |
|---|
String getData()
throws DOMException
CharacterData 節點中的資料量。不過,實作限制可能意味著全部的節點資料不可以適合單個 DOMString。在這種情況下,使用者可以調用 substringData 以適當大小的片段來檢索資料。
DOMException - DOMSTRING_SIZE_ERR:當它返回的字元多於實作平臺上的 DOMString 變數中的字元時引發此異常。
void setData(String data)
throws DOMException
CharacterData 節點中的資料量。不過,實作限制可能意味著全部的節點資料不可以適合單個 DOMString。在這種情況下,使用者可以調用 substringData 以適當大小的片段來檢索資料。。
DOMException - NO_MODIFICATION_ALLOWED_ERR:節點為只讀的時引發此異常。int getLength()
data 和 substringData 方法可使用的 16 位單元數。此數可能是值 0,即 CharacterData 節點可以為空。
String substringData(int offset,
int count)
throws DOMException
offset - 要提取的子字元串的起始偏移量。count - 要提取的 16 位單元數。
offset 和 count 的和超過 length,則返回到資料結尾處的所有 16 位單元。
DOMException - INDEX_SIZE_ERR:如果指定 offset 為負或大於 data 中的 16 位單元數,或者如果指定 count 為負,則引發此異常。 DOMString 時引發此異常。
void appendData(String arg)
throws DOMException
data 可存取 data 和指定 DOMString 的串聯形式。
arg - 要追加的 DOMString。
DOMException - NO_MODIFICATION_ALLOWED_ERR:此節點為只讀的引發此異常。
void insertData(int offset,
String arg)
throws DOMException
offset - 字元串偏移量,在該處插入字元串。arg - 要插入的 DOMString。
DOMException - INDEX_SIZE_ERR:指定 offset 為負或大於 data 中的 16 位單元數時引發此異常。
void deleteData(int offset,
int count)
throws DOMException
data 和 length 反映此更改。
offset - 偏移量,從此位置開始移除。count - 要刪除的 16 位單元數。如果 offset 和 count 的和超過 length,則刪除從 offset 開始到資料結尾的所有 16 位單元。
DOMException - INDEX_SIZE_ERR:如果指定 offset 為負或大於 data 中的 16 位單元數,或者如果指定 count 為負,則引發此異常。
void replaceData(int offset,
int count,
String arg)
throws DOMException
offset - 偏移量,從此位置開始替換。count - 要替換的 16 位單元數。如果 offset 和 count 的和超過 length,則替換到資料結尾的所有 16 位單元;(即其效果與具有同樣範圍的 remove 方法調用相同,後跟 append 方法調用)。arg - 必須用來替換該範圍的字元的 DOMString。
DOMException - INDEX_SIZE_ERR:如果指定 offset 為負或大於 data 中的 16 位單元數,或者如果指定 count 為負,則引發此異常。
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。