source: trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlPageElement.java @ 1019

Last change on this file since 1019 was 1019, checked in by pharms, 12 years ago
  • changed logfile format to XML
  • included logging of GUI structure
  • moved robot detection into monitor
File size: 3.3 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.htmlmonitor;
16
17import java.util.ArrayList;
18import java.util.List;
19
20/**
21 * <p>
22 * TODO comment
23 * </p>
24 *
25 * @author Patrick Harms
26 */
27class HtmlPageElement {
28
29    /**
30     *
31     */
32    private String parentPath;
33   
34    /**
35     *
36     */
37    private String tagName;
38   
39    /**
40     *
41     */
42    private String id;
43   
44    /**
45     *
46     */
47    private String title;
48   
49    /**
50     *
51     */
52    private Integer index;
53   
54    /**
55     *
56     */
57    private List<HtmlPageElement> children;
58
59    /**
60     * <p>
61     * TODO: comment
62     * </p>
63     *
64     * @param tagName
65     * @param index
66     * @param id
67     * @param children
68     */
69    HtmlPageElement(String parentPath, String tagName, String id, Integer index) {
70        this.parentPath = parentPath;
71        this.tagName = tagName;
72        this.id = id;
73        this.index = index;
74    }
75
76    /**
77     * <p>
78     * TODO: comment
79     * </p>
80     *
81     * @param tagName
82     * @param index
83     * @param id
84     * @param children
85     */
86    HtmlPageElement(String parentPath, String tagName, String id, String title, Integer index) {
87        this(parentPath, tagName, id, index);
88        this.title = title;
89    }
90
91    /**
92     * @return the tagName
93     */
94    String getTagName() {
95        return tagName;
96    }
97
98    /**
99     * @return the id
100     */
101    String getId() {
102        return id;
103    }
104
105    /**
106     * @return the title
107     */
108    String getTitle() {
109        return title;
110    }
111
112    /**
113     * @return the index
114     */
115    Integer getIndex() {
116        return index;
117    }
118
119    /**
120     * @return the children
121     */
122    List<HtmlPageElement> getChildren() {
123        return children;
124    }
125
126
127    /**
128     *
129     */
130    void addChild(HtmlPageElement child) {
131        if (child != null) {
132            if (children == null) {
133                children = new ArrayList<HtmlPageElement>();
134            }
135           
136            children.add(child);
137        }
138    }
139
140    /**
141     * <p>
142     * TODO: comment
143     * </p>
144     *
145     * @return
146     */
147    String getParentPath() {
148        return parentPath;
149    }
150
151    /**
152     * <p>
153     * TODO: comment
154     * </p>
155     *
156     * @return
157     */
158    String getPath() {
159        StringBuffer result = new StringBuffer();
160        if (parentPath != null) {
161            result.append(parentPath);
162        }
163
164        result.append("/");
165        result.append(tagName);
166       
167        if ((id != null) && (!"".equals(id))) {
168            result.append("(id=");
169            result.append(id);
170            result.append(")");
171        }
172        else {
173            result.append("[");
174            result.append(index);
175            result.append("]");
176        }
177       
178        return result.toString();
179    }
180
181}
Note: See TracBrowser for help on using the repository browser.