aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.ws.spi.db; aoqi@0: aoqi@0: import java.io.InputStream; aoqi@0: import java.io.OutputStream; aoqi@0: aoqi@0: import javax.xml.bind.JAXBException; aoqi@0: import javax.xml.bind.attachment.AttachmentMarshaller; aoqi@0: import javax.xml.bind.attachment.AttachmentUnmarshaller; aoqi@0: import javax.xml.namespace.NamespaceContext; aoqi@0: import javax.xml.stream.XMLStreamReader; aoqi@0: import javax.xml.stream.XMLStreamWriter; aoqi@0: import javax.xml.transform.Result; aoqi@0: import javax.xml.transform.Source; aoqi@0: aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: import com.sun.istack.internal.Nullable; aoqi@0: import org.w3c.dom.Node; aoqi@0: import org.xml.sax.ContentHandler; aoqi@0: aoqi@0: /** aoqi@0: * The XMLBridge is a Glassfish JAXWS side of Glassfish JAXB Bridge. aoqi@0: * aoqi@0: * Mini-marshaller/unmarshaller that is specialized for a particular aoqi@0: * element name and a type. aoqi@0: * aoqi@0: *

aoqi@0: * Instances of this class is stateless and multi-thread safe. aoqi@0: * They are reentrant. aoqi@0: * aoqi@0: *

aoqi@0: * All the marshal operation generates fragments. aoqi@0: * aoqi@0: *

aoqi@0: * Subject to change without notice. aoqi@0: * aoqi@0: * @since JAXB 2.0 EA1 aoqi@0: * @author Kohsuke Kawaguchi aoqi@0: * @author shih-chang.chen@oracle.com aoqi@0: */ aoqi@0: public interface XMLBridge { aoqi@0: /** aoqi@0: * Gets the {@link BindingContext} to which this object belongs. aoqi@0: * aoqi@0: * @since 2.1 aoqi@0: */ aoqi@0: public @NotNull BindingContext context(); aoqi@0: aoqi@0: /** aoqi@0: * aoqi@0: * @throws JAXBException aoqi@0: * if there was an error while marshalling. aoqi@0: * aoqi@0: * @since 2.0 EA1 aoqi@0: */ aoqi@0: // public void marshal(T object,XMLStreamWriter output) throws JAXBException; aoqi@0: aoqi@0: public void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * Marshals the specified type object with the implicit element name aoqi@0: * associated with this instance of {@link Bond}. aoqi@0: * aoqi@0: * @param nsContext aoqi@0: * if this marshalling is done to marshal a subelement, this {@link NamespaceContext} aoqi@0: * represents in-scope namespace bindings available for that element. Can be null, aoqi@0: * in which case JAXB assumes no in-scope namespaces. aoqi@0: * @throws JAXBException aoqi@0: * if there was an error while marshalling. aoqi@0: * aoqi@0: * @since 2.0 EA1 aoqi@0: */ aoqi@0: // public void marshal(T object,OutputStream output, NamespaceContext nsContext) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * @since 2.0.2 aoqi@0: */ aoqi@0: public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException ; aoqi@0: // aoqi@0: //// public void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException; aoqi@0: // aoqi@0: // public void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException; aoqi@0: aoqi@0: aoqi@0: public void marshal(T object,Node output) throws JAXBException ; aoqi@0: // aoqi@0: //// public void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException ; aoqi@0: // aoqi@0: // public void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException; aoqi@0: aoqi@0: aoqi@0: /** aoqi@0: * @since 2.0 EA4 aoqi@0: */ aoqi@0: // public void marshal(T object, ContentHandler contentHandler) throws JAXBException; aoqi@0: /** aoqi@0: * @since 2.0.2 aoqi@0: */ aoqi@0: public void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException ; aoqi@0: aoqi@0: //// public void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException; aoqi@0: // aoqi@0: // public void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * @since 2.0 EA4 aoqi@0: */ aoqi@0: public void marshal(T object, Result result) throws JAXBException; aoqi@0: aoqi@0: //// public void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException; aoqi@0: // public void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException; aoqi@0: aoqi@0: aoqi@0: aoqi@0: /** aoqi@0: * Unmarshals the specified type object. aoqi@0: * aoqi@0: * @param in aoqi@0: * the parser must be pointing at a start tag aoqi@0: * that encloses the XML type that this {@link Bond} is aoqi@0: * instanciated for. aoqi@0: * aoqi@0: * @return aoqi@0: * never null. aoqi@0: * aoqi@0: * @throws JAXBException aoqi@0: * if there was an error while unmarshalling. aoqi@0: * aoqi@0: * @since 2.0 EA1 aoqi@0: */ aoqi@0: // public @NotNull T unmarshal(@NotNull XMLStreamReader in) throws JAXBException ; aoqi@0: /** aoqi@0: * @since 2.0.3 aoqi@0: */ aoqi@0: public @NotNull T unmarshal(@NotNull XMLStreamReader in, @Nullable AttachmentUnmarshaller au) throws JAXBException; aoqi@0: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException ; aoqi@0: // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * Unmarshals the specified type object. aoqi@0: * aoqi@0: * @param in aoqi@0: * the parser must be pointing at a start tag aoqi@0: * that encloses the XML type that this {@link Bond} is aoqi@0: * instanciated for. aoqi@0: * aoqi@0: * @return aoqi@0: * never null. aoqi@0: * aoqi@0: * @throws JAXBException aoqi@0: * if there was an error while unmarshalling. aoqi@0: * aoqi@0: * @since 2.0 EA1 aoqi@0: */ aoqi@0: // public @NotNull T unmarshal(@NotNull Source in) throws JAXBException ; aoqi@0: /** aoqi@0: * @since 2.0.3 aoqi@0: */ aoqi@0: public @NotNull T unmarshal(@NotNull Source in, @Nullable AttachmentUnmarshaller au) throws JAXBException; aoqi@0: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException; aoqi@0: // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * Unmarshals the specified type object. aoqi@0: * aoqi@0: * @param in aoqi@0: * the parser must be pointing at a start tag aoqi@0: * that encloses the XML type that this {@link XMLBridge} is aoqi@0: * instanciated for. aoqi@0: * aoqi@0: * @return aoqi@0: * never null. aoqi@0: * aoqi@0: * @throws JAXBException aoqi@0: * if there was an error while unmarshalling. aoqi@0: * aoqi@0: * @since 2.0 EA1 aoqi@0: */ aoqi@0: public @NotNull T unmarshal(@NotNull InputStream in) throws JAXBException ; aoqi@0: aoqi@0: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException ; aoqi@0: aoqi@0: // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * Unmarshals the specified type object. aoqi@0: * aoqi@0: * @param n aoqi@0: * Node to be unmarshalled. aoqi@0: * aoqi@0: * @return aoqi@0: * never null. aoqi@0: * aoqi@0: * @throws JAXBException aoqi@0: * if there was an error while unmarshalling. aoqi@0: * aoqi@0: * @since 2.0 FCS aoqi@0: */ aoqi@0: // public @NotNull T unmarshal(@NotNull Node n) throws JAXBException ; aoqi@0: /** aoqi@0: * @since 2.0.3 aoqi@0: */ aoqi@0: public @NotNull T unmarshal(@NotNull Node n, @Nullable AttachmentUnmarshaller au) throws JAXBException; aoqi@0: // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException; aoqi@0: // public @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException; aoqi@0: aoqi@0: /** aoqi@0: * Gets the {@link TypeInfo} from which this bridge was created. aoqi@0: */ aoqi@0: public TypeInfo getTypeInfo(); aoqi@0: aoqi@0: /** aoqi@0: * This can be used to determine whether XMLStreamWriter or OutputStream is aoqi@0: * prefered by the implementation. aoqi@0: * aoqi@0: * @return true if marshall to OutputStream is supported in the aoqi@0: * implementation. aoqi@0: */ aoqi@0: public boolean supportOutputStream(); aoqi@0: }