View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package javax.xml.bind;
18  
19  import java.io.OutputStream;
20  import java.io.Writer;
21  import java.io.File;
22  
23  import javax.xml.bind.annotation.adapters.XmlAdapter;
24  import javax.xml.bind.attachment.AttachmentMarshaller;
25  import javax.xml.validation.Schema;
26  import javax.xml.transform.Result;
27  import javax.xml.stream.XMLEventWriter;
28  import javax.xml.stream.XMLStreamWriter;
29  
30  import org.w3c.dom.Node;
31  
32  import org.xml.sax.ContentHandler;
33  
34  public interface Marshaller {
35  
36      String JAXB_ENCODING = "jaxb.encoding";
37      String JAXB_FORMATTED_OUTPUT = "jaxb.formatted.output";
38      String JAXB_FRAGMENT = "jaxb.fragment";
39      String JAXB_NO_NAMESPACE_SCHEMA_LOCATION = "jaxb.noNamespaceSchemaLocation";
40      String JAXB_SCHEMA_LOCATION = "jaxb.schemaLocation";
41  
42      abstract class Listener {
43          public void beforeMarshal(Object source) {
44          }
45          public void afterMarshal(Object source) {
46          }
47      }
48  
49      <A extends XmlAdapter> A getAdapter(Class<A> type);
50  
51      AttachmentMarshaller getAttachmentMarshaller();
52  
53      ValidationEventHandler getEventHandler() throws JAXBException;
54  
55      Listener getListener();
56  
57      Node getNode(Object contentTree) throws JAXBException;
58  
59      Object getProperty(String name) throws PropertyException;
60  
61      Schema getSchema();
62  
63      void marshal(Object jaxbElement, ContentHandler handler) throws JAXBException;
64  
65      void marshal(Object jaxbElement, File file) throws JAXBException;
66  
67      void marshal(Object jaxbElement, Node node) throws JAXBException;
68  
69      void marshal(Object jaxbElement, OutputStream os) throws JAXBException;
70  
71      void marshal(Object jaxbElement, Result result) throws JAXBException;
72  
73      void marshal(Object jaxbElement, Writer writer) throws JAXBException;
74  
75      void marshal(Object jaxbElement, XMLEventWriter writer) throws JAXBException;
76  
77      void marshal(Object jaxbElement, XMLStreamWriter writer) throws JAXBException;
78  
79      <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter);
80  
81      void setAdapter(XmlAdapter adapter);
82  
83      void setAttachmentMarshaller(AttachmentMarshaller am);
84  
85      void setEventHandler(ValidationEventHandler handler) throws JAXBException;
86  
87      void setListener(Listener listener);
88  
89      void setProperty(String name, Object value) throws PropertyException;
90  
91      void setSchema(Schema schema);
92  
93  }