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

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

The newest version!
package org.enhydra.xml.xhtml.dom.xerces;
    
import org.enhydra.apache.xerces.dom.DOMImplementationImpl;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.html.HTMLDOMImplementation;
import org.w3c.dom.html.HTMLDocument;

/**
 * Provides number of methods for performing operations that are independent
 * of any particular instance of the document object model. This class is
 * unconstructable, the only way to obtain an instance of a DOM implementation
 * is by calling the static method {@link #getDOMImplementation}.
 * 
 * @version $Revision: 1.2 $ $Date: 2005/01/26 08:28:45 $
 * @author Assaf Arkin
 * @see org.w3c.dom.DOMImplementation
 */
public class XHTMLDOMImplementationImpl
    extends DOMImplementationImpl
    implements HTMLDOMImplementation
{
    /**
     * Holds a reference to the single instance of the DOM implementation.
     * Only one instance is required since this class is multiple entry.
     */
    private static HTMLDOMImplementation _instance = new XHTMLDOMImplementationImpl();


    /**
     * Private constructor assures that an object of this class cannot
     * be created. The only way to obtain an object is by calling {@link
     * #getDOMImplementation}.
     */
    private XHTMLDOMImplementationImpl()
    {
    }


    /**
     * @see org.w3c.dom.DOMImplementation
     */
    public Document createDocument(String namespaceURI, 
				   String qualifiedName, 
				   DocumentType doctype) throws DOMException {
	if (qualifiedName == null) {
	    throw new NullPointerException("qualifiedName is null");
        }
        Document doc = new XHTMLDocumentImpl(doctype);
        Element e = doc.createElementNS(namespaceURI, qualifiedName);
        doc.appendChild(e);
        return doc;
    }


    /**
     * Create a new HTML document of the specified TITLE text.
     *
     * @param title The document title text
     * @return New HTML document
     */
    public final HTMLDocument createHTMLDocument( String title )
        throws DOMException
    {
	HTMLDocument doc;

	if ( title == null )
	    throw new NullPointerException( "HTM014 Argument 'title' is null." );
	doc = new XHTMLDocumentImpl();
	doc.setTitle( title );
	return doc;
    }


    /**
     * Returns an instance of a {@link HTMLDOMImplementation} that can be
     * used to perform operations that are not specific to a particular
     * document instance, e.g. to create a new document.
     *
     * @return Reference to a valid DOM implementation
     */
    public static HTMLDOMImplementation getHTMLDOMImplementation()
    {
	return _instance;
    }

    /**
     * Returns an instance of a {@link HTMLDOMImplementation} that can be
     * used to perform operations that are not specific to a particular
     * document instance, e.g. to create a new document.
     *
     * @return Reference to a valid DOM implementation
     */
    public static DOMImplementation getDOMImplementation()
    {
	return _instance;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy