< prev index next >

jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeImpl.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2011, 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


  59  */
  60 final class BridgeImpl<T> extends InternalBridge<T> {
  61 
  62     /**
  63      * Tag name associated with this {@link Bridge}.
  64      * Used for marshalling.
  65      */
  66     private final Name tagName;
  67     private final JaxBeanInfo<T> bi;
  68     private final TypeReference typeRef;
  69 
  70     public BridgeImpl(JAXBContextImpl context, Name tagName, JaxBeanInfo<T> bi,TypeReference typeRef) {
  71         super(context);
  72         this.tagName = tagName;
  73         this.bi = bi;
  74         this.typeRef = typeRef;
  75     }
  76 
  77     public void marshal(Marshaller _m, T t, XMLStreamWriter output) throws JAXBException {
  78         MarshallerImpl m = (MarshallerImpl)_m;
  79         m.write(tagName,bi,t,XMLStreamWriterOutput.create(output,context),new StAXPostInitAction(output,m.serializer));
  80     }
  81 
  82     public void marshal(Marshaller _m, T t, OutputStream output, NamespaceContext nsContext) throws JAXBException {
  83         MarshallerImpl m = (MarshallerImpl)_m;
  84 
  85         Runnable pia = null;
  86         if(nsContext!=null)
  87             pia = new StAXPostInitAction(nsContext,m.serializer);
  88 
  89         m.write(tagName,bi,t,m.createWriter(output),pia);
  90     }
  91 
  92     public void marshal(Marshaller _m, T t, Node output) throws JAXBException {
  93         MarshallerImpl m = (MarshallerImpl)_m;
  94         m.write(tagName,bi,t,new SAXOutput(new SAX2DOMEx(output)),new DomPostInitAction(output,m.serializer));
  95     }
  96 
  97     public void marshal(Marshaller _m, T t, ContentHandler contentHandler) throws JAXBException {
  98         MarshallerImpl m = (MarshallerImpl)_m;
  99         m.write(tagName,bi,t,new SAXOutput(contentHandler),null);


   1 /*
   2  * Copyright (c) 1997, 2017, 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


  59  */
  60 final class BridgeImpl<T> extends InternalBridge<T> {
  61 
  62     /**
  63      * Tag name associated with this {@link Bridge}.
  64      * Used for marshalling.
  65      */
  66     private final Name tagName;
  67     private final JaxBeanInfo<T> bi;
  68     private final TypeReference typeRef;
  69 
  70     public BridgeImpl(JAXBContextImpl context, Name tagName, JaxBeanInfo<T> bi,TypeReference typeRef) {
  71         super(context);
  72         this.tagName = tagName;
  73         this.bi = bi;
  74         this.typeRef = typeRef;
  75     }
  76 
  77     public void marshal(Marshaller _m, T t, XMLStreamWriter output) throws JAXBException {
  78         MarshallerImpl m = (MarshallerImpl)_m;
  79         m.write(tagName,bi,t,XMLStreamWriterOutput.create(output,context, m.getEscapeHandler()),new StAXPostInitAction(output,m.serializer));
  80     }
  81 
  82     public void marshal(Marshaller _m, T t, OutputStream output, NamespaceContext nsContext) throws JAXBException {
  83         MarshallerImpl m = (MarshallerImpl)_m;
  84 
  85         Runnable pia = null;
  86         if(nsContext!=null)
  87             pia = new StAXPostInitAction(nsContext,m.serializer);
  88 
  89         m.write(tagName,bi,t,m.createWriter(output),pia);
  90     }
  91 
  92     public void marshal(Marshaller _m, T t, Node output) throws JAXBException {
  93         MarshallerImpl m = (MarshallerImpl)_m;
  94         m.write(tagName,bi,t,new SAXOutput(new SAX2DOMEx(output)),new DomPostInitAction(output,m.serializer));
  95     }
  96 
  97     public void marshal(Marshaller _m, T t, ContentHandler contentHandler) throws JAXBException {
  98         MarshallerImpl m = (MarshallerImpl)_m;
  99         m.write(tagName,bi,t,new SAXOutput(contentHandler),null);


< prev index next >