1/*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.xml.internal.ws.message.jaxb;
27
28import com.sun.xml.internal.bind.api.Bridge;
29import com.sun.xml.internal.bind.api.JAXBRIContext;
30import com.sun.xml.internal.bind.api.TypeReference;
31import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
32import com.sun.xml.internal.bind.v2.runtime.MarshallerImpl;
33import org.w3c.dom.Node;
34import org.xml.sax.ContentHandler;
35
36import javax.xml.bind.JAXBException;
37import javax.xml.bind.Marshaller;
38import javax.xml.bind.Unmarshaller;
39import javax.xml.namespace.NamespaceContext;
40import javax.xml.stream.XMLStreamReader;
41import javax.xml.stream.XMLStreamWriter;
42import javax.xml.transform.Result;
43import javax.xml.transform.Source;
44import java.io.InputStream;
45import java.io.OutputStream;
46
47/**
48 * Used to adapt {@link Marshaller} into a {@link Bridge}.
49 * @deprecated
50 * @author Kohsuke Kawaguchi
51 */
52final class MarshallerBridge extends Bridge {
53    public MarshallerBridge(JAXBRIContext context) {
54        super((JAXBContextImpl)context);
55    }
56
57    public void marshal(Marshaller m, Object object, XMLStreamWriter output) throws JAXBException {
58        m.setProperty(Marshaller.JAXB_FRAGMENT,true);
59        try {
60            m.marshal(object,output);
61        } finally {
62            m.setProperty(Marshaller.JAXB_FRAGMENT,false);
63        }
64    }
65
66    public void marshal(Marshaller m, Object object, OutputStream output, NamespaceContext nsContext) throws JAXBException {
67        m.setProperty(Marshaller.JAXB_FRAGMENT,true);
68        try {
69            ((MarshallerImpl)m).marshal(object,output,nsContext);
70        } finally {
71            m.setProperty(Marshaller.JAXB_FRAGMENT,false);
72        }
73    }
74
75    public void marshal(Marshaller m, Object object, Node output) throws JAXBException {
76        m.setProperty(Marshaller.JAXB_FRAGMENT,true);
77        try {
78            m.marshal(object,output);
79        } finally {
80            m.setProperty(Marshaller.JAXB_FRAGMENT,false);
81        }
82    }
83
84    public void marshal(Marshaller m, Object object, ContentHandler contentHandler) throws JAXBException {
85        m.setProperty(Marshaller.JAXB_FRAGMENT,true);
86        try {
87            m.marshal(object,contentHandler);
88        } finally {
89            m.setProperty(Marshaller.JAXB_FRAGMENT,false);
90        }
91    }
92
93    public void marshal(Marshaller m, Object object, Result result) throws JAXBException {
94        m.setProperty(Marshaller.JAXB_FRAGMENT,true);
95        try {
96            m.marshal(object,result);
97        } finally {
98            m.setProperty(Marshaller.JAXB_FRAGMENT,false);
99        }
100    }
101
102    public Object unmarshal(Unmarshaller u, XMLStreamReader in) {
103        throw new UnsupportedOperationException();
104    }
105
106    public Object unmarshal(Unmarshaller u, Source in) {
107        throw new UnsupportedOperationException();
108    }
109
110    public Object unmarshal(Unmarshaller u, InputStream in) {
111        throw new UnsupportedOperationException();
112    }
113
114    public Object unmarshal(Unmarshaller u, Node n) {
115        throw new UnsupportedOperationException();
116    }
117
118    public TypeReference getTypeReference() {
119        throw new UnsupportedOperationException();
120    }
121}
122