Example usage for org.w3c.dom Document getClass

List of usage examples for org.w3c.dom Document getClass

Introduction

In this page you can find the example usage for org.w3c.dom Document getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:DOMWriter.java

/** Extracts the XML version from the Document. */
protected String getVersion(Document document) {
    if (document == null) {
        return null;
    }//from ww w.  ja  v  a2s.  co m
    String version = null;
    Method getXMLVersion = null;
    try {
        getXMLVersion = document.getClass().getMethod("getXmlVersion", new Class[] {});
        // If Document class implements DOM L3, this method will exist.
        if (getXMLVersion != null) {
            version = (String) getXMLVersion.invoke(document, null);
        }
    } catch (Exception e) {
        // Either this locator object doesn't have 
        // this method, or we're on an old JDK.
    }
    return version;
}