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    
022    import javax.xml.bind.annotation.adapters.XmlAdapter;
023    import javax.xml.bind.attachment.AttachmentMarshaller;
024    import javax.xml.validation.Schema;
025    import javax.xml.transform.Result;
026    import javax.xml.stream.XMLEventWriter;
027    import javax.xml.stream.XMLStreamWriter;
028    
029    import org.w3c.dom.Node;
030    
031    import org.xml.sax.ContentHandler;
032    
033    public interface Marshaller {
034    
035        String JAXB_ENCODING = "jaxb.encoding";
036        String JAXB_FORMATTED_OUTPUT = "jaxb.formatted.output";
037        String JAXB_FRAGMENT = "jaxb.fragment";
038        String JAXB_NO_NAMESPACE_SCHEMA_LOCATION = "jaxb.noNamespaceSchemaLocation";
039        String JAXB_SCHEMA_LOCATION = "jaxb.schemaLocation";
040    
041        abstract class Listener {
042            public void beforeMarshal(Object source) {
043            }
044            public void afterMarshal(Object source) {
045            }
046        }
047    
048        <A extends XmlAdapter> A getAdapter(Class<A> type);
049    
050        AttachmentMarshaller getAttachmentMarshaller();
051    
052        ValidationEventHandler getEventHandler() throws JAXBException;
053    
054        Listener getListener();
055    
056        Node getNode(Object contentTree) throws JAXBException;
057    
058        Object getProperty(String name) throws PropertyException;
059    
060        Schema getSchema();
061    
062        void marshal(Object jaxbElement, ContentHandler handler) throws JAXBException;
063    
064        void marshal(Object jaxbElement, Node node) throws JAXBException;
065    
066        void marshal(Object jaxbElement, OutputStream os) throws JAXBException;
067    
068        void marshal(Object jaxbElement, Result result) throws JAXBException;
069    
070        void marshal(Object jaxbElement, Writer writer) throws JAXBException;
071    
072        void marshal(Object jaxbElement, XMLEventWriter writer) throws JAXBException;
073    
074        void marshal(Object jaxbElement, XMLStreamWriter writer) throws JAXBException;
075    
076        <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter);
077    
078        void setAdapter(XmlAdapter adapter);
079    
080        void setAttachmentMarshaller(AttachmentMarshaller am);
081    
082        void setEventHandler(ValidationEventHandler handler) throws JAXBException;
083    
084        void setListener(Listener listener);
085    
086        void setProperty(String name, Object value) throws PropertyException;
087    
088        void setSchema(Schema schema);
089    
090    }