Index: trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlPageElement.java
===================================================================
--- trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlPageElement.java	(revision 1022)
+++ trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlPageElement.java	(revision 1069)
@@ -15,38 +15,32 @@
 package de.ugoe.cs.autoquest.htmlmonitor;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * <p>
- * represents an element of an HTML GUI. This can be a server, which is usually the root of a
- * GUI structure, a web page, or a tag within a web page.
+ * represents an element of an HTML GUI, i.e. a tag within a web page.
  * </p>
  * 
  * @author Patrick Harms
  */
-class HtmlPageElement {
-
-    /**
-     * path to the parent of this page element or null, if this is the root element
-     */
-    private String parentPath;
-    
-    /**
-     * the name of the tag represented by this page element. May also be the name of the server
-     * or the page.
+class HtmlPageElement extends HtmlGUIElement {
+
+    /**
+     * the document to which the represented tag belongs
+     */
+    private HtmlDocument document;
+    
+    /**
+     * the parent page element; if null, the document is considered the parent
+     */
+    private HtmlPageElement parent;
+    
+    /**
+     * the name of the tag represented by this page element.
      */
     private String tagName;
     
     /**
-     * the id of the page element. May also be the name of the server including port number or the
-     * URL of the page
-     */
-    private String id;
-    
-    /**
-     * the title of the page if a page is represented through this element
-     */
-    private String title;
+     * the id of the page element inside the DOM.
+     */
+    private String htmlId;
     
     /**
@@ -57,23 +51,41 @@
     
     /**
-     * the children of this element
-     */
-    private List<HtmlPageElement> children;
-
-    /**
      * <p>
      * instantiates a new element representing a tag in an HTML page
      * </p>
      *
-     * @param parentPath the path through the DOM to the parent node of the represented tag 
-     * @param tagName    the name of the represented tag
-     * @param id         the id of the tag in the DOM
-     * @param index      the index of the represented tag regarding all tags with the same tag name
-     *                   in the list of children of the parent tag
-     */
-    HtmlPageElement(String parentPath, String tagName, String id, Integer index) {
-        this.parentPath = parentPath;
+     * @param id       the id of the page element
+     * @param document the document to which the represented tag belongs
+     * @param parent   the parent page element; if null, the document is considered the parent
+     * @param tagName  the name of the represented tag
+     * @param htmlId   the id of the tag in the DOM
+     * @param index    the index of the represented tag regarding all tags with the same
+     *                 tag name in the list of children of the parent tag
+     */
+    HtmlPageElement(String          id,
+                    HtmlDocument    document,
+                    HtmlPageElement parent,
+                    String          tagName,
+                    String          htmlId,
+                    Integer         index)
+    {
+        super(id, parent == null ? document : parent);
+        
+        if (document == null) {
+            throw new IllegalArgumentException("document must not be null");
+        }
+
+        if (tagName == null) {
+            throw new IllegalArgumentException("tagName must not be null");
+        }
+        
+        if ((htmlId == null) && (index == null)) {
+            throw new IllegalArgumentException("either one of htmlId and index must not be null");
+        }
+        
+        this.document = document;
+        this.parent = parent;
         this.tagName = tagName;
-        this.id = id;
+        this.htmlId = htmlId;
         this.index = index;
     }
@@ -81,23 +93,16 @@
     /**
      * <p>
-     * instantiates a new element representing an HTML page
+     * returns the document to which the represented tag belongs
      * </p>
      *
-     * @param parentPath the path through the DOM to the parent node of the represented tag which is
-     *                   usually a server
-     * @param tagName    the name of the represented tag which is the path of the web page
-     * @param title      the title of the web page
-     * @param id         the id of the web page which is its path
-     * @param index      usually 0
-     */
-    HtmlPageElement(String parentPath, String tagName, String id, String title, Integer index) {
-        this(parentPath, tagName, id, index);
-        this.title = title;
-    }
-
-    /**
-     * <p>
-     * returns the name of the tag represented by this page element. May also be the name of the
-     * server or the page.
+     * @return the document
+     */
+    HtmlDocument getDocument() {
+        return document;
+    }
+
+    /**
+     * <p>
+     * returns the name of the tag represented by this page element.
      * </p>
      * 
@@ -110,23 +115,11 @@
     /**
      * <p>
-     * returns the id of the page element. May also be the name of the server including port
-     * number or the URL of the page
+     * returns the id of the page element.
      * </p>
      * 
      * @return the id
      */
-    String getId() {
-        return id;
-    }
-
-    /**
-     * <p>
-     * returns the title of the page if a page is represented through this element
-     * </p>
-     * 
-     * @return the title
-     */
-    String getTitle() {
-        return title;
+    String getHtmlId() {
+        return htmlId;
     }
 
@@ -141,42 +134,4 @@
     Integer getIndex() {
         return index;
-    }
-
-    /**
-     * <p>
-     * returns the children of this element if any, null else
-     * </p>
-     * 
-     * @return the children
-     */
-    List<HtmlPageElement> getChildren() {
-        return children;
-    }
-
-
-    /**
-     * adds a child to this element
-     * 
-     * @param child the child to be added
-     */
-    void addChild(HtmlPageElement child) {
-        if (child != null) {
-            if (children == null) {
-                children = new ArrayList<HtmlPageElement>();
-            }
-            
-            children.add(child);
-        }
-    }
-
-    /**
-     * <p>
-     * returns the path to the parent of this page element or null, if this is the root element
-     * </p>
-     *
-     * @return as described
-     */
-    String getParentPath() {
-        return parentPath;
     }
 
@@ -190,8 +145,8 @@
      * @return as described
      */
-    String getPath() {
+    String getDOMPath() {
         StringBuffer result = new StringBuffer();
-        if (parentPath != null) {
-            result.append(parentPath);
+        if (parent != null) {
+            result.append(parent.getDOMPath());
         }
 
@@ -199,7 +154,7 @@
         result.append(tagName);
         
-        if ((id != null) && (!"".equals(id))) {
-            result.append("(id=");
-            result.append(id);
+        if ((htmlId != null) && (!"".equals(htmlId))) {
+            result.append("(htmlId=");
+            result.append(htmlId);
             result.append(")");
         }
@@ -213,3 +168,42 @@
     }
 
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.htmlmonitor.HtmlGUIElement#equals(de.ugoe.cs.autoquest.htmlmonitor.HtmlGUIElement)
+     */
+    @Override
+    public boolean equals(HtmlGUIElement obj) {
+        if (this == obj) {
+            return true;
+        }
+        else if (obj instanceof HtmlPageElement) {
+            return equals((HtmlPageElement) obj);
+        }
+        else {
+            return false;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.htmlmonitor.HtmlGUIElement#equals(de.ugoe.cs.autoquest.htmlmonitor.HtmlGUIElement)
+     */
+    public boolean equals(HtmlPageElement other) {
+        if (this == other) {
+            return true;
+        }
+
+        return (document.equals(other.document) && tagName.equals(other.tagName) &&
+                (parent != null ? parent.equals(other.parent) : other.parent == null) &&
+                (htmlId != null ? htmlId.equals(other.htmlId) : other.htmlId == null) &&
+                (index != null ? index.equals(other.index) : other.index == null));
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        return document.hashCode() + tagName.hashCode() + (parent != null ? parent.hashCode() : 0) +
+            (htmlId != null ? htmlId.hashCode() : 0) + (index != null ? index : 0);
+    }
+
 }
