Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b4f85d3

Browse files
Removed support of Generics in Element
Reason: Having generics requires all elements to be of type T, where it is not always the case, since an element may be an integer, string or file.
1 parent 1e11785 commit b4f85d3

File tree

6 files changed

+451
-99
lines changed

6 files changed

+451
-99
lines changed

‎.idea/workspace.xml‎

Lines changed: 429 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-6.55 KB
Binary file not shown.
-1.14 KB
Binary file not shown.
724 Bytes
Binary file not shown.

‎src/net/ddns/cyberstudios/Element.java‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
//TODO
88
// add methods to check ID, hint, check question type, check type, etc
99

10-
public class Element<T> {
10+
public class Element {
1111

1212
private Map<String, String> attributes = new HashMap<>();
13-
private LinkedList<Element<T>> children = new LinkedList<>();
14-
private Element<T> parent;
13+
private LinkedList<Element> children = new LinkedList<>();
14+
private Element parent;
1515
private String tag = "",
1616
id = "",
1717
hint = "",
1818
type = "",
1919
link = "";
20-
private T value;
20+
private Object value;
2121

2222

2323
public Element() {
@@ -27,31 +27,31 @@ public Element(String tag) {
2727
this.tag = tag;
2828
}
2929

30-
public Element(String tag, Element<T> parent) {
30+
public Element(String tag, Element parent) {
3131
this.tag = tag;
3232
this.parent = parent;
3333
}
3434

35-
public Element(String tag, Element<T> parent, LinkedList<Element<T>> children) {
35+
public Element(String tag, Element parent, LinkedList<Element> children) {
3636
this.tag = tag;
3737
this.children = children;
3838
this.parent = parent;
3939
}
4040

41-
public Element(String tag, Element<T> parent, LinkedList<Element<T>> children, Map<String, String> attributes) {
41+
public Element(String tag, Element parent, LinkedList<Element> children, Map<String, String> attributes) {
4242
this.tag = tag;
4343
this.attributes = attributes;
4444
this.children = children;
4545
this.parent = parent;
4646
}
4747

48-
public Element(String tag, Element<T> parent, Map<String, String> attributes) {
48+
public Element(String tag, Element parent, Map<String, String> attributes) {
4949
this.tag = tag;
5050
this.attributes = attributes;
5151
this.parent = parent;
5252
}
5353

54-
public void setValue(T value) {
54+
public void setValue(Object value) {
5555
this.value = value;
5656
}
5757

@@ -83,7 +83,7 @@ public String getType() {
8383
* Gets text value (question, etc) stored by Element
8484
* @return
8585
*/
86-
public T getValue() {
86+
public Object getValue() {
8787
return value;
8888
}
8989

@@ -117,19 +117,19 @@ public boolean hasLink(){
117117
return !link.isEmpty();
118118
}
119119

120-
public void addChild(Element<T> child) {
120+
public void addChild(Element child) {
121121
this.children.add(child);
122122
}
123123

124-
public LinkedList<Element<T>> getChildren() {
124+
public LinkedList<Element> getChildren() {
125125
return children;
126126
}
127127

128-
public Element<T> getParent() {
128+
public Element getParent() {
129129
return parent;
130130
}
131131

132-
public void setParent(Element<T> parent) {
132+
public void setParent(Element parent) {
133133
this.parent = parent;
134134
}
135135

@@ -207,8 +207,8 @@ public String toString() {
207207
* @param parent required to keep tree structure, since making a deep copy of parent will result in a invalid reference to the actual parent of the element.
208208
* @return deep copied element
209209
*/
210-
public Element<T> clone(Element<T> parent){
211-
Element<T> e = new Element<>();
210+
public Element clone(Element parent){
211+
Element e = new Element();
212212
e.parent = parent;
213213
e.tag = tag;
214214
e.id = id;

‎src/net/ddns/cyberstudios/XMLTools.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public static Element parseDocument(Document xml_document) {
102102
* @param parent parent element used to create and set children
103103
* @return root element of DOM document as a parsed element
104104
*/
105-
public static Element<Object> parse(org.w3c.dom.Element root, Element<Object> parent) {
106-
Element<Object> element = new Element<>(root.getTagName(), parent);
105+
public static Element parse(org.w3c.dom.Element root, Element parent) {
106+
Element element = new Element(root.getTagName(), parent);
107107
for (int i = 0; i < root.getAttributes().getLength(); i++) {
108108
Attr item = (Attr) root.getAttributes().item(i);
109109
String attrKey = item.getNodeName();
@@ -116,7 +116,7 @@ public static Element<Object> parse(org.w3c.dom.Element root, Element<Object> pa
116116
if (item.getNodeType() == Node.ELEMENT_NODE) {
117117
org.w3c.dom.Element e = (org.w3c.dom.Element) item;
118118
String tag = e.getTagName();
119-
Element<Object> childNode = parse(e, element);
119+
Element childNode = parse(e, element);
120120
if (tag.equals("component")) {
121121
if (item.getFirstChild() != null && item.getFirstChild().getNodeType() == Node.TEXT_NODE) {
122122
childNode.setValue(item.getFirstChild().getNodeValue().replace("\n", "").replace("\"", "").trim());
@@ -135,12 +135,12 @@ public static Element<Object> parse(org.w3c.dom.Element root, Element<Object> pa
135135
* @param id ID of element to be found
136136
* @return element matching ID specified
137137
*/
138-
public static Element<Object> lookup(Element<Object> root, String id) {
138+
public static Element lookup(Element root, String id) {
139139
if (root.getId().equals(id))
140140
return root;
141141
else {
142-
for (Element<Object> element : root.getChildren()) {
143-
Element<Object> e = lookup(element, id);
142+
for (Element element : root.getChildren()) {
143+
Element e = lookup(element, id);
144144
if (e != null)
145145
return e;
146146
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /