Package com.fengjing.framework.jaxb.model

Examples of com.fengjing.framework.jaxb.model.ClassRoom


public class JaxbMarshaller {
 
  @Test
  public void student2xml() throws JAXBException{
    JAXBContext context=JAXBContext.newInstance(Student.class);
    Student student=new Student("admin", 18, "��������", new ClassRoom("classroom", "�������"));
    Marshaller marshaller = context.createMarshaller();
    //�O�ò�ݔ��<?xml version="1.0" encoding="UTF-8" standalone="yes"?>��Ϣ
    //marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
    marshaller.marshal(student, System.out);
  }
View Full Code Here


  }
 
  @Test
  public void classroom2xml() throws JAXBException{
    JAXBContext context=JAXBContext.newInstance(Student.class);
    ClassRoom classRoom=new ClassRoom("classroom", "�������");
    Student student;
   
    List<Student> students=new ArrayList<Student>();
   
    for (int i = 1; i <= 10; i++) {
      student=new Student("admin", 18, "��������");
      students.add(student);
    }
    classRoom.setStudents(students);
   
    Marshaller marshaller = context.createMarshaller();
    marshaller.marshal(classRoom, System.out);
  }
View Full Code Here

  @Test
  public void xml2classroom() throws JAXBException{
    String str="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><classRoom classroomid=\"classroom\" classroomname=\"�������\"><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student><student><age>18</age><stuaddress>��������</stuaddress><stuname>admin</stuname></student></classRoom>";
    JAXBContext context=JAXBContext.newInstance(ClassRoom.class);
    Unmarshaller unmarshaller = context.createUnmarshaller();
    ClassRoom room = (ClassRoom) unmarshaller.unmarshal(new StringReader(str));
    System.out.println(room);
  }
View Full Code Here

TOP

Related Classes of com.fengjing.framework.jaxb.model.ClassRoom

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.