src/share/jaxws_classes/com/sun/xml/internal/ws/db/glassfish/WrapperBridge.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2012, 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  */
    26 package com.sun.xml.internal.ws.db.glassfish;
    28 import java.io.InputStream;
    29 import java.io.OutputStream;
    31 import javax.xml.bind.JAXBException;
    32 import javax.xml.bind.attachment.AttachmentMarshaller;
    33 import javax.xml.bind.attachment.AttachmentUnmarshaller;
    34 import javax.xml.namespace.NamespaceContext;
    35 import javax.xml.stream.XMLStreamReader;
    36 import javax.xml.stream.XMLStreamWriter;
    37 import javax.xml.transform.Result;
    38 import javax.xml.transform.Source;
    40 import org.w3c.dom.Node;
    41 import org.xml.sax.ContentHandler;
    43 import com.sun.xml.internal.bind.api.Bridge;
    44 import com.sun.xml.internal.bind.api.CompositeStructure;
    45 import com.sun.xml.internal.ws.spi.db.BindingContext;
    46 import com.sun.xml.internal.ws.spi.db.XMLBridge;
    47 import com.sun.xml.internal.ws.spi.db.TypeInfo;
    48 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
    50 public class WrapperBridge<T> implements XMLBridge<T> {
    52     private JAXBRIContextWrapper parent;
    53     private com.sun.xml.internal.bind.api.Bridge<T> bridge;
    55     public WrapperBridge(JAXBRIContextWrapper p, com.sun.xml.internal.bind.api.Bridge<T> b) {
    56         parent = p;
    57         bridge = b;
    58     }
    60     @Override
    61     public BindingContext context() {
    62         return parent;
    63     }
    65     @Override
    66     public boolean equals(Object obj) {
    67         return bridge.equals(obj);
    68     }
    70     @Override
    71     public TypeInfo getTypeInfo() {
    72         return parent.typeInfo(bridge.getTypeReference());
    73     }
    75     @Override
    76     public int hashCode() {
    77         return bridge.hashCode();
    78     }
    80     static CompositeStructure convert(Object o) {
    81         WrapperComposite w = (WrapperComposite) o;
    82         CompositeStructure cs = new CompositeStructure();
    83         cs.values = w.values;
    84         cs.bridges = new Bridge[w.bridges.length];
    85         for (int i = 0; i < cs.bridges.length; i++) {
    86             cs.bridges[i] = ((BridgeWrapper) w.bridges[i]).getBridge();
    87         }
    88         return cs;
    89     }
    91     @Override
    92     public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    93         bridge.marshal((T) convert(object), contentHandler, am);
    94 //              bridge.marshal(object, contentHandler, am);
    95     }
    97     @Override
    98     public void marshal(T object, Node output) throws JAXBException {
    99         throw new UnsupportedOperationException();
   100 //              bridge.marshal(object, output);
   101 //              bridge.marshal((T) convert(object), output);
   102     }
   104     @Override
   105     public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
   106         bridge.marshal((T) convert(object), output, nsContext, am);
   107     }
   109     @Override
   110     public final void marshal(T object, Result result) throws JAXBException {
   111         throw new UnsupportedOperationException();
   112 //              bridge.marshal(object, result);
   113     }
   115     @Override
   116     public final void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
   117         bridge.marshal((T) convert(object), output, am);
   118     }
   120     @Override
   121     public String toString() {
   122         return BridgeWrapper.class.getName() + " : " + bridge.toString();
   123     }
   125     @Override
   126     public final T unmarshal(InputStream in) throws JAXBException {
   127         //EndpointArgumentsBuilder.RpcLit.readRequest
   128         throw new UnsupportedOperationException();
   129 //              return bridge.unmarshal(in);
   130     }
   132     @Override
   133     public final T unmarshal(Node n, AttachmentUnmarshaller au) throws JAXBException {
   134         //EndpointArgumentsBuilder.RpcLit.readRequest
   135         throw new UnsupportedOperationException();
   136 //              return bridge.unmarshal(n, au);
   137     }
   139     @Override
   140     public final T unmarshal(Source in, AttachmentUnmarshaller au) throws JAXBException {
   141         //EndpointArgumentsBuilder.RpcLit.readRequest
   142         throw new UnsupportedOperationException();
   143 //              return bridge.unmarshal(in, au);
   144     }
   146     @Override
   147     public final T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au) throws JAXBException {
   148         //EndpointArgumentsBuilder.RpcLit.readRequest
   149         throw new UnsupportedOperationException();
   150 //              return bridge.unmarshal(in, au);
   151     }
   153     @Override
   154     public boolean supportOutputStream() {
   155         return true;
   156     }
   157 }

mercurial