类org.w3c.dom.html.HTMLDocument源码实例Demo

下面列出了怎么用org.w3c.dom.html.HTMLDocument的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk1.8-source-analysis   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码2 项目: jdk1.8-source-analysis   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码3 项目: TencentKona-8   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码4 项目: TencentKona-8   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码5 项目: oim-fx   文件: ShowPanelFrame.java
private void initEvent() {
	button.setOnAction(new EventHandler<ActionEvent>() {

		@Override
		public void handle(ActionEvent event) {
			
			Document doc = webPage.getDocument(webPage.getMainFrame());
			if (doc instanceof HTMLDocument) {
				HTMLDocument htmlDocument = (HTMLDocument) doc;
				Element e = htmlDocument.createElement("div");
				e.setTextContent("hhhhhhh");
				HTMLElement htmlDocumentElement = (HTMLElement)htmlDocument.getDocumentElement();
		        HTMLElement htmlBodyElement = (HTMLElement)htmlDocumentElement.getElementsByTagName("body").item(0);
		        
				//e.setAttribute(name, value);
		        //org.w3c.dom.Node n=htmlBodyElement.getLastChild();;
		        htmlBodyElement.appendChild(e);
		        webPage.getClientInsertPositionOffset();
		       // htmlBodyElement.ge
				//hd.appendChild(e);
				System.out.println(e.getClass());
			}
		}
	});

}
 
源代码6 项目: jdk8u60   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码7 项目: jdk8u60   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码8 项目: JDKSourceCode1.8   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码9 项目: JDKSourceCode1.8   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码10 项目: openjdk-jdk8u   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码11 项目: openjdk-jdk8u   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码12 项目: lams   文件: DomBasedScriptingEngineFactory.java
/**
 * load
 * @param response
 */
public void load( WebResponse response ) {
		Function onLoadEvent=null;
    try {
        Context context = Context.enter();
        context.initStandardObjects( null );

        HTMLDocument htmlDocument = ((DomWindow) response.getScriptingHandler()).getDocument();
        if (!(htmlDocument instanceof HTMLDocumentImpl)) return;

        HTMLBodyElementImpl body = (HTMLBodyElementImpl) htmlDocument.getBody();
        if (body == null) return;
        onLoadEvent = body.getOnloadEvent();
        if (onLoadEvent == null) return;
        onLoadEvent.call( context, body, body, new Object[0] );
    } catch (JavaScriptException e) {
    	ScriptingEngineImpl.handleScriptException(e, onLoadEvent.toString());
    	// HttpUnitUtils.handleException(e);
    } catch (EcmaError ee) {
    	//throw ee;
    	ScriptingEngineImpl.handleScriptException(ee, onLoadEvent.toString());        	
    } finally {
        Context.exit();
    }
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码15 项目: hottub   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码16 项目: hottub   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码17 项目: openjdk-8-source   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码18 项目: openjdk-8-source   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码19 项目: openjdk-8   文件: OutputFormat.java
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
源代码20 项目: openjdk-8   文件: OutputFormat.java
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
源代码21 项目: oim-fx   文件: WritePanel.java
private void updateStyle() {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);
		htmlBodyElement.setAttribute("style", createStyleValue().toString());
	}
}
 
源代码22 项目: oim-fx   文件: WritePanel.java
public void insertImage(String path, String id, String name, String value) {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);

		if (htmlBodyElement instanceof HTMLBodyElementImpl) {
			// HTMLBodyElementImpl htmlBodyElementImpl =
			// (HTMLBodyElementImpl) htmlBodyElement;
			// Element e = htmlBodyElementImpl.getOffsetParent();
			// htmlBodyElementImpl.insertBefore(newChild, refChild)
			// htmlDocument.
		}

		Element e = htmlDocument.createElement("img");
		e.setAttribute("id", id);
		e.setAttribute("name", name);
		e.setAttribute("value", value);
		e.setAttribute("src", path);

		// webEngine.get
		// webView.get

		int positionOffset = webPage.getClientInsertPositionOffset();
		int index = (positionOffset + 1);
		NodeList nodeList = htmlBodyElement.getChildNodes();
		int length = nodeList.getLength();
		if (index < 0) {
			htmlBodyElement.appendChild(e);
		} else if (index < length) {
			org.w3c.dom.Node node = nodeList.item(index);
			htmlBodyElement.insertBefore(e, node);
		} else {
			htmlBodyElement.appendChild(e);
		}
		webPage.getClientInsertPositionOffset();
	}
}
 
源代码23 项目: oim-fx   文件: ShowPanel.java
public void insertLast(String text, String fontName, int fontSize, String color, boolean bold, boolean underline, boolean italic) {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);

		Element element = htmlDocument.createElement("div");
		element.setTextContent(text);
		element.setAttribute("style", createStyleValue(fontName, fontSize, color, bold, underline, italic).toString());
		htmlBodyElement.appendChild(element);

	}
}
 
