001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package javax.xml.bind;
018    
019    import java.io.OutputStream;
020    import java.io.Writer;
021    import java.io.File;
022    
023    import javax.xml.bind.annotation.adapters.XmlAdapter;
024    import javax.xml.bind.attachment.AttachmentMarshaller;
025    import javax.xml.validation.Schema;
026    import javax.xml.transform.Result;
027    import javax.xml.stream.XMLEventWriter;
028    import javax.xml.stream.XMLStreamWriter;
029    
030    import org.w3c.dom.Node;
031    
032    import org.xml.sax.ContentHandler;
033    
034    public interface Marshaller {
035    
036        String JAXB_ENCODING = "jaxb.encoding";
037        String JAXB_FORMATTED_OUTPUT = "jaxb.formatted.output";
038        String JAXB_FRAGMENT = "jaxb.fragment";
039        String JAXB_NO_NAMESPACE_SCHEMA_LOCATION = "jaxb.noNamespaceSchemaLocation";
040        String JAXB_SCHEMA_LOCATION = "jaxb.schemaLocation";
041    
042        abstract class Listener {
043            public void beforeMarshal(Object source) {
044            }
045            public void afterMarshal(Object source) {
046            }
047        }
048    
049        <A extends XmlAdapter> A getAdapter(Class<A> type);
050    
051        AttachmentMarshaller getAttachmentMarshaller();
052    
053        ValidationEventHandler getEventHandler() throws JAXBException;
054    
055        Listener getListener();
056    
057        Node getNode(Object contentTree) throws JAXBException;
058    
059        Object getProperty(String name) throws PropertyException;
060    
061        Schema getSchema();
062    
063        void marshal(Object jaxbElement, ContentHandler handler) throws JAXBException;
064    
065        void marshal(Object jaxbElement, File file) throws JAXBException;
066    
067        void marshal(Object jaxbElement, Node node) throws JAXBException;
068    
069        void marshal(Object jaxbElement, OutputStream os) throws JAXBException;
070    
071        void marshal(Object jaxbElement, Result result) throws JAXBException;
072    
073        void marshal(Object jaxbElement, Writer writer) throws JAXBException;
074    
075        void marshal(Object jaxbElement, XMLEventWriter writer) throws JAXBException;
076    
077        void marshal(Object jaxbElement, XMLStreamWriter writer) throws JAXBException;
078    
079        <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter);
080    
081        void setAdapter(XmlAdapter adapter);
082    
083        void setAttachmentMarshaller(AttachmentMarshaller am);
084    
085        void setEventHandler(ValidationEventHandler handler) throws JAXBException;
086    
087        void setListener(Listener listener);
088    
089        void setProperty(String name, Object value) throws PropertyException;
090    
091        void setSchema(Schema schema);
092    
093    }