Changeset 2751
- Timestamp:
- 08/14/09 15:32:28 (12 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/dev-dd/org.javarosa.graphing/src/org/javarosa/graphing/parser/StatisticsXMLParser.java
r2750 r2751 7 7 import java.io.InputStream; 8 8 import java.io.InputStreamReader; 9 import java.util.Hashtable;10 9 10 import org.javarosa.core.util.OrderedHashtable; 11 11 import org.javarosa.graphing.model.StatisticsModel; 12 12 import org.javarosa.graphing.model.StatisticsReport; 13 13 import org.kxml2.io.KXmlParser; 14 import org.kxml2.io.KXmlSerializer;15 14 import org.kxml2.kdom.Document; 16 15 import org.kxml2.kdom.Element; … … 23 22 */ 24 23 public class StatisticsXMLParser { 25 Hashtable handlers = new Hashtable();26 27 private interface ElementHandler {28 public void handle(Element e, StatisticsModel m) throws StatisticsXmlParseException;29 }30 24 31 25 public StatisticsXMLParser() { … … 101 95 102 96 String name = e.getAttributeValue(null,"name"); 103 String index = e.getAttributeValue(null,"ind ex");97 String index = e.getAttributeValue(null,"indices"); 104 98 if(name != null) { 105 99 modelName = name; … … 108 102 } 109 103 110 Hashtable fullData = new Hashtable(); 104 OrderedHashtable fullData = new OrderedHashtable(); 105 106 try { 107 e = e.getElement("","valuesets"); 108 } catch(Exception ex) { 109 ex.printStackTrace(); 110 throw new StatisticsXmlParseException("No Value Sets in Dataset"); 111 } 111 112 112 113 int childElements = e.getChildCount(); … … 117 118 Element child = e.getElement(i); 118 119 if(child.getName().equals("values")) { 119 String entryType = child.getAttributeValue(null, " value");120 String entryType = child.getAttributeValue(null, "name"); 120 121 if(primaryEntry == null) { 121 122 primaryEntry = entryType; 122 123 } 123 124 entityTitle = index; 124 Hashtable entries = parseEntries(child);125 OrderedHashtable entries = parseEntries(child); 125 126 fullData.put(entryType, entries); 126 127 } else { … … 134 135 } 135 136 136 private Hashtable parseEntries(Element entities) throws StatisticsXmlParseException {137 Hashtable entries = newHashtable();137 private OrderedHashtable parseEntries(Element entities) throws StatisticsXmlParseException { 138 OrderedHashtable entries = new OrderedHashtable(); 138 139 int childElements = entities.getChildCount(); 139 140 for(int i = 0; i < childElements; ++i) { … … 142 143 } else { 143 144 Element child = entities.getElement(i); 144 if(child.getName().equals(" entry")) {145 if(child.getName().equals("value")) { 145 146 try{ 146 147 String key = (String)child.getAttributeValue("","index"); … … 152 153 } 153 154 } else { 154 throw new StatisticsXmlParseException("All entry children must be elements");155 System.out.println("Non value element of valueset: " + child.getName()); 155 156 } 156 157 }
