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

org.enhydra.xml.xmlc.html.HTMLObjectImpl 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 Enhydra Application Server is Lutris
 * Technologies, Inc. The Enhydra Application Server and portions created
 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
 * All Rights Reserved.
 * 
 * Contributor(s):
 * 
 * $Id: HTMLObjectImpl.java,v 1.3 2005/01/26 08:29:24 jkjome Exp $
 */

package org.enhydra.xml.xmlc.html;

import org.enhydra.xml.io.DOMFormatter;
import org.enhydra.xml.xmlc.XMLObjectImpl;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.html.HTMLCollection;
import org.w3c.dom.html.HTMLDocument;
import org.w3c.dom.html.HTMLElement;

// Note: Most methods in this object don't need to directly
// implement delegation, as they operate on the document,
// returned by getDocument(), which is delegate.

/**
 * Abstract class that forms the base of all compiled HTML Objects.
 */
public abstract class HTMLObjectImpl extends XMLObjectImpl
    implements HTMLObject {
    /**
     * Default HTML formatting object for use by toDocument().  Initialized
     * on first use and shared
     */
    private static DOMFormatter fFormatter = null;

    /**
     * Constructor.  The setDocument() method must be called to
     * associate a document with this object.
     */
    protected HTMLObjectImpl() {
    }

    /**
     * Clone the entire document.  Derived objects should override this
     * to get the correct derived type.  Cloning with deep being false
     * is not allowed.
     *
     * @see org.w3c.dom.Node#cloneNode
     */
    abstract public Node cloneNode(boolean deep);

    /**
     * @see HTMLObject#toDocument
     */
    public String toDocument() {
        // Create formatter if needed (no synchronization necessary)
        if (fFormatter == null) {
            fFormatter = new DOMFormatter(DOMFormatter.getDefaultOutputOptions(getDocument()));
        }
        return fFormatter.toString(this);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getTitle
     */
    public String getTitle() {
        return ((HTMLDocument)getDocument()).getTitle();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#setTitle
     */
    public void setTitle(String title) {
        ((HTMLDocument)getDocument()).setTitle(title);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getReferrer
     */
    public String getReferrer() {
        return ((HTMLDocument)getDocument()).getReferrer();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getDomain
     */
    public String getDomain() {
        return ((HTMLDocument)getDocument()).getDomain();
    }
    
    /**
     * @see org.w3c.dom.html.HTMLDocument
     */
    public String getURL() {
        return ((HTMLDocument)getDocument()).getURL();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument
     */
    public HTMLElement getBody() {
        return ((HTMLDocument)getDocument()).getBody();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#setBody
     */
    public void setBody(HTMLElement body) {
        ((HTMLDocument)getDocument()).setBody(body);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getImages
     */
    public HTMLCollection getImages() {
        return ((HTMLDocument)getDocument()).getImages();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument
     */
    public HTMLCollection getApplets() {
        return ((HTMLDocument)getDocument()).getApplets();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument
     */
    public HTMLCollection getLinks() {
        return ((HTMLDocument)getDocument()).getLinks();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getForms
     */
    public HTMLCollection getForms() {
        return ((HTMLDocument)getDocument()).getForms();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getAnchors
     */
    public HTMLCollection getAnchors() {
        return ((HTMLDocument)getDocument()).getAnchors();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getCookie
     */
    public String getCookie() {
        return ((HTMLDocument)getDocument()).getCookie();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#setCookie
     */
    public void setCookie(String cookie) {
        ((HTMLDocument)getDocument()).setCookie(cookie);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#open
     */
    public void open() {
        ((HTMLDocument)getDocument()).open();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#close
     */
    public void close() {
        ((HTMLDocument)getDocument()).close();
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#write
     */
    public void write(String text) {
        ((HTMLDocument)getDocument()).write(text);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#writeln
     */
    public void writeln(String text) {
        ((HTMLDocument)getDocument()).writeln(text);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getElementById
     */
    public Element getElementById(String elementId) {
        return ((HTMLDocument)getDocument()).getElementById(elementId);
    }

    /**
     * @see org.w3c.dom.html.HTMLDocument#getElementsByName
     */
    public NodeList getElementsByName(String elementName) { 
        return ((HTMLDocument)getDocument()).getElementsByName(elementName);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy