1/*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.tools.internal.xjc.api;
27
28import java.util.Collection;
29import java.util.List;
30
31import javax.xml.namespace.QName;
32import javax.xml.bind.annotation.XmlSeeAlso;
33
34import com.sun.codemodel.internal.CodeWriter;
35import com.sun.codemodel.internal.JCodeModel;
36import com.sun.codemodel.internal.JClass;
37import com.sun.tools.internal.xjc.Options;
38import com.sun.tools.internal.xjc.Plugin;
39
40/**
41 * {@link JAXBModel} that exposes additional information available
42 * only for the {@code schema -> java} direction.
43 *
44 * @author Kohsuke Kawaguchi
45 */
46public interface S2JJAXBModel extends JAXBModel {
47
48    /**
49     * Gets a {@link Mapping} object for the given global element.
50     *
51     * @return
52     *      null if the element name is not a defined global element in the schema.
53     */
54    Mapping get( QName elementName );
55
56    /**
57     * Gets all the {@code ObjectFactory} classes generated by the compilation.
58     *
59     * <p>
60     * This should be used for generating {@link XmlSeeAlso} on the SEI.
61     */
62    List<JClass> getAllObjectFactories();
63
64
65    /**
66     * Gets a read-only view of all the {@link Mapping}s.
67     */
68    Collection<? extends Mapping> getMappings();
69
70    /**
71     * Returns the fully-qualified name of the Java type that is bound to the
72     * specified XML type.
73     *
74     * @param xmlTypeName
75     *      must not be null.
76     * @return
77     *      null if the XML type is not bound to any Java type.
78     */
79    TypeAndAnnotation getJavaType(QName xmlTypeName);
80
81    /**
82     * Generates artifacts.
83     *
84     * <p>
85     * TODO: if JAXB supports various modes of code generations
86     * (such as public interface only or implementation only or
87     * etc), we should define bit flags to control those.
88     *
89     * <p>
90     * This operation is only supported for a model built from a schema.
91     *
92     * @param extensions
93     *      The JAXB RI extensions to run. This can be null or empty
94     *      array if the caller wishes not to run any extension.
95     *      <br>
96     *
97     *      Those specified extensions
98     *      will participate in the code generation. Specifying an extension
99     *      in this list has the same effect of turning that extension on
100     *      via command line.
101     *      <br>
102     *
103     *      It is the caller's responsibility to configure each augmenter
104     *      properly by using {@link Plugin#parseArgument(Options, String[], int)}.
105     *
106     * @return
107     *      object filled with the generated code. Use
108     *      {@link JCodeModel#build(CodeWriter)} to write them
109     *      to a disk.
110     */
111    JCodeModel generateCode( Plugin[] extensions, ErrorListener errorListener );
112}
113