|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.ElementIterator
public class ElementIterator
ElementIterator,顧名思義,沿 Element 階層樹進行迭代。可使用 Document 或 Element 參數調用此建構子。如果以 Document 為參數調用此建構子,那麼迭代的根為 document.getDefaultRootElement() 的返回值。 迭代以深度優先 (depth-first) 的方式進行。至於如何處理邊界條件:a) 如果 next() 在 first() 或 current() 之前調用,將返回根。b) next() 返回 null 指示列表的末尾。c) 如果當前元素為根或 next() 已經返回 null 時,previous() 返回 null。 ElementIterator 並不鎖定 Element 階層樹。這意味著它不追蹤任何更改。由此類別的使用者負責確保元素迭代期間不出現更改。 簡單用法範例: public void iterate() { ElementIterator it = new ElementIterator(root); Element elem; while (true) { if ((elem = next()) != null) { // process element System.out.println("elem: " + elem.getName()); } else { break; } } }
| 建構子摘要 | |
|---|---|
ElementIterator(Document document)
創建新的 ElementIterator。 |
|
ElementIterator(Element root)
創建新的 ElementIterator。 |
|
| 方法摘要 | |
|---|---|
Object |
clone()
複製 ElementIterator。 |
Element |
current()
獲取當前 Element。 |
int |
depth()
獲取元素階層樹的當前深度。 |
Element |
first()
獲取第一個元素。 |
Element |
next()
獲取下一個 Element。 |
Element |
previous()
獲取前一個 Element。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 建構子詳細資訊 |
|---|
public ElementIterator(Document document)
document - Document。public ElementIterator(Element root)
root - 根 Element。| 方法詳細資訊 |
|---|
public Object clone()
Object 中的 cloneCloneablepublic Element first()
public int depth()
public Element current()
null 則返回 nullpublic Element next()
null。public Element previous()
Element(如果有)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。