List of usage examples for javax.xml.bind JAXBContext newInstance
public static JAXBContext newInstance(String contextPath, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext context = JAXBContext.newInstance(Disk.class, MyStatus.class, MyDisk.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); Disk disk = new Disk(); disk.setStatus("attached"); disk.setSize(10000000000L);/*from w w w . j ava 2s. c o m*/ disk.setFreeSpace(25600000L); disk.setId("1"); m.marshal(disk, System.out); m.marshal(new MyStatus(disk), System.out); m.marshal(new MyDisk(disk), System.out); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Parent.class, IntegerChild.class, StringChild.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); IntegerChild integerChild = new IntegerChild(); integerChild.getItem().add(1);/*from w w w . j a v a 2 s . co m*/ integerChild.getItem().add(2); marshaller.marshal(integerChild, System.out); StringChild stringChild = new StringChild(); stringChild.getItem().add("A"); stringChild.getItem().add("B"); marshaller.marshal(stringChild, System.out); }
From source file:Main.java
public static void main(String[] args) throws JAXBException { JAXBContext jc = JAXBContext.newInstance(Home.class, Person.class, Animal.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); StreamSource xml = new StreamSource("input.xml"); Home home = unmarshaller.unmarshal(xml, Home.class).getValue(); for (Object object : home.any) { System.out.println(object.getClass()); }/*from w w w. ja v a2 s .c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { MyMessage sarm = new MyMessage(); MyGroupResponse[] sgr = new MyGroupResponse[2]; sgr[0] = new MyGroupResponse(); sgr[1] = new MyGroupResponse(); sarm.setSailingGroup(sgr);//from w w w. j av a2 s . co m JAXBElement<MyMessage> rootElement = new JAXBElement<MyMessage>(new QName("root"), MyMessage.class, sarm); JAXBContext jc = JAXBContext.newInstance(MyMessage.class, MyGroup.class, MyGroupResponse.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(rootElement, System.out); }
From source file:com.moss.bdbadmin.client.service.BdbClient.java
public static void init() { try {// w w w . ja va2 s . c o m context = JAXBContext.newInstance(Category.class, DbInfo.class, EntryInfo.class); } catch (JAXBException ex) { throw new RuntimeException(ex); } }