|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.xml.parsers.DocumentBuilder
public abstract class DocumentBuilder
定義 API, 使其從 XML 文檔獲取 DOM 文檔實例。使用此類別,應用開發人員可以從 XML 獲取一個 Document。
此類別的實例可以從 DocumentBuilderFactory.newDocumentBuilder() 方法獲取。獲取此類別的實例之後,將可以從各種輸入源解析 XML。
這些輸入源有 InputStreams、Files、URL 和 SAX InputSources。
注意,此類別重用了 SAX API 中的一些類別。這並不要求底層 DOM 實作的實作者使用 SAX 解析器將 XML 文檔解析為 Document。它僅要求該實作使用這些現有的 API 與應用程序交串流。
| 建構子摘要 | |
|---|---|
protected |
DocumentBuilder()
受保護的建構子 |
| 方法摘要 | |
|---|---|
abstract DOMImplementation |
getDOMImplementation()
獲取 DOMImplementation 物件的一個實例。 |
Schema |
getSchema()
獲取由 XML 處理器使用的 Schema 的參考。 |
abstract boolean |
isNamespaceAware()
指示此解析器是否被配置為可識別名稱空間。 |
abstract boolean |
isValidating()
指示此解析器是否被配置為驗證 XML 文檔。 |
boolean |
isXIncludeAware()
獲取此解析器的 XInclude 處理網要。 |
abstract Document |
newDocument()
獲取 DOM Document 物件的一個新實例來產生一個 DOM 階層樹。 |
Document |
parse(File f)
將給定檔案的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。 |
abstract Document |
parse(InputSource is)
將給定輸入源的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。 |
Document |
parse(InputStream is)
將給定 InputStream 的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。 |
Document |
parse(InputStream is,
String systemId)
將給定 InputStream 的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。 |
Document |
parse(String uri)
將給定 URI 的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。 |
void |
reset()
將此 DocumentBuilder 重置為其原始配置。 |
abstract void |
setEntityResolver(EntityResolver er)
指定使用 EntityResolver 解析要解析的 XML 文檔中存在的實體。 |
abstract void |
setErrorHandler(ErrorHandler eh)
指定解析器要使用的 ErrorHandler。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 建構子詳細資訊 |
|---|
protected DocumentBuilder()
| 方法詳細資訊 |
|---|
public void reset()
將此 DocumentBuilder 重置為其原始配置。
DocumentBuilder 被重置為使用 DocumentBuilderFactory.newDocumentBuilder() 創建它時的狀態。設計 reset() 旨在允許重用現有的 DocumentBuilder,從而節省與創建新的 DocumentBuilder 相關的資源。
重置的 DocumentBuilder 不能保證具有相同的 EntityResolver 或 ErrorHandler Object,如 Object.equals(Object obj)。可以保證具有功能相等的 EntityResolver 和 ErrorHandler。
UnsupportedOperationException - 當實作沒有覆寫此方法時。
public Document parse(InputStream is)
throws SAXException,
IOException
InputStream 的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。如果 InputStream 為 null,則拋出 IllegalArgumentException。
is - 套件含要解析內容的 InputStream。
InputStream 的 Document 結果。
IOException - 如果發生任何 IO 錯誤。
SAXException - 如果發生任何解析錯誤。
IllegalArgumentException - 當 is 為 null 時DocumentHandler
public Document parse(InputStream is,
String systemId)
throws SAXException,
IOException
InputStream 的內容解析為一個 XML 文檔,並且返回一個新的 DOM Document 物件。如果 InputStream 為 null,則拋出 IllegalArgumentException。
is - 套件含要解析內容的 InputStream。systemId - 提供一個與解析相關的 URI 的基礎。
IOException - 如果發生任何 IO 錯誤。
SAXException - 如果發生任何解析錯誤。
IllegalArgumentException - 當 is 為 null 時DocumentHandler
public Document parse(String uri)
throws SAXException,
IOException
Document 物件。如果 URI 為 null,則拋出 IllegalArgumentException。
uri - 要解析的內容的位置。
IOException - 如果發生任何 IO 錯誤。
SAXException - 如果發生任何解析錯誤。
IllegalArgumentException - 當 uri 為 null 時DocumentHandler
public Document parse(File f)
throws SAXException,
IOException
Document 物件。如果 File 為 null,則拋出 IllegalArgumentException。
f - 套件含要解析的 XML 的檔案。
IOException - 如果發生任何 IO 錯誤。
SAXException - 如果發生任何解析錯誤。
IllegalArgumentException - 當 f 為 null 時DocumentHandler
public abstract Document parse(InputSource is)
throws SAXException,
IOException
Document 物件。如果 InputSource 為 null,則拋出 IllegalArgumentException。
is - 套件含要解析內容的 InputSource。
IOException - 如果發生任何 IO 錯誤。
SAXException - 如果發生任何解析錯誤。
IllegalArgumentException - 當 is 為 null 時DocumentHandlerpublic abstract boolean isNamespaceAware()
public abstract boolean isValidating()
public abstract void setEntityResolver(EntityResolver er)
EntityResolver 解析要解析的 XML 文檔中存在的實體。將其設置為 null 將會導致底層實作使用其自身的預設實作和行為。
er - EntityResolver,用於解析要解析的 XML 文檔中存在的實體。public abstract void setErrorHandler(ErrorHandler eh)
ErrorHandler。將其設置為 null 將會導致底層實作使用其自身的預設實作和行為。
eh - 解析器將要使用的 ErrorHandler。public abstract Document newDocument()
Document 物件的一個新實例來產生一個 DOM 階層樹。
public abstract DOMImplementation getDOMImplementation()
DOMImplementation 物件的一個實例。
DOMImplementation 實例。public Schema getSchema()
獲取由 XML 處理器使用的 Schema 的參考。
如果沒有使用 schema,則返回 null。
Schema,如果一個也沒有使用,則返回 null
UnsupportedOperationException - 當實作沒有覆寫此方法時public boolean isXIncludeAware()
獲取此解析器的 XInclude 處理網要。
DocumentBuilderFactory.isXIncludeAware() 的返回值。
UnsupportedOperationException - 當實作沒有覆寫此方法時DocumentBuilderFactory.setXIncludeAware(boolean)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。