]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.xmlio/src/org/simantics/interop/xmlio/LoadXML.java
Fix plug-in dependencies + use fastutils hashmaps.
[simantics/interop.git] / org.simantics.interop.xmlio / src / org / simantics / interop / xmlio / LoadXML.java
index c79ace686e8e39bb5ee2a639e52e16f451d6478a..a2cae0c49428d5b241efebf267692a5123c493ef 100644 (file)
-package org.simantics.interop.xmlio;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.File;\r
-import java.io.FileReader;\r
-import java.io.Reader;\r
-import java.io.Serializable;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Stack;\r
-\r
-import javax.xml.parsers.SAXParser;\r
-import javax.xml.parsers.SAXParserFactory;\r
-\r
-import org.cojen.util.IntHashMap;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.DelayedWriteRequest;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.Layer0Utils;\r
-import org.simantics.db.layer0.util.SessionGarbageCollection;\r
-import org.simantics.layer0.Layer0;\r
-import org.xml.sax.Attributes;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.XMLReader;\r
-import org.xml.sax.helpers.DefaultHandler;\r
-\r
-\r
-\r
-public class LoadXML {\r
-\r
-       private Session session;\r
-       private Resource resultRoot;\r
-       \r
-       private File file;\r
-       \r
-       \r
-       //private Map<Integer,Resource> idMap = new HashMap<Integer, Resource>();\r
-       private IntHashMap<Resource> idMap = new IntHashMap<Resource>();\r
-       \r
-       //private Map<String,Resource> uriMap = new HashMap<String, Resource>();\r
-       \r
-       private WriteGraph graph;\r
-       private Layer0 l0;\r
-       private LoadRule rule;\r
-       \r
-       private int resources;\r
-       private int statements;\r
-       \r
-       private static final boolean USE_DELAYED = true;\r
-       \r
-       public LoadXML(Session session, File file) {\r
-               this.session = session;\r
-               this.file = file;\r
-               this.rule = new DefaultLoadRule();\r
-       }\r
-       \r
-       public void setRule(LoadRule rule) {\r
-               this.rule = rule;\r
-       }\r
-       \r
-       public void load(Resource subj, Resource pred) throws Exception {\r
-               resources = 0;\r
-               statements = 0;\r
-               \r
-               if (USE_DELAYED) {\r
-                       session.syncRequest(new ImportDelayedRequest(subj,pred));       \r
-               } else {\r
-                       session.syncRequest(new ImportRequest(subj,pred));      \r
-               }\r
-               //session.syncRequest(new DelayedWriteRequest() {\r
-               \r
-               \r
-               System.out.println("Import done.");\r
-       }\r
-       \r
-       private class ImportRequest extends WriteRequest {\r
-               Resource subj;Resource pred;\r
-               \r
-               \r
-               public ImportRequest(Resource subj, Resource pred) {\r
-                       super();\r
-                       this.subj = subj;\r
-                       this.pred = pred;\r
-               }\r
-\r
-               @Override\r
-               public void perform(WriteGraph graph) throws DatabaseException {\r
-                       doImport(graph, subj, pred);\r
-               }\r
-       }\r
-       \r
-       private class ImportDelayedRequest extends DelayedWriteRequest {\r
-               Resource subj;Resource pred;\r
-               \r
-               \r
-               public ImportDelayedRequest(Resource subj, Resource pred) {\r
-                       super();\r
-                       this.subj = subj;\r
-                       this.pred = pred;\r
-               }\r
-\r
-               @Override\r
-               public void perform(WriteGraph graph) throws DatabaseException {\r
-                       doImport(graph, subj, pred);\r
-               }\r
-       }\r
-       \r
-       private void doImport(WriteGraph graph, Resource subj, Resource pred) throws DatabaseException {\r
-               LoadXML.this.graph = graph;\r
-               l0 = Layer0.getInstance(graph);\r
-               Layer0Utils.setDependenciesIndexingDisabled(graph, true);\r
-               try {\r
-                       XMLParser parser = new XMLParser();\r
-                       parser.parse(file.getAbsolutePath());\r
-                       System.out.println("Imported " + statements + " Statements, " + resources + " Resources.");\r
-               } catch (Exception e) {\r
-                       throw new DatabaseException(e);\r
-               } finally {\r
-                       resultRoot = idMap.get(0);\r
-                       graph.claim(subj, pred, resultRoot);\r
-                       idMap.clear();\r
-               }\r
-       }\r
-       \r
-       \r
-//     public Resource getResult() {\r
-//             return resultRoot;\r
-//     }\r
-       \r
-       protected Resource getResource(ReadGraph graph, String uri) throws DatabaseException {\r
-               return rule.getResource(graph, uri);\r
-       }\r
-       \r
-       protected Object createValue(ReadGraph graph, List<String> value, List<String> types) throws DatabaseException {\r
-               return rule.createValue(graph, value, types);\r
-       }\r
-       \r
-       protected void initializeWithBundles(ReadGraph graph, List<Bundle> bundles) throws DatabaseException {\r
-               rule.initializeWithBundles(graph, bundles);\r
-       }\r
-       \r
-       \r
-       public class XMLParser  extends DefaultHandler implements Serializable {\r
-\r
-               private static final long serialVersionUID = -4995836637014958966L;\r
-               \r
-               private Stack<Element> current = new Stack<Element>();\r
-               \r
-               private void loadElement(Element element) throws SAXException{\r
-                       String name = element.qName;\r
-                       if ("graphexport".equals(name))\r
-                               return;\r
-                       if ("graphbundles".equals(name)) {\r
-                               element.setData(new ArrayList<Bundle>());\r
-                               return;\r
-                       }\r
-                       if ("bundle".equals(name))\r
-                               return;\r
-                       if ("resource".equals(name)) {\r
-                               element.setData(new Res());\r
-                               return;\r
-                       }\r
-                       if ("type".equals(name)) {\r
-                               return;\r
-                       }\r
-                       if ("statement".equals(name))\r
-                               return;\r
-                       \r
-               }\r
-               \r
-               private void handleElement(Stack<Element> parents, Element element) throws SAXException{\r
-                       try {\r
-                       String elementName = element.qName;\r
-                       if ("graphexport".equals(elementName))\r
-                               return;\r
-                       if ("graphbundles".equals(elementName)) {\r
-                               List<Bundle> list = (List<Bundle>)element.getData();\r
-                               initializeWithBundles(graph, list);\r
-                               element.setData(null);\r
-                               return;\r
-                       }\r
-                       if ("bundle".equals(elementName)) {\r
-                               List<Bundle> list = (List<Bundle>)parents.peek().getData();\r
-                               String name = null;\r
-                               String versionId = null;\r
-                               for (Attribute a : element.getAttributes()) {\r
-                                       if ("name".equals(a.qName))\r
-                                               name = a.value;\r
-                                       if ("versionid".equals(a.qName))\r
-                                               versionId = a.value;\r
-                               } \r
-                               list.add(new Bundle(name,versionId));\r
-                               return;\r
-                       }\r
-                       if ("resource".equals(elementName)) {\r
-                               Res res = (Res)element.getData();\r
-                               boolean rel = false;\r
-                               String uri = null;\r
-                               int id = -1;\r
-                               Resource r = null;\r
-                               for (Attribute a : element.getAttributes()) {\r
-                                       if ("id".equals(a.qName))\r
-                                               id = Integer.parseInt(a.value);\r
-                                       if ("rel".equals(a.qName))\r
-                                               rel = "true".equals(a.value);\r
-                                       if ("uri".equals(a.qName))\r
-                                               uri = a.value;\r
-                               } \r
-                               if (rel) {\r
-                                       r = getResource(graph, uri);\r
-                               } else {\r
-                                       \r
-                                       r = graph.newResource();\r
-                                       for (String typeUri : res.types) {\r
-                                               Resource type =getResource(graph, typeUri);\r
-                                               graph.claim(r, l0.InstanceOf, type);\r
-                                       }\r
-                                       \r
-                                       if (res.values.size() > 0 ) {\r
-                                               Object valObj = createValue(graph, res.values, res.types);\r
-                                               graph.claimValue(r, valObj);\r
-                                       }\r
-                               }\r
-                               if (id == -1)\r
-                                       throw new SAXException("Resource id missing");\r
-                               idMap.put(id, r);\r
-                               \r
-                               res.types.clear();\r
-                               res.values.clear();\r
-                               element.setData(null);\r
-                               resources++;\r
-                               return;\r
-                       }\r
-                       if ("type".equals(elementName)) {\r
-                               Element parent = parents.peek();\r
-                               Res res = (Res)parent.getData();\r
-                               String uri = null;\r
-                               for (Attribute a : element.getAttributes()) {\r
-                                       if ("uri".equals(a.qName))\r
-                                               uri = a.value;\r
-                               } \r
-                               if (uri != null)\r
-                                       res.types.add(uri);\r
-                               \r
-                               return;\r
-                       }\r
-                       if ("value".equals(elementName)) {\r
-                               Element parent = parents.peek();\r
-                               Res res = (Res)parent.getData();\r
-                               String value = null;\r
-                               for (Attribute a : element.getAttributes()) {\r
-                                       if ("value".equals(a.qName))\r
-                                               value = a.value;\r
-                               } \r
-                               if (value != null)\r
-                                       res.values.add(value);\r
-                               \r
-                               return;\r
-                       }\r
-                       if ("statement".equals(elementName)) {\r
-                               int subjId = -1;\r
-                               int predId = -1;\r
-                               int objId = -1;\r
-                               for (Attribute a : element.getAttributes()) {\r
-                                       if ("subject".equals(a.qName))\r
-                                               subjId = Integer.parseInt(a.value);\r
-                                       if ("predicate".equals(a.qName))\r
-                                               predId = Integer.parseInt(a.value);\r
-                                       if ("object".equals(a.qName))\r
-                                               objId = Integer.parseInt(a.value);\r
-                               } \r
-                               \r
-                               graph.claim(idMap.get(subjId), idMap.get(predId), idMap.get(objId));\r
-                               statements++;\r
-                               if (statements % 10000 == 0) {\r
-                                       System.out.println("Imported " + statements + " Statements, " + resources + " Resources..");\r
-                                       //SessionGarbageCollection.gc(graph, 0, -1);\r
-                               }\r
-                               if (!USE_DELAYED && statements % 100000 == 0) {\r
-                                       SessionGarbageCollection.gc(graph, 0, -1);\r
-                                       System.gc();\r
-                               }\r
-                               \r
-                               return;\r
-                       }\r
-                       \r
-                       } catch (DatabaseException e) {\r
-                               throw new SAXException(e);\r
-                       }\r
-               }\r
-               \r
-               public void done() {\r
-                       \r
-               }\r
-               \r
-               public void parse(String filename) throws Exception {\r
-                       SAXParserFactory spf = SAXParserFactory.newInstance();\r
-                       SAXParser saxParser = spf.newSAXParser();\r
-                       \r
-                       XMLReader reader = saxParser.getXMLReader();\r
-                       Reader file = new BufferedReader(new FileReader(filename));\r
-                       reader.setContentHandler(this);\r
-                       reader.parse(new InputSource(file));\r
-                       done();\r
-               }\r
-               \r
-               @Override\r
-               public void startElement(String uri, String localName, String name,\r
-                               Attributes attributes) throws SAXException {\r
-                       Element e = new Element(uri,localName,name,attributes);\r
-                       current.push(e);\r
-                       //texts.push(new String());\r
-                       loadElement(e);\r
-               }\r
-               \r
-               @Override\r
-               public void endElement(String uri, String localName, String name)\r
-                               throws SAXException {\r
-                       Element e = null;\r
-                       if (!current.empty()) {\r
-                               e = current.pop();\r
-                       }\r
-                       if (e != null) {\r
-                               handleElement(current,e);\r
-                       }\r
-               }\r
-               \r
-       }\r
-       \r
-       public class Attribute {\r
-               public String localName;\r
-               public String qName;\r
-               public String uri;\r
-               public String value;\r
-               \r
-               public Attribute(String localName, String qName, String uri, String value) {\r
-                       this.localName = localName;\r
-                       this.qName = qName;\r
-                       this.uri = uri;\r
-                       this.value = value;\r
-               }\r
-       }\r
-       \r
-       public class Element implements Serializable {\r
-               private static final long serialVersionUID = -5207502156942818875L;\r
-               String uri;\r
-               String localName;\r
-               String qName;\r
-               List<Attribute> attributes = new ArrayList<Attribute>();\r
-               \r
-               public Element(String uri, String localName, String qName, Attributes attributes) {\r
-                       this.uri = uri;\r
-                       this.localName = localName;\r
-                       this.qName = qName;\r
-                       for (int i = 0; i < attributes.getLength(); i++) {\r
-                               this.attributes.add(new Attribute(attributes.getLocalName(i),attributes.getQName(i),attributes.getURI(i),attributes.getValue(i)));\r
-                       }\r
-               }\r
-\r
-               public String getUri() {\r
-                       return uri;\r
-               }\r
-\r
-               public String getLocalName() {\r
-                       return localName;\r
-               }\r
-\r
-               public String getQName() {\r
-                       return qName;\r
-               }\r
-\r
-               public List<Attribute> getAttributes() {\r
-                       return attributes;\r
-               }\r
-\r
-               private Object data;\r
-               \r
-               public void setData(Object data) {\r
-                       this.data = data;\r
-               }\r
-               \r
-               public Object getData() {\r
-                       return data;\r
-               }\r
-\r
-       }\r
-       class Res {\r
-               \r
-               List<String> types = new ArrayList<String>();\r
-               List<String> values = new ArrayList<String>();\r
-       }\r
-       \r
-       public static class Bundle {\r
-               String name;\r
-               String versionId;\r
-               public Bundle(String name, String versionId) {\r
-                       super();\r
-                       this.name = name;\r
-                       this.versionId = versionId;\r
-               }\r
-               \r
-               public String getName() {\r
-                       return name;\r
-               }\r
-               \r
-               public String getVersionId() {\r
-                       return versionId;\r
-               }\r
-       }\r
-       \r
-       \r
-}\r
+package org.simantics.interop.xmlio;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.DelayedWriteRequest;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
+import org.simantics.db.layer0.util.SessionGarbageCollection;
+import org.simantics.layer0.Layer0;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+
+
+
+public class LoadXML {
+
+       private Session session;
+       private Resource resultRoot;
+       
+       private File file;
+       
+       
+       //private Map<Integer,Resource> idMap = new HashMap<Integer, Resource>();
+       Int2ObjectOpenHashMap<Resource> idMap = new Int2ObjectOpenHashMap<Resource>();
+       
+       //private Map<String,Resource> uriMap = new HashMap<String, Resource>();
+       
+       private WriteGraph graph;
+       private Layer0 l0;
+       private LoadRule rule;
+       
+       private int resources;
+       private int statements;
+       
+       private static final boolean USE_DELAYED = true;
+       
+       public LoadXML(Session session, File file) {
+               this.session = session;
+               this.file = file;
+               this.rule = new DefaultLoadRule();
+       }
+       
+       public void setRule(LoadRule rule) {
+               this.rule = rule;
+       }
+       
+       public void load(Resource subj, Resource pred) throws Exception {
+               resources = 0;
+               statements = 0;
+               
+               if (USE_DELAYED) {
+                       session.syncRequest(new ImportDelayedRequest(subj,pred));       
+               } else {
+                       session.syncRequest(new ImportRequest(subj,pred));      
+               }
+               //session.syncRequest(new DelayedWriteRequest() {
+               
+               
+               System.out.println("Import done.");
+       }
+       
+       private class ImportRequest extends WriteRequest {
+               Resource subj;Resource pred;
+               
+               
+               public ImportRequest(Resource subj, Resource pred) {
+                       super();
+                       this.subj = subj;
+                       this.pred = pred;
+               }
+
+               @Override
+               public void perform(WriteGraph graph) throws DatabaseException {
+                       doImport(graph, subj, pred);
+               }
+       }
+       
+       private class ImportDelayedRequest extends DelayedWriteRequest {
+               Resource subj;Resource pred;
+               
+               
+               public ImportDelayedRequest(Resource subj, Resource pred) {
+                       super();
+                       this.subj = subj;
+                       this.pred = pred;
+               }
+
+               @Override
+               public void perform(WriteGraph graph) throws DatabaseException {
+                       doImport(graph, subj, pred);
+               }
+       }
+       
+       private void doImport(WriteGraph graph, Resource subj, Resource pred) throws DatabaseException {
+               LoadXML.this.graph = graph;
+               l0 = Layer0.getInstance(graph);
+               Layer0Utils.setDependenciesIndexingDisabled(graph, true);
+               try {
+                       XMLParser parser = new XMLParser();
+                       parser.parse(file.getAbsolutePath());
+                       System.out.println("Imported " + statements + " Statements, " + resources + " Resources.");
+               } catch (Exception e) {
+                       throw new DatabaseException(e);
+               } finally {
+                       resultRoot = idMap.get(0);
+                       graph.claim(subj, pred, resultRoot);
+                       idMap.clear();
+               }
+       }
+       
+       
+//     public Resource getResult() {
+//             return resultRoot;
+//     }
+       
+       protected Resource getResource(ReadGraph graph, String uri) throws DatabaseException {
+               return rule.getResource(graph, uri);
+       }
+       
+       protected Object createValue(ReadGraph graph, List<String> value, List<String> types) throws DatabaseException {
+               return rule.createValue(graph, value, types);
+       }
+       
+       protected void initializeWithBundles(ReadGraph graph, List<Bundle> bundles) throws DatabaseException {
+               rule.initializeWithBundles(graph, bundles);
+       }
+       
+       
+       public class XMLParser  extends DefaultHandler implements Serializable {
+
+               private static final long serialVersionUID = -4995836637014958966L;
+               
+               private Stack<Element> current = new Stack<Element>();
+               
+               private void loadElement(Element element) throws SAXException{
+                       String name = element.qName;
+                       if ("graphexport".equals(name))
+                               return;
+                       if ("graphbundles".equals(name)) {
+                               element.setData(new ArrayList<Bundle>());
+                               return;
+                       }
+                       if ("bundle".equals(name))
+                               return;
+                       if ("resource".equals(name)) {
+                               element.setData(new Res());
+                               return;
+                       }
+                       if ("type".equals(name)) {
+                               return;
+                       }
+                       if ("statement".equals(name))
+                               return;
+                       
+               }
+               
+               private void handleElement(Stack<Element> parents, Element element) throws SAXException{
+                       try {
+                       String elementName = element.qName;
+                       if ("graphexport".equals(elementName))
+                               return;
+                       if ("graphbundles".equals(elementName)) {
+                               List<Bundle> list = (List<Bundle>)element.getData();
+                               initializeWithBundles(graph, list);
+                               element.setData(null);
+                               return;
+                       }
+                       if ("bundle".equals(elementName)) {
+                               List<Bundle> list = (List<Bundle>)parents.peek().getData();
+                               String name = null;
+                               String versionId = null;
+                               for (Attribute a : element.getAttributes()) {
+                                       if ("name".equals(a.qName))
+                                               name = a.value;
+                                       if ("versionid".equals(a.qName))
+                                               versionId = a.value;
+                               } 
+                               list.add(new Bundle(name,versionId));
+                               return;
+                       }
+                       if ("resource".equals(elementName)) {
+                               Res res = (Res)element.getData();
+                               boolean rel = false;
+                               String uri = null;
+                               int id = -1;
+                               Resource r = null;
+                               for (Attribute a : element.getAttributes()) {
+                                       if ("id".equals(a.qName))
+                                               id = Integer.parseInt(a.value);
+                                       if ("rel".equals(a.qName))
+                                               rel = "true".equals(a.value);
+                                       if ("uri".equals(a.qName))
+                                               uri = a.value;
+                               } 
+                               if (rel) {
+                                       r = getResource(graph, uri);
+                               } else {
+                                       
+                                       r = graph.newResource();
+                                       for (String typeUri : res.types) {
+                                               Resource type =getResource(graph, typeUri);
+                                               graph.claim(r, l0.InstanceOf, type);
+                                       }
+                                       
+                                       if (res.values.size() > 0 ) {
+                                               Object valObj = createValue(graph, res.values, res.types);
+                                               graph.claimValue(r, valObj);
+                                       }
+                               }
+                               if (id == -1)
+                                       throw new SAXException("Resource id missing");
+                               idMap.put(id, r);
+                               
+                               res.types.clear();
+                               res.values.clear();
+                               element.setData(null);
+                               resources++;
+                               return;
+                       }
+                       if ("type".equals(elementName)) {
+                               Element parent = parents.peek();
+                               Res res = (Res)parent.getData();
+                               String uri = null;
+                               for (Attribute a : element.getAttributes()) {
+                                       if ("uri".equals(a.qName))
+                                               uri = a.value;
+                               } 
+                               if (uri != null)
+                                       res.types.add(uri);
+                               
+                               return;
+                       }
+                       if ("value".equals(elementName)) {
+                               Element parent = parents.peek();
+                               Res res = (Res)parent.getData();
+                               String value = null;
+                               for (Attribute a : element.getAttributes()) {
+                                       if ("value".equals(a.qName))
+                                               value = a.value;
+                               } 
+                               if (value != null)
+                                       res.values.add(value);
+                               
+                               return;
+                       }
+                       if ("statement".equals(elementName)) {
+                               int subjId = -1;
+                               int predId = -1;
+                               int objId = -1;
+                               for (Attribute a : element.getAttributes()) {
+                                       if ("subject".equals(a.qName))
+                                               subjId = Integer.parseInt(a.value);
+                                       if ("predicate".equals(a.qName))
+                                               predId = Integer.parseInt(a.value);
+                                       if ("object".equals(a.qName))
+                                               objId = Integer.parseInt(a.value);
+                               } 
+                               
+                               graph.claim(idMap.get(subjId), idMap.get(predId), idMap.get(objId));
+                               statements++;
+                               if (statements % 10000 == 0) {
+                                       System.out.println("Imported " + statements + " Statements, " + resources + " Resources..");
+                                       //SessionGarbageCollection.gc(graph, 0, -1);
+                               }
+                               if (!USE_DELAYED && statements % 100000 == 0) {
+                                       SessionGarbageCollection.gc(graph, 0, -1);
+                                       System.gc();
+                               }
+                               
+                               return;
+                       }
+                       
+                       } catch (DatabaseException e) {
+                               throw new SAXException(e);
+                       }
+               }
+               
+               public void done() {
+                       
+               }
+               
+               public void parse(String filename) throws Exception {
+                       SAXParserFactory spf = SAXParserFactory.newInstance();
+                       SAXParser saxParser = spf.newSAXParser();
+                       
+                       XMLReader reader = saxParser.getXMLReader();
+                       Reader file = new BufferedReader(new FileReader(filename));
+                       reader.setContentHandler(this);
+                       reader.parse(new InputSource(file));
+                       done();
+               }
+               
+               @Override
+               public void startElement(String uri, String localName, String name,
+                               Attributes attributes) throws SAXException {
+                       Element e = new Element(uri,localName,name,attributes);
+                       current.push(e);
+                       //texts.push(new String());
+                       loadElement(e);
+               }
+               
+               @Override
+               public void endElement(String uri, String localName, String name)
+                               throws SAXException {
+                       Element e = null;
+                       if (!current.empty()) {
+                               e = current.pop();
+                       }
+                       if (e != null) {
+                               handleElement(current,e);
+                       }
+               }
+               
+       }
+       
+       public class Attribute {
+               public String localName;
+               public String qName;
+               public String uri;
+               public String value;
+               
+               public Attribute(String localName, String qName, String uri, String value) {
+                       this.localName = localName;
+                       this.qName = qName;
+                       this.uri = uri;
+                       this.value = value;
+               }
+       }
+       
+       public class Element implements Serializable {
+               private static final long serialVersionUID = -5207502156942818875L;
+               String uri;
+               String localName;
+               String qName;
+               List<Attribute> attributes = new ArrayList<Attribute>();
+               
+               public Element(String uri, String localName, String qName, Attributes attributes) {
+                       this.uri = uri;
+                       this.localName = localName;
+                       this.qName = qName;
+                       for (int i = 0; i < attributes.getLength(); i++) {
+                               this.attributes.add(new Attribute(attributes.getLocalName(i),attributes.getQName(i),attributes.getURI(i),attributes.getValue(i)));
+                       }
+               }
+
+               public String getUri() {
+                       return uri;
+               }
+
+               public String getLocalName() {
+                       return localName;
+               }
+
+               public String getQName() {
+                       return qName;
+               }
+
+               public List<Attribute> getAttributes() {
+                       return attributes;
+               }
+
+               private Object data;
+               
+               public void setData(Object data) {
+                       this.data = data;
+               }
+               
+               public Object getData() {
+                       return data;
+               }
+
+       }
+       class Res {
+               
+               List<String> types = new ArrayList<String>();
+               List<String> values = new ArrayList<String>();
+       }
+       
+       public static class Bundle {
+               String name;
+               String versionId;
+               public Bundle(String name, String versionId) {
+                       super();
+                       this.name = name;
+                       this.versionId = versionId;
+               }
+               
+               public String getName() {
+                       return name;
+               }
+               
+               public String getVersionId() {
+                       return versionId;
+               }
+       }
+       
+       
+}