//   Copyright 2012 Georg-August-Universität Göttingen, Germany
//
//   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 de.ugoe.cs.autoquest.plugin.html.guimodel;

import de.ugoe.cs.autoquest.eventcore.guimodel.IDialog;

/**
 * <p>
 * a GUI element representing an HTML document, i.e., a page on an HTML server. This is the
 * element for a GUI model of an HTML web site being always and only the children of servers. It
 * is identified through the server on which it resists, its path, a potential query, and a title.
 * Its children are HTML page elements
 * </p>
 * 
 * @author Patrick Harms
 */
public class HTMLDocument extends HTMLGUIElement implements IDialog {

    /**
     * <p>
     * default serial version UID
     * </p> 
     */
    private static final long serialVersionUID = 1L;

    /**
     * <p>
     * instantiates the document with it specification and its parent, which is always a server
     * </p>
     *
     * @param specification the specification of the document
     * @param parent        the server on which the document resists
     */
    public HTMLDocument(HTMLDocumentSpec specification, HTMLServer parent) {
        super(specification, parent);
    }

    /**
     * <p>
     * returns the path in the URL of the document
     * </p>
     *
     * @return the path in the URL of the document
     */
    public String getPath() {
        return ((HTMLDocumentSpec) super.getSpecification()).getPath();
    }

    /*
     * (non-Javadoc)
     * 
     * @see de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLGUIElement#getElementDescriptor()
     */
    @Override
    protected String getElementDescriptor() {
        return "Document";
    }

    /**
     * <p>
     * returns the server on which the document resists
     * </p>
     *
     * @return the server on which the document resists
     */
    HTMLServer getServer() {
        return (HTMLServer) super.getParent();
    }

    /**
     * <p>
     * returns the title of the document
     * </p>
     *
     * @return the title of the document
     */
    String getTitle() {
        return ((HTMLDocumentSpec) super.getSpecification()).getTitle();
    }

}
