source: src/main/java/genius/core/xml/OrderedSimpleElement.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.3 KB
Line 
1package genius.core.xml;
2
3import java.util.ArrayList;
4import java.util.List;
5
6/**
7 * Orders the attributes
8 */
9public class OrderedSimpleElement extends SimpleElement
10{
11 int index = 0;
12 List<String> attributeKeys;
13
14 public OrderedSimpleElement(String tagName)
15 {
16 super(tagName);
17 attributeKeys = new ArrayList<String>();
18 }
19
20 @Override
21 public void setAttribute(String name, String value)
22 {
23 attributes.put(name, value);
24 if (!attributeKeys.contains(name))
25 attributeKeys.add(name);
26 }
27
28 @Override
29 public String toString() {
30 String lResult="";
31 lResult +="<" + tagName;
32 //save all attributes
33 for(int i=0;i<attributeKeys.size();i++) {
34 String lAttrName = attributeKeys.get(i);
35 String lAttrValue="";
36 if (attributes.entrySet().toArray()[i]!=null)
37 lAttrValue= (attributes.get(lAttrName));
38
39 lResult +=" "+lAttrName+"=\"" +lAttrValue+"\"";
40 }
41 lResult +="> \n";
42 //save all children
43 for(int i=0;i<childElements.size();i++) {
44 SimpleElement lSE = (SimpleElement)getChildElements()[i];
45 lResult += lSE.toString();
46 }
47 if(text!=null) {
48 lResult += text+" \n";}
49 lResult +="</" + tagName+"> \n";
50
51 return lResult;
52 }
53
54}
Note: See TracBrowser for help on using the repository browser.