KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > jaxb > dao > XMLUtil


1 package com.mvnforum.jaxb.dao;
2
3 import javax.xml.bind.JAXBContext;
4 import javax.xml.bind.JAXBException;
5 import javax.xml.bind.Marshaller;
6 import javax.xml.bind.Validator;
7
8 import com.mvnforum.jaxb.db.ObjectFactory;
9
10 public class XMLUtil {
11     
12     public static JAXBContext jaxbContext = null;
13     public static ObjectFactory objectFactory = null;
14     public static Marshaller marshaller = null;
15     public static Validator validator = null;
16     
17     static {
18         try {
19             jaxbContext = JAXBContext.newInstance("com.mvnforum.jaxb.db");
20             marshaller = jaxbContext.createMarshaller();
21             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT ,
22                    new Boolean JavaDoc(true));
23             objectFactory = new ObjectFactory();
24             validator = jaxbContext.createValidator();
25         } catch (JAXBException e) {
26             // TODO Auto-generated catch block
27
e.printStackTrace();
28         }
29         
30         
31     }
32
33     public static JAXBContext getJaxbContext() {
34         return jaxbContext;
35     }
36
37     public static Marshaller getMarshaller() {
38         return marshaller;
39     }
40
41     public static ObjectFactory getObjectFactory() {
42         return objectFactory;
43     }
44
45     public static Validator getValidator() {
46         return validator;
47     }
48     
49     
50    
51 }
52
Popular Tags