Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2002-2017 Gargoyle Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gargoylesoftware.htmlunit.javascript.host.html;
import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INNER_TEXT_READONLY_FOR_TABLE;
import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TABLE_VALIGN_SUPPORTS_IE_VALUES;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.EDGE;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter;
import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser;
import net.sourceforge.htmlunit.corejs.javascript.Context;
/**
* The JavaScript object {@code HTMLTableElement}.
*
* @author David D. Kilzer
* @author Mike Bowler
* @author Daniel Gredler
* @author Chris Erskine
* @author Marc Guillemot
* @author Ahmed Ashour
* @author Ronald Brill
* @author Frank Danek
*/
@JsxClass(domClass = HtmlTable.class)
public class HTMLTableElement extends RowContainer {
private static final List VALID_RULES_ = Arrays.asList("none", "groups", "rows", "cols");
/**
* Creates an instance.
*/
@JsxConstructor({@WebBrowser(CHROME), @WebBrowser(FF), @WebBrowser(EDGE)})
public HTMLTableElement() {
}
/**
* Returns the table's caption element, or {@code null} if none exists. If more than one
* caption is declared in the table, this method returns the first one.
* @return the table's caption element
*/
@JsxGetter
public Object getCaption() {
final List captions = getDomNodeOrDie().getElementsByTagName("caption");
if (captions.isEmpty()) {
return null;
}
return getScriptableFor(captions.get(0));
}
/**
* Sets the caption.
* @param o the caption
*/
@JsxSetter
public void setCaption(final Object o) {
if (!(o instanceof HTMLTableCaptionElement)) {
throw Context.reportRuntimeError("Not a caption");
}
// remove old caption (if any)
deleteCaption();
final HTMLTableCaptionElement caption = (HTMLTableCaptionElement) o;
getDomNodeOrDie().appendChild(caption.getDomNodeOrDie());
}
/**
* Returns the table's tfoot element, or {@code null} if none exists. If more than one
* tfoot is declared in the table, this method returns the first one.
* @return the table's tfoot element
*/
@JsxGetter
public Object getTFoot() {
final List tfoots = getDomNodeOrDie().getElementsByTagName("tfoot");
if (tfoots.isEmpty()) {
return null;
}
return getScriptableFor(tfoots.get(0));
}
/**
* Sets the tFoot.
* @param o the tFoot
*/
@JsxSetter
public void setTFoot(final Object o) {
if (!(o instanceof HTMLTableSectionElement
&& "TFOOT".equals(((HTMLTableSectionElement) o).getTagName()))) {
throw Context.reportRuntimeError("Not a tFoot");
}
// remove old caption (if any)
deleteTFoot();
final HTMLTableSectionElement tfoot = (HTMLTableSectionElement) o;
getDomNodeOrDie().appendChild(tfoot.getDomNodeOrDie());
}
/**
* Returns the table's thead element, or {@code null} if none exists. If more than one
* thead is declared in the table, this method returns the first one.
* @return the table's thead element
*/
@JsxGetter
public Object getTHead() {
final List theads = getDomNodeOrDie().getElementsByTagName("thead");
if (theads.isEmpty()) {
return null;
}
return getScriptableFor(theads.get(0));
}
/**
* Sets the {@code tHead}.
* @param o the {@code tHead}
*/
@JsxSetter
public void setTHead(final Object o) {
if (!(o instanceof HTMLTableSectionElement
&& "THEAD".equals(((HTMLTableSectionElement) o).getTagName()))) {
throw Context.reportRuntimeError("Not a tHead");
}
// remove old caption (if any)
deleteTHead();
final HTMLTableSectionElement thead = (HTMLTableSectionElement) o;
getDomNodeOrDie().appendChild(thead.getDomNodeOrDie());
}
/**
* Returns the tbody's in the table.
* @return the tbody's in the table
*/
@JsxGetter
public Object getTBodies() {
final HtmlTable table = (HtmlTable) getDomNodeOrDie();
return new HTMLCollection(table, false) {
@Override
protected List