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