源代码24 项目: oim-fx   文件: ChatWritePane.java
private void updateStyle() {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);
		htmlBodyElement.setAttribute("style", createStyleValue().toString());
	}
}
 
源代码25 项目: oim-fx   文件: ChatWritePane.java
public void insert(String text) {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);

		if (htmlBodyElement instanceof HTMLBodyElementImpl) {
		}

		Element e = htmlDocument.createElement("div");
		e.setTextContent(text);

		int positionOffset = webPage.getClientInsertPositionOffset();
		int index = (positionOffset + 1);
		NodeList nodeList = htmlBodyElement.getChildNodes();
		int length = nodeList.getLength();
		if (index < 0) {
			htmlBodyElement.appendChild(e);
		} else if (index < length) {
			org.w3c.dom.Node node = nodeList.item(index);
			// htmlBodyElement.
			htmlBodyElement.insertBefore(e, node);
		} else {
			htmlBodyElement.appendChild(e);
		}

		webPage.getClientInsertPositionOffset();

	}
}
 
源代码26 项目: oim-fx   文件: ChatWritePane.java
public void insertImage(String path, String id, String name, String value) {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);

		if (htmlBodyElement instanceof HTMLBodyElementImpl) {
		}

		Element e = htmlDocument.createElement("img");
		e.setAttribute("id", id);
		e.setAttribute("name", name);
		e.setAttribute("value", value);
		e.setAttribute("src", path);

		// webEngine.get
		// webView.get

		int positionOffset = webPage.getClientInsertPositionOffset();
		int index = (positionOffset + 1);
		NodeList nodeList = htmlBodyElement.getChildNodes();
		int length = nodeList.getLength();
		if (index < 0) {
			htmlBodyElement.appendChild(e);
		} else if (index < length) {
			org.w3c.dom.Node node = nodeList.item(index);
			htmlBodyElement.insertBefore(e, node);
		} else {
			htmlBodyElement.appendChild(e);
		}
		webPage.getClientInsertPositionOffset();
	}
}
 
源代码27 项目: oim-fx   文件: WritePane.java
private void updateStyle() {
	Document doc = webPage.getDocument(webPage.getMainFrame());
	if (doc instanceof HTMLDocument) {
		HTMLDocument htmlDocument = (HTMLDocument) doc;
		HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement();
		HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0);
		htmlBodyElement.setAttribute("style", createStyleValue().toString());
	}
}
 
源代码28 项目: lams   文件: HTMLPage.java
/**
 * parse the given test with the given URL
 * @param text
 * @param pageURL
 * @throws SAXException
 * @throws IOException
 */
public void parse( String text, URL pageURL ) throws SAXException, IOException {
    HTMLParserFactory.getHTMLParser().parse( pageURL, text, new DocumentAdapter() {
        public void setDocument(HTMLDocument document ) { HTMLPage.this.setRootNode( document ); }
        public String getIncludedScript( String srcAttribute ) throws IOException { return HTMLPage.this.getIncludedScript( srcAttribute ); }
        public ScriptingHandler getScriptingHandler() { return getResponse().getScriptingHandler(); }
    });
}
 
源代码29 项目: lams   文件: NekoHTMLParser.java
/**
* parse the given URL with the given pageText using the given document adapter
* @param pageURL
* @param pageText
* @param adapter
*/
public void parse( URL pageURL, String pageText, DocumentAdapter adapter ) throws IOException, SAXException {
    try {
        NekoDOMParser parser = NekoDOMParser.newParser( adapter, pageURL );
        parser.parse( new InputSource( new StringReader( pageText ) ) );
        Document doc=parser.getDocument();
       	adapter.setDocument( (HTMLDocument)doc );
    } catch (NekoDOMParser.ScriptException e) {
         throw e.getException();
    }     
}
 
源代码30 项目: lams   文件: JTidyHTMLParser.java
public void parse( URL pageURL, String pageText, DocumentAdapter adapter ) throws IOException, SAXException {
    try {
        Document jtidyDocument = getParser( pageURL ).parseDOM( new ByteArrayInputStream( pageText.getBytes( UTF_ENCODING ) ), null );
        HTMLDocument htmlDocument = new HTMLDocumentImpl();
        NodeList nl = jtidyDocument.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node importedNode = nl.item(i);
            if (importedNode.getNodeType() != Node.DOCUMENT_TYPE_NODE) htmlDocument.appendChild( htmlDocument.importNode( importedNode, true ) );
        }
        adapter.setDocument( htmlDocument );
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException( "UTF-8 encoding failed" );
    }
}
 
 类所在包
 类方法
 同包方法