package org.lindenb.sandbox; import java.io.FileInputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.lindenb.sandbox.tinyseq.TSeq; import org.lindenb.sandbox.tinyseq.TSeqSet; /** * Testing JAXB * @author Pierre Lindenbaum PhD * */ public class JAXBTinySeq { /** * parse each tinyseq sequence and echo to stdout * @param args */ public static void main(String[] args) { try { JAXBContext jc = JAXBContext.newInstance("org.lindenb.sandbox.tinyseq"); Unmarshaller u = jc.createUnmarshaller(); Marshaller m= jc.createMarshaller(); for(String f:args) { TSeqSet seqSet = (TSeqSet)u.unmarshal(new FileInputStream(f)); //echo each defline for(TSeq seq: seqSet.getTSeq()) { System.out.println("Found "+seq.getTSeqDefline()); } //marshall to stdout m.marshal(seqSet, System.out); } } catch (Exception e) { e.printStackTrace(); } } }