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.IOException;
20  
21  import java.util.Map;
22  import java.util.Collections;
23  
24  import org.w3c.dom.Node;
25  
26  public abstract class JAXBContext {
27  
28      public static final String JAXB_CONTEXT_FACTORY = "javax.xml.bind.context.factory";
29  
30      protected JAXBContext() {
31      }
32  
33      public Binder<Node> createBinder() {
34          throw new UnsupportedOperationException();
35      }
36  
37      public <T> Binder<T> createBinder(Class<T> domType) {
38          throw new UnsupportedOperationException();
39      }
40  
41      public JAXBIntrospector createJAXBIntrospector() {
42          throw new UnsupportedOperationException();
43      }
44  
45      public abstract Marshaller createMarshaller() throws JAXBException;
46  
47      public abstract Unmarshaller createUnmarshaller() throws JAXBException;
48  
49      public abstract Validator createValidator() throws JAXBException;
50  
51      public void generateSchema(SchemaOutputResolver resolver) throws IOException {
52          throw new UnsupportedOperationException();
53      }
54  
55      public static JAXBContext newInstance(Class... classesToBeBound) throws JAXBException {
56          return newInstance(classesToBeBound, Collections.<String, Object>emptyMap());
57      }
58  
59      public static JAXBContext newInstance(Class[] classesToBeBound, Map<String, ?> properties) throws JAXBException {
60          for (Class cl : classesToBeBound) {
61              if (cl == null) {
62                  throw new IllegalArgumentException();
63              }
64          }
65          return ContextFinder.find(classesToBeBound, properties);
66      }
67  
68      public static JAXBContext newInstance(String contextPath) throws JAXBException {
69          return newInstance(contextPath, Thread.currentThread().getContextClassLoader());
70      }
71  
72      public static JAXBContext newInstance(String contextPath, ClassLoader classLoader) throws JAXBException {
73          return newInstance(contextPath, classLoader, Collections.<String, Object>emptyMap());
74      }
75  
76      public static JAXBContext newInstance(String contextPath, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException {
77          return ContextFinder.find(contextPath, classLoader, properties);
78      }
79  }