diff options
-rw-r--r-- | sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java b/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java new file mode 100644 index 0000000000..cfd9488a28 --- /dev/null +++ b/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java @@ -0,0 +1,64 @@ +import java.io.File; +import java.util.Iterator; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.apache.tuscany.SourceExplore.ObjectFactory; +import org.apache.tuscany.SourceExplore.Projects; +import org.apache.tuscany.SourceExplore.Projects2; +import org.apache.tuscany.SourceExplore.Projects2.Project; + + + +public class HashSPISource { + + public static void main(String[] args) throws Throwable { + + ObjectFactory fac = new ObjectFactory(); + + JAXBContext jaxbContext = JAXBContext + .newInstance("org.apache.tuscany.SourceExplore"); + Unmarshaller m = jaxbContext.createUnmarshaller(); + + + + + File inputFile = new File("src/main/resources/projects.xml").getAbsoluteFile(); + Projects p = (Projects)m.unmarshal(inputFile); + List<JAXBElement<String>> data = p.getProjectOrPackage(); + System.out.println(p); + + + Projects2 p2 = fac.createProjects2(); + + + + for (int i = 0; i < data.size(); i++) { + if(!"project".equals(data.get(i).getName().getLocalPart())) { + throw new Exception("Expecting a project element " + i); + } else { + System.out.println("project: " + data.get(i).getValue()); + Project proj = fac.createProjects2Project(); + proj.setName(data.get(i).getValue()); + p2.getProject().add(proj); + } + for(i++;i<data.size() && "package".equals(data.get(i).getName().getLocalPart());i++) { + if(!"package".equals(data.get(i).getName().getLocalPart())) { + throw new Exception("Expecting a package element " + i); + } else { + System.out.println("package: " + data.get(i).getValue()); + } + } + i--; + } + + + + } + + +}
\ No newline at end of file |