01: package com.mvnforum.jaxb.dao;
02:
03: import javax.xml.bind.JAXBContext;
04: import javax.xml.bind.JAXBException;
05: import javax.xml.bind.Marshaller;
06: import javax.xml.bind.Validator;
07:
08: import com.mvnforum.jaxb.db.ObjectFactory;
09:
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:
19: try {
20:
21: jaxbContext = JAXBContext
22: .newInstance("com.mvnforum.jaxb.db");
23: marshaller = jaxbContext.createMarshaller();
24: marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
25: new Boolean(true));
26: objectFactory = new ObjectFactory();
27: validator = jaxbContext.createValidator();
28:
29: } catch (JAXBException e) {
30:
31: e.printStackTrace();
32:
33: }
34: }
35:
36: public static JAXBContext getJaxbContext() {
37: return jaxbContext;
38: }
39:
40: public static Marshaller getMarshaller() {
41: return marshaller;
42: }
43:
44: public static ObjectFactory getObjectFactory() {
45: return objectFactory;
46: }
47:
48: public static Validator getValidator() {
49: return validator;
50: }
51:
52: }
|