1
|
/**
|
2
|
* Copyright (C) 2011 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.dataportal.elements;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.openqa.selenium.WebElement;
|
15
|
|
16
|
public class MultipartDescriptionElementRepresentation extends DescriptionElementRepresentation{
|
17
|
|
18
|
ArrayList<DescriptionElementRepresentation> multipartElements = null;
|
19
|
|
20
|
public ArrayList<DescriptionElementRepresentation> getMultipartElements() {
|
21
|
return multipartElements;
|
22
|
}
|
23
|
|
24
|
public MultipartDescriptionElementRepresentation(WebElement ... element) {
|
25
|
super(element[0]);
|
26
|
|
27
|
multipartElements = new ArrayList<DescriptionElementRepresentation>(element.length -1);
|
28
|
for(int i = 0; i < element.length; i++){
|
29
|
multipartElements.add(new DescriptionElementRepresentation(element[i]));
|
30
|
}
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public WebElement getElement() {
|
35
|
String methodName = "getElement()";
|
36
|
throw new RuntimeException(methodName +" is NOT applicable to MultipartDescriptionElementRepresentation, use getElements().get(n)." + methodName + " instead");
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public String getText() {
|
41
|
StringBuilder combinedText = new StringBuilder();
|
42
|
for (DescriptionElementRepresentation element : multipartElements) {
|
43
|
combinedText.append(element.getText());
|
44
|
}
|
45
|
return combinedText.toString();
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public List<String> getClassAttributes() {
|
50
|
String methodName = "getClassAttributes()";
|
51
|
throw new RuntimeException(methodName +" is NOT applicable to MultipartDescriptionElementRepresentation, use getElements().get(n)." + methodName + " instead");
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public double getComputedFontSize() {
|
56
|
String methodName = "getComputedFontSize()";
|
57
|
throw new RuntimeException(methodName +" is NOT applicable to MultipartDescriptionElementRepresentation, use getElements().get(n)." + methodName + " instead");
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public List<LinkElement> getLinksInElement() {
|
62
|
List<LinkElement> combinedLinkList = new ArrayList<LinkElement>();
|
63
|
for (DescriptionElementRepresentation element : multipartElements) {
|
64
|
combinedLinkList.addAll(element.getLinksInElement());
|
65
|
}
|
66
|
return combinedLinkList;
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
public String toString() {
|
71
|
StringBuilder toStringRepresentatin = new StringBuilder(this.getClass().getSimpleName());
|
72
|
for (DescriptionElementRepresentation element : multipartElements) {
|
73
|
toStringRepresentatin.append("<" + element.getElement().getTagName() + ">");
|
74
|
}
|
75
|
return toStringRepresentatin.toString();
|
76
|
}
|
77
|
|
78
|
@Override
|
79
|
public List getSources() {
|
80
|
List<BaseElement> combinedSourcesList = new ArrayList<BaseElement>();
|
81
|
for (DescriptionElementRepresentation element : multipartElements) {
|
82
|
combinedSourcesList.addAll(element.getSources());
|
83
|
}
|
84
|
return combinedSourcesList;
|
85
|
}
|
86
|
|
87
|
|
88
|
}
|