This project has retired. For details please refer to its
Attic page.
InMemoryJaxbHelper xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.inmemory.types;
20
21 import java.io.OutputStream;
22
23 import javax.xml.bind.JAXBContext;
24 import javax.xml.bind.JAXBElement;
25 import javax.xml.bind.JAXBException;
26 import javax.xml.bind.Marshaller;
27 import javax.xml.bind.Unmarshaller;
28 import javax.xml.bind.annotation.XmlElementDecl;
29 import javax.xml.bind.annotation.XmlRegistry;
30 import javax.xml.namespace.QName;
31 import javax.xml.stream.XMLStreamWriter;
32
33 import org.apache.chemistry.opencmis.commons.impl.Constants;
34 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
35 import org.apache.chemistry.opencmis.commons.impl.jaxb.ObjectFactory;
36
37 public class InMemoryJaxbHelper {
38 private static final QName CMIS_TYPE_DEFINITIONS = new QName("http://chemistry.apache.org/schemas/TypeDefnitions", "typeDefinitions");
39 private static final QName CMIS_TYPE_DEFINITION = new QName(Constants.NAMESPACE_RESTATOM, "type");
40
41 public static final ObjectFactory CMIS_OBJECT_FACTORY = new ObjectFactory();
42 public static final CMISExtraObjectFactory CMIS_EXTRA_OBJECT_FACTORY = new CMISExtraObjectFactory();
43 public static final JAXBContext CONTEXT;
44 static {
45 JAXBContext jc = null;
46 try {
47 jc = JAXBContext.newInstance(ObjectFactory.class, CMISExtraObjectFactory.class);
48 } catch (JAXBException e) {
49 e.printStackTrace();
50 }
51 CONTEXT = jc;
52 }
53
54 @XmlRegistry
55 public static class CMISExtraObjectFactory {
56 @XmlElementDecl(namespace="http://chemistry.apache.org/schemas/TypeDefnitions", name = "typeDefinitions")
57 public JAXBElement<TypeDefinitions> createObject(TypeDefinitions value) {
58 return new JAXBElement<TypeDefinitions>(CMIS_TYPE_DEFINITIONS, TypeDefinitions.class, value);
59 }
60
61 @XmlElementDecl(namespace = Constants.NAMESPACE_RESTATOM, name = "type")
62 public JAXBElement<CmisTypeDefinitionType> createTypeDefinition(CmisTypeDefinitionType value) {
63 return new JAXBElement<CmisTypeDefinitionType>(CMIS_TYPE_DEFINITION, CmisTypeDefinitionType.class, value);
64 }
65 }
66
67
68
69
70 private InMemoryJaxbHelper() {
71 }
72
73
74
75
76 public static Unmarshaller createUnmarshaller() throws JAXBException {
77 return CONTEXT.createUnmarshaller();
78 }
79
80
81
82
83 public static Marshaller createMarshaller() throws JAXBException {
84 return CONTEXT.createMarshaller();
85 }
86
87
88
89
90 public static <T> void marshal(JAXBElement<T> object, OutputStream out, boolean fragment) throws JAXBException {
91 if (object == null) {
92 return;
93 }
94
95 Marshaller m = CONTEXT.createMarshaller();
96 if (fragment) {
97 m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
98 }
99
100 m.marshal(object, out);
101 }
102
103
104
105
106 public static void marshal(Object object, XMLStreamWriter out, boolean fragment) throws JAXBException {
107 if (object == null) {
108 return;
109 }
110
111 Marshaller m = CONTEXT.createMarshaller();
112 if (fragment) {
113 m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
114 }
115
116 m.marshal(object, out);
117 }
118 }