All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enhydra.xml.xhtml.dom.xerces.XHTMLTableElementImpl Maven / Gradle / Ivy

The newest version!
/*
 * Enhydra Java Application Server Project
 * 
 * The contents of this file are subject to the Enhydra Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License on
 * the Enhydra web site ( http://www.enhydra.org/ ).
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
 * the License for the specific terms governing rights and limitations
 * under the License.
 * 
 * The Initial Developer of the Original Code is DigitalSesame
 * Portions created by DigitalSesame are Copyright (C) 1997-2000 DigitalSesame
 * All Rights Reserved.
 * 
 * Contributor(s):
 *     Rex Tsai 
 *     David Li 
 * 
 * $Id: XHTMLTableElementImpl.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
 */

package org.enhydra.xml.xhtml.dom.xerces;

import org.w3c.dom.Node;
import org.w3c.dom.html.HTMLCollection;
import org.w3c.dom.html.HTMLElement;
import org.w3c.dom.html.HTMLTableCaptionElement;
import org.w3c.dom.html.HTMLTableRowElement;
import org.w3c.dom.html.HTMLTableSectionElement;

public class XHTMLTableElementImpl 
    extends XHTMLElementImpl 
    implements org.enhydra.xml.xhtml.dom.XHTMLTableElement 
{

    public XHTMLTableElementImpl (XHTMLDocumentBase owner, String namespaceURI, String tagName) {
	super( owner, namespaceURI, tagName);
    }

        public void setId (String newValue) {
	setAttribute("id", newValue);
    }

    public String getId () {
	return getAttribute ("id");
    }
    public void setLang (String newValue) {
	setAttribute("lang", newValue);
    }

    public String getLang () {
	return getAttribute ("lang");
    }
    public void setDir (String newValue) {
	setAttribute("dir", newValue);
    }

    public String getDir () {
	return getAttribute ("dir");
    }
    public void setClassName (String newValue) {
	setAttribute("class", newValue);
    }

    public String getClassName () {
	return getAttribute ("class");
    }
    public void setTitle (String newValue) {
	setAttribute("title", newValue);
    }

    public String getTitle () {
	return getAttribute ("title");
    }
    public void setAlign (String newValue) {
	setAttribute("align", newValue);
    }

    public String getAlign () {
	return getAttribute ("align");
    }
    public void setWidth (String newValue) {
	setAttribute("width", newValue);
    }

    public String getWidth () {
	return getAttribute ("width");
    }
    public void setBgColor (String newValue) {
	setAttribute("bgcolor", newValue);
    }

    public String getBgColor () {
	return getAttribute ("bgcolor");
    }
    public void setBorder (String newValue) {
	setAttribute("border", newValue);
    }

    public String getBorder () {
	return getAttribute ("border");
    }
    public void setCellPadding (String newValue) {
	setAttribute("cellpadding", newValue);
    }

    public String getCellPadding () {
	return getAttribute ("cellpadding");
    }
    public void setCellSpacing (String newValue) {
	setAttribute("cellspacing", newValue);
    }

    public String getCellSpacing () {
	return getAttribute ("cellspacing");
    }
    public void setFrame (String newValue) {
	setAttribute("frame", newValue);
    }

    public String getFrame () {
	return getAttribute ("frame");
    }
    public void setRules (String newValue) {
	setAttribute("rules", newValue);
    }

    public String getRules () {
	return getAttribute ("rules");
    }
    public void setSummary (String newValue) {
	setAttribute("summary", newValue);
    }

    public String getSummary () {
	return getAttribute ("summary");
    }
    public void setOnKeyUp (String newValue) {
	setAttribute("onkeyup", newValue);
    }

    public String getOnKeyUp () {
	return getAttribute ("onkeyup");
    }
    public void setStyle (String newValue) {
	setAttribute("style", newValue);
    }

    public String getStyle () {
	return getAttribute ("style");
    }
    public void setOnMouseDown (String newValue) {
	setAttribute("onmousedown", newValue);
    }

    public String getOnMouseDown () {
	return getAttribute ("onmousedown");
    }
    public void setOnKeyPress (String newValue) {
	setAttribute("onkeypress", newValue);
    }

    public String getOnKeyPress () {
	return getAttribute ("onkeypress");
    }
    public void setOnDblClick (String newValue) {
	setAttribute("ondblclick", newValue);
    }

    public String getOnDblClick () {
	return getAttribute ("ondblclick");
    }
    public void setOnKeyDown (String newValue) {
	setAttribute("onkeydown", newValue);
    }

    public String getOnKeyDown () {
	return getAttribute ("onkeydown");
    }
    public void setOnMouseMove (String newValue) {
	setAttribute("onmousemove", newValue);
    }

    public String getOnMouseMove () {
	return getAttribute ("onmousemove");
    }
    public void setOnMouseUp (String newValue) {
	setAttribute("onmouseup", newValue);
    }

    public String getOnMouseUp () {
	return getAttribute ("onmouseup");
    }
    public void setXmlLang (String newValue) {
	setAttribute("xml:lang", newValue);
    }

    public String getXmlLang () {
	return getAttribute ("xml:lang");
    }
    public void setOnMouseOut (String newValue) {
	setAttribute("onmouseout", newValue);
    }

    public String getOnMouseOut () {
	return getAttribute ("onmouseout");
    }
    public void setOnClick (String newValue) {
	setAttribute("onclick", newValue);
    }

    public String getOnClick () {
	return getAttribute ("onclick");
    }
    public void setOnMouseOver (String newValue) {
	setAttribute("onmouseover", newValue);
    }

    public String getOnMouseOver () {
	return getAttribute ("onmouseover");
    }
;

        
    public synchronized HTMLTableCaptionElement getCaption() {
        Node    child;
        
        child = getFirstChild();
        while ( child != null ) {
            if ( child instanceof HTMLTableCaptionElement &&
                 child.getNodeName().equals( "CAPTION" ) )
                return (HTMLTableCaptionElement) child;
            child = child.getNextSibling();
        }
        return null;
    }
    
    
    public synchronized void setCaption( HTMLTableCaptionElement caption )
    {
        if ( caption != null && ! caption.getTagName().equals( "CAPTION" ) )
            throw new IllegalArgumentException( "HTM016 Argument 'caption' is not an element of type ." );
        deleteCaption();
        if ( caption != null )
            appendChild( caption );
    }
    
    
    public synchronized HTMLElement createCaption() {
        HTMLElement    section;
        
        section = getCaption();
        if ( section != null )
            return section;
        section = new XHTMLTableCaptionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "CAPTION" );
        appendChild( section );
        return section;
    }
  
    public synchronized void deleteCaption() {
        Node    old;
        
        old = getCaption();
        if ( old != null )
            removeChild ( old );
    }
    
    public synchronized HTMLTableSectionElement getTHead() {
        Node    child;
        
        child = getFirstChild();
        while ( child != null ) {
            if ( child instanceof HTMLTableSectionElement &&
                 child.getNodeName().equals( "THEAD" ) )
                return (HTMLTableSectionElement) child;
            child = child.getNextSibling();
        }
        return null;
    }
    
    public synchronized void setTHead( HTMLTableSectionElement tHead ) {
        if ( tHead != null && ! tHead.getTagName().equals( "THEAD" ) )
            throw new IllegalArgumentException( "HTM017 Argument 'tHead' is not an element of type ." );
        deleteTHead();
        if ( tHead != null )
            appendChild( tHead );
    }
    
    public synchronized HTMLElement createTHead() {
        HTMLElement    section;
        
        section = getTHead();
        if ( section != null )
            return section;
        section = new XHTMLTableSectionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "THEAD" );
        appendChild( section );
        return section;
    }

    
    public synchronized void deleteTHead() {
        Node    old;
        
        old = getTHead();
        if ( old != null )
            removeChild ( old );
    }
    
    public synchronized HTMLTableSectionElement getTFoot() {
        Node    child;
        
        child = getFirstChild();
        while ( child != null )
        {
            if ( child instanceof HTMLTableSectionElement &&
                 child.getNodeName().equals( "tfoot" ) )
                return (HTMLTableSectionElement) child;
            child = child.getNextSibling();
        }
        return null;
    }
    
    
    public synchronized void setTFoot( HTMLTableSectionElement tFoot ) {
        if ( tFoot != null && ! tFoot.getTagName().equals( "tfoot" ) )
            throw new IllegalArgumentException( "HTM018 Argument 'tFoot' is not an element of type ." );
        deleteTFoot();
        if ( tFoot != null )
            appendChild( tFoot );
    }
    
    
    public synchronized HTMLElement createTFoot() {
        HTMLElement    section;
        
        section = getTFoot();
        if ( section != null )
            return section;
        section = new XHTMLTableSectionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "TFOOT" );
        appendChild( section );
        return section;
    }

    
    public synchronized void deleteTFoot() {
        Node    old;
        
        old = getTFoot();
        if ( old != null )
            removeChild ( old );
    }
    
    public HTMLCollection getRows() {
        if ( _rows == null )
            _rows = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.ROW );
        return _rows;
    }
    

    public HTMLCollection getTBodies() {
        if ( _bodies == null )
            _bodies = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.TBODY );
        return _bodies;
    }
  
    public HTMLElement insertRow( int index ) {
        XHTMLTableRowElementImpl    newRow;

        newRow = new XHTMLTableRowElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "TR" );
        //newRow.insertCell( 0 );
        insertRowX( index, newRow );
        return newRow;
    }
        
        
    void insertRowX( int index, XHTMLTableRowElementImpl newRow ) {
        Node    child;
        Node    lastSection = null;
                
        child = getFirstChild();
        while ( child != null ) {
            if ( child instanceof HTMLTableRowElement ) {
                if ( index == 0 ) {
                    insertBefore( newRow, child );
                    return;
                }
            } else if ( child instanceof XHTMLTableSectionElementImpl ) {
                lastSection = child;
                index = ( (XHTMLTableSectionElementImpl) child ).insertRowX( index, newRow );
                if ( index < 0 )
                    return;
            }
            child = child.getNextSibling();
        }
        if ( lastSection != null )
            lastSection.appendChild( newRow );
        else
            appendChild( newRow );
    }
    
    
    public synchronized void deleteRow( int index ) {
        Node    child;
        
        child = getFirstChild();
        while ( child != null ) {
            if ( child instanceof HTMLTableRowElement ) {
                if ( index == 0 ) {
                    removeChild ( child );
                    return;
                }
            } else if ( child instanceof XHTMLTableSectionElementImpl ) {
                index = ( (XHTMLTableSectionElementImpl) child ).deleteRowX( index );
                if ( index < 0 )
                    return;
            }
            child = child.getNextSibling();
        }
    }

    private XHTMLCollectionImpl    _rows;
    
    private XHTMLCollectionImpl    _bodies;

;
}






© 2015 - 2025 Weber Informatics LLC | Privacy Policy