ohair@286: /*
alanb@368: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286: *
ohair@286: * This code is free software; you can redistribute it and/or modify it
ohair@286: * under the terms of the GNU General Public License version 2 only, as
ohair@286: * published by the Free Software Foundation. Oracle designates this
ohair@286: * particular file as subject to the "Classpath" exception as provided
ohair@286: * by Oracle in the LICENSE file that accompanied this code.
ohair@286: *
ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286: * version 2 for more details (a copy is included in the LICENSE file that
ohair@286: * accompanied this code).
ohair@286: *
ohair@286: * You should have received a copy of the GNU General Public License version
ohair@286: * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286: *
ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286: * or visit www.oracle.com if you need additional information or have any
ohair@286: * questions.
ohair@286: */
ohair@286:
ohair@286: package com.sun.xml.internal.ws.spi.db;
ohair@286:
ohair@286: import java.io.InputStream;
ohair@286: import java.io.OutputStream;
ohair@286:
ohair@286: import javax.xml.bind.JAXBException;
ohair@286: import javax.xml.bind.attachment.AttachmentMarshaller;
ohair@286: import javax.xml.bind.attachment.AttachmentUnmarshaller;
ohair@286: import javax.xml.namespace.NamespaceContext;
ohair@286: import javax.xml.stream.XMLStreamReader;
ohair@286: import javax.xml.stream.XMLStreamWriter;
ohair@286: import javax.xml.transform.Result;
ohair@286: import javax.xml.transform.Source;
ohair@286:
ohair@286: import com.sun.istack.internal.NotNull;
ohair@286: import com.sun.istack.internal.Nullable;
ohair@286: import org.w3c.dom.Node;
ohair@286: import org.xml.sax.ContentHandler;
ohair@286:
ohair@286: /**
ohair@286: * The XMLBridge is a Glassfish JAXWS side of Glassfish JAXB Bridge.
ohair@286: *
ohair@286: * Mini-marshaller/unmarshaller that is specialized for a particular
ohair@286: * element name and a type.
ohair@286: *
ohair@286: *
ohair@286: * Instances of this class is stateless and multi-thread safe.
ohair@286: * They are reentrant.
ohair@286: *
ohair@286: *
ohair@286: * All the marshal operation generates fragments.
ohair@286: *
ohair@286: *
ohair@286: * Subject to change without notice.
ohair@286: *
ohair@286: * @since JAXB 2.0 EA1
ohair@286: * @author Kohsuke Kawaguchi
ohair@286: * @author shih-chang.chen@oracle.com
ohair@286: */
ohair@286: public interface XMLBridge {
ohair@286: /**
ohair@286: * Gets the {@link BindingContext} to which this object belongs.
ohair@286: *
ohair@286: * @since 2.1
ohair@286: */
ohair@286: public @NotNull BindingContext context();
ohair@286:
ohair@286: /**
ohair@286: *
ohair@286: * @throws JAXBException
ohair@286: * if there was an error while marshalling.
ohair@286: *
ohair@286: * @since 2.0 EA1
ohair@286: */
ohair@286: // public void marshal(T object,XMLStreamWriter output) throws JAXBException;
ohair@286:
ohair@286: public void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * Marshals the specified type object with the implicit element name
ohair@286: * associated with this instance of {@link Bond}.
ohair@286: *
ohair@286: * @param nsContext
ohair@286: * if this marshalling is done to marshal a subelement, this {@link NamespaceContext}
ohair@286: * represents in-scope namespace bindings available for that element. Can be null,
ohair@286: * in which case JAXB assumes no in-scope namespaces.
ohair@286: * @throws JAXBException
ohair@286: * if there was an error while marshalling.
ohair@286: *
ohair@286: * @since 2.0 EA1
ohair@286: */
ohair@286: // public void marshal(T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * @since 2.0.2
ohair@286: */
ohair@286: public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException ;
ohair@286: //
ohair@286: //// public void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
ohair@286: //
ohair@286: // public void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
ohair@286:
ohair@286:
ohair@286: public void marshal(T object,Node output) throws JAXBException ;
ohair@286: //
ohair@286: //// public void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException ;
ohair@286: //
ohair@286: // public void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException;
ohair@286:
ohair@286:
ohair@286: /**
ohair@286: * @since 2.0 EA4
ohair@286: */
ohair@286: // public void marshal(T object, ContentHandler contentHandler) throws JAXBException;
ohair@286: /**
ohair@286: * @since 2.0.2
ohair@286: */
ohair@286: public void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException ;
ohair@286:
ohair@286: //// public void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException;
ohair@286: //
ohair@286: // public void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * @since 2.0 EA4
ohair@286: */
ohair@286: public void marshal(T object, Result result) throws JAXBException;
ohair@286:
ohair@286: //// public void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException;
ohair@286: // public void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException;
ohair@286:
ohair@286:
ohair@286:
ohair@286: /**
ohair@286: * Unmarshals the specified type object.
ohair@286: *
ohair@286: * @param in
ohair@286: * the parser must be pointing at a start tag
ohair@286: * that encloses the XML type that this {@link Bond} is
ohair@286: * instanciated for.
ohair@286: *
ohair@286: * @return
ohair@286: * never null.
ohair@286: *
ohair@286: * @throws JAXBException
ohair@286: * if there was an error while unmarshalling.
ohair@286: *
ohair@286: * @since 2.0 EA1
ohair@286: */
ohair@286: // public @NotNull T unmarshal(@NotNull XMLStreamReader in) throws JAXBException ;
ohair@286: /**
ohair@286: * @since 2.0.3
ohair@286: */
ohair@286: public @NotNull T unmarshal(@NotNull XMLStreamReader in, @Nullable AttachmentUnmarshaller au) throws JAXBException;
ohair@286: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException ;
ohair@286: // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * Unmarshals the specified type object.
ohair@286: *
ohair@286: * @param in
ohair@286: * the parser must be pointing at a start tag
ohair@286: * that encloses the XML type that this {@link Bond} is
ohair@286: * instanciated for.
ohair@286: *
ohair@286: * @return
ohair@286: * never null.
ohair@286: *
ohair@286: * @throws JAXBException
ohair@286: * if there was an error while unmarshalling.
ohair@286: *
ohair@286: * @since 2.0 EA1
ohair@286: */
ohair@286: // public @NotNull T unmarshal(@NotNull Source in) throws JAXBException ;
ohair@286: /**
ohair@286: * @since 2.0.3
ohair@286: */
ohair@286: public @NotNull T unmarshal(@NotNull Source in, @Nullable AttachmentUnmarshaller au) throws JAXBException;
ohair@286: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException;
ohair@286: // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * Unmarshals the specified type object.
ohair@286: *
ohair@286: * @param in
ohair@286: * the parser must be pointing at a start tag
ohair@286: * that encloses the XML type that this {@link XMLBridge} is
ohair@286: * instanciated for.
ohair@286: *
ohair@286: * @return
ohair@286: * never null.
ohair@286: *
ohair@286: * @throws JAXBException
ohair@286: * if there was an error while unmarshalling.
ohair@286: *
ohair@286: * @since 2.0 EA1
ohair@286: */
ohair@286: public @NotNull T unmarshal(@NotNull InputStream in) throws JAXBException ;
ohair@286:
ohair@286: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException ;
ohair@286:
ohair@286: // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * Unmarshals the specified type object.
ohair@286: *
ohair@286: * @param n
ohair@286: * Node to be unmarshalled.
ohair@286: *
ohair@286: * @return
ohair@286: * never null.
ohair@286: *
ohair@286: * @throws JAXBException
ohair@286: * if there was an error while unmarshalling.
ohair@286: *
ohair@286: * @since 2.0 FCS
ohair@286: */
ohair@286: // public @NotNull T unmarshal(@NotNull Node n) throws JAXBException ;
ohair@286: /**
ohair@286: * @since 2.0.3
ohair@286: */
ohair@286: public @NotNull T unmarshal(@NotNull Node n, @Nullable AttachmentUnmarshaller au) throws JAXBException;
ohair@286: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException;
ohair@286: // public @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException;
ohair@286:
ohair@286: /**
ohair@286: * Gets the {@link TypeInfo} from which this bridge was created.
ohair@286: */
ohair@286: public TypeInfo getTypeInfo();
ohair@286:
ohair@286: /**
ohair@286: * This can be used to determine whether XMLStreamWriter or OutputStream is
ohair@286: * prefered by the implementation.
ohair@286: *
ohair@286: * @return true if marshall to OutputStream is supported in the
ohair@286: * implementation.
ohair@286: */
ohair@286: public boolean supportOutputStream();
ohair@286: }