📄 htmldocumentimpl.java
字号:
// Information not available on server side.
return null;
}
public String getDomain() {
// Information not available on server side.
return null;
}
public String getURL() {
// Information not available on server side.
return null;
}
public String getCookie() {
// Information not available on server side.
return null;
}
public void setCookie( String cookie ) {
// Information not available on server side.
}
public HTMLCollection getImages() {
// For more information see HTMLCollection#collectionMatch
if (_images == null) {
_images = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.IMAGE );
}
return _images;
}
public HTMLCollection getApplets() {
// For more information see HTMLCollection#collectionMatch
if (_applets == null) {
_applets = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.APPLET );
}
return _applets;
}
public HTMLCollection getLinks() {
// For more information see HTMLCollection#collectionMatch
if (_links == null) {
_links = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.LINK );
}
return _links;
}
public HTMLCollection getForms() {
// For more information see HTMLCollection#collectionMatch
if (_forms == null) {
_forms = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.FORM );
}
return _forms;
}
public HTMLCollection getAnchors() {
// For more information see HTMLCollection#collectionMatch
if (_anchors == null) {
_anchors = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.ANCHOR );
}
return _anchors;
}
public void open() {
// When called an in-memory is prepared. The document tree is still
// accessible the old way, until this writer is closed.
if (_writer == null) {
_writer = new StringWriter();
}
}
public void close() {
// ! NOT IMPLEMENTED, REQUIRES PARSER !
if (_writer != null) {
_writer = null;
}
}
public void write( String text ) {
// Write a string into the in-memory writer.
if (_writer != null) {
_writer.write( text );
}
}
public void writeln( String text ) {
// Write a line into the in-memory writer.
if (_writer != null) {
_writer.write( text + "\n" );
}
}
public Object clone() {
HTMLDocumentImpl clone;
clone = new HTMLDocumentImpl();
cloneInto( clone, true );
return clone;
}
public Node cloneNode( boolean deep ) {
HTMLDocumentImpl clone;
clone = new HTMLDocumentImpl();
cloneInto( clone, deep );
return clone;
}
protected Node castNewChild( Node newChild ) throws DOMException {
// Same method appears in HTMLElementImpl and HTMLDocumentImpl.
if (newChild == null) {
throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR, "Child reference is null." );
}
if (!(newChild instanceof NodeImpl)) {
throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR,
"Child is not a compatible type for this node." );
}
// newChild must be HTMLElement, Text, Comment, DocumentFragment or
// ProcessingInstruction. CDATASection and EntityReference not supported
// in HTML documents.
if (!(newChild instanceof HTMLElementImpl || newChild instanceof Comment || newChild instanceof Text
|| newChild instanceof DocumentFragment || newChild instanceof ProcessingInstruction)) {
throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR,
"Child is not a compatible type for this node." );
}
return (NodeImpl)newChild;
}
/**
* Recursive method retreives an element by its <code>id</code> attribute.
* Called by {@link #getElementById(String)}.
*
* @param elementId The <code>id</code> value to look for
* @return The node in which to look for
*/
private Element getElementById( String elementId, Node node ) {
Node child;
Element result;
child = node.getFirstChild();
while (child != null) {
if (child instanceof Element) {
if (elementId.equals( ((Element)child).getAttribute( "id" ) )) {
return (Element)child;
}
result = getElementById( elementId, child );
if (result != null) {
return result;
}
}
child = child.getNextSibling();
}
return null;
}
/**
* Called by the constructor to populate the element types list (see {@link
* #_elementTypesHTML}). Will be called multiple times but populate the list
* only the first time. Replacement for static constructor due to unknown
* problem with the static constructor.
*/
private static void populateElementTypes() {
if (_elementTypesHTML != null) {
return;
}
_elementTypesHTML = new Hashtable( 63 );
_elementTypesHTML.put( "A", HTMLAnchorElementImpl.class );
_elementTypesHTML.put( "APPLET", HTMLAppletElementImpl.class );
_elementTypesHTML.put( "AREA", HTMLAreaElementImpl.class );
_elementTypesHTML.put( "BASE", HTMLBaseElementImpl.class );
_elementTypesHTML.put( "BASEFONT", HTMLBaseFontElementImpl.class );
_elementTypesHTML.put( "BLOCKQUOTE", HTMLBlockquoteElementImpl.class );
_elementTypesHTML.put( "BODY", HTMLBodyElementImpl.class );
_elementTypesHTML.put( "BR", HTMLBRElementImpl.class );
_elementTypesHTML.put( "BUTTON", HTMLButtonElementImpl.class );
_elementTypesHTML.put( "DEL", HTMLModElementImpl.class );
_elementTypesHTML.put( "DIR", HTMLDirectoryElementImpl.class );
_elementTypesHTML.put( "DIV", HTMLDivElementImpl.class );
_elementTypesHTML.put( "DL", HTMLDListElementImpl.class );
_elementTypesHTML.put( "FIELDSET", HTMLFieldSetElementImpl.class );
_elementTypesHTML.put( "FONT", HTMLFontElementImpl.class );
_elementTypesHTML.put( "FORM", HTMLFormElementImpl.class );
_elementTypesHTML.put( "FRAME", HTMLFrameElementImpl.class );
_elementTypesHTML.put( "FRAMESET", HTMLFrameSetElementImpl.class );
_elementTypesHTML.put( "HEAD", HTMLHeadElementImpl.class );
_elementTypesHTML.put( "H1", HTMLHeadingElementImpl.class );
_elementTypesHTML.put( "H2", HTMLHeadingElementImpl.class );
_elementTypesHTML.put( "H3", HTMLHeadingElementImpl.class );
_elementTypesHTML.put( "H4", HTMLHeadingElementImpl.class );
_elementTypesHTML.put( "H5", HTMLHeadingElementImpl.class );
_elementTypesHTML.put( "H6", HTMLHeadingElementImpl.class );
_elementTypesHTML.put( "HR", HTMLHRElementImpl.class );
_elementTypesHTML.put( "HTML", HTMLHtmlElementImpl.class );
_elementTypesHTML.put( "IFRAME", HTMLIFrameElementImpl.class );
_elementTypesHTML.put( "IMG", HTMLImageElementImpl.class );
_elementTypesHTML.put( "INPUT", HTMLInputElementImpl.class );
_elementTypesHTML.put( "INS", HTMLModElementImpl.class );
_elementTypesHTML.put( "ISINDEX", HTMLIsIndexElementImpl.class );
_elementTypesHTML.put( "LABEL", HTMLLabelElementImpl.class );
_elementTypesHTML.put( "LEGEND", HTMLLegendElementImpl.class );
_elementTypesHTML.put( "LI", HTMLLIElementImpl.class );
_elementTypesHTML.put( "LINK", HTMLLinkElementImpl.class );
_elementTypesHTML.put( "MAP", HTMLMapElementImpl.class );
_elementTypesHTML.put( "MENU", HTMLMenuElementImpl.class );
_elementTypesHTML.put( "META", HTMLMetaElementImpl.class );
_elementTypesHTML.put( "OBJECT", HTMLObjectElementImpl.class );
_elementTypesHTML.put( "OL", HTMLOListElementImpl.class );
_elementTypesHTML.put( "OPTGROUP", HTMLOptGroupElementImpl.class );
_elementTypesHTML.put( "OPTION", HTMLOptionElementImpl.class );
_elementTypesHTML.put( "P", HTMLParagraphElementImpl.class );
_elementTypesHTML.put( "PARAM", HTMLParamElementImpl.class );
_elementTypesHTML.put( "PRE", HTMLPreElementImpl.class );
_elementTypesHTML.put( "Q", HTMLQuoteElementImpl.class );
_elementTypesHTML.put( "SCRIPT", HTMLScriptElementImpl.class );
_elementTypesHTML.put( "SELECT", HTMLSelectElementImpl.class );
_elementTypesHTML.put( "STYLE", HTMLStyleElementImpl.class );
_elementTypesHTML.put( "TABLE", HTMLTableElementImpl.class );
_elementTypesHTML.put( "CAPTION", HTMLTableCaptionElementImpl.class );
_elementTypesHTML.put( "TD", HTMLTableCellElementImpl.class );
_elementTypesHTML.put( "COL", HTMLTableColElementImpl.class );
_elementTypesHTML.put( "COLGROUP", HTMLTableColElementImpl.class );
_elementTypesHTML.put( "TR", HTMLTableRowElementImpl.class );
_elementTypesHTML.put( "TBODY", HTMLTableSectionElementImpl.class );
_elementTypesHTML.put( "THEAD", HTMLTableSectionElementImpl.class );
_elementTypesHTML.put( "TFOOT", HTMLTableSectionElementImpl.class );
_elementTypesHTML.put( "TEXTAREA", HTMLTextAreaElementImpl.class );
_elementTypesHTML.put( "TITLE", HTMLTitleElementImpl.class );
_elementTypesHTML.put( "UL", HTMLUListElementImpl.class );
}
/**
*/
public HTMLDocumentImpl() {
super();
populateElementTypes();
}
/**
* Holds {@link HTMLCollectionImpl} object with live collection of all
* anchors in document. This reference is on demand only once.
*/
private HTMLCollectionImpl _anchors;
/**
* Holds {@link HTMLCollectionImpl} object with live collection of all
* forms in document. This reference is on demand only once.
*/
private HTMLCollectionImpl _forms;
/**
* Holds {@link HTMLCollectionImpl} object with live collection of all
* images in document. This reference is on demand only once.
*/
private HTMLCollectionImpl _images;
/**
* Holds {@link HTMLCollectionImpl} object with live collection of all
* links in document. This reference is on demand only once.
*/
private HTMLCollectionImpl _links;
/**
* Holds {@link HTMLCollectionImpl} object with live collection of all
* applets in document. This reference is on demand only once.
*/
private HTMLCollectionImpl _applets;
/**
* Holds string writer used by direct manipulation operation ({@link #open}.
* {@link #write}, etc) to write new contents into the document and parse
* that text into a document tree.
*/
private StringWriter _writer;
/**
* Holds names and classes of HTML element types. When an element with a
* particular tag name is created, the matching {@link java.lang.Class}
* is used to create the element object. For example, <A> matches
* {@link HTMLAnchorElementImpl}. This static table is shared across all
* HTML documents, as opposed to the non-static table defined in {@link
* org.openxml.dom.DocumentImpl}.
*
* @see #createElement
*/
private static Hashtable _elementTypesHTML;
/**
* Signature used to locate constructor of HTML element classes. This
* static array is shared across all HTML documents.
*
* @see #createElement
*/
private final static Class[] _elemClassSigHTML = new Class[] {HTMLDocumentImpl.class, String.class};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -