diff options
author | kelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-10 12:00:09 +0000 |
---|---|---|
committer | kelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-10 12:00:09 +0000 |
commit | ef083f8a304dd324482cb3b62219e22f1ede3f14 (patch) | |
tree | af48af97f4bdcb0186a304a273f3ffd0a7b99504 /sandbox/kgoodson/SourceExplore | |
parent | b38dbda5f4e6cd64410be8def5a601382a7cd572 (diff) |
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@921321 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/kgoodson/SourceExplore')
-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 |