1/*
2 * Copyright (c) 2000, 2016, 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.javadoc;
27
28import java.io.PrintWriter;
29
30import com.sun.tools.javadoc.main.Start;
31
32/**
33 * Provides external entry points (tool and programmatic)
34 * for the javadoc program.
35 *
36 *  <p><b>This is NOT part of any supported API.
37 *  If you write code that depends on this, you do so at your own risk.
38 *  This code and its internal interfaces are subject to change or
39 *  deletion without notice.</b>
40 *
41 * @deprecated
42 * This class is now deprecated and may be removed in a future release.
43 * See
44 * {@code javax.tools.ToolProvider::getSystemDocumentationTool}
45 * and
46 * {@code javax.tools.DocumentationTool}
47 * for replacement functionality.
48 *
49 * @since 1.4
50 */
51@Deprecated
52public class Main {
53
54    /**
55     * Constructor should never be called.
56     */
57    private Main() {
58    }
59
60    /**
61     * Command line interface.
62     * @param args   The command line parameters.
63     */
64    public static void main(String... args) {
65        System.exit(execute(args));
66    }
67
68    /**
69     * Programmatic interface.
70     * @param args   The command line parameters.
71     * @return The return code.
72     */
73    public static int execute(String... args) {
74        Start jdoc = new Start();
75        return jdoc.begin(args);
76    }
77
78    /**
79     * Programmatic interface.
80     * @param args   The command line parameters.
81     * @param docletParentClassLoader The parent class loader used when
82     *  creating the doclet classloader. If null, the class loader used
83     *  to instantiate doclets will be created without specifying a parent
84     *  class loader.
85     * @return The return code.
86     * @since 1.7
87     */
88    public static int execute(ClassLoader docletParentClassLoader, String... args) {
89        Start jdoc = new Start(docletParentClassLoader);
90        return jdoc.begin(args);
91    }
92
93    /**
94     * Programmatic interface.
95     * @param programName  Name of the program (for error messages).
96     * @param args   The command line parameters.
97     * @return The return code.
98     */
99    public static int execute(String programName, String... args) {
100        Start jdoc = new Start(programName);
101        return jdoc.begin(args);
102    }
103
104    /**
105     * Programmatic interface.
106     * @param programName  Name of the program (for error messages).
107     * @param args   The command line parameters.
108     * @param docletParentClassLoader The parent class loader used when
109     *  creating the doclet classloader. If null, the class loader used
110     *  to instantiate doclets will be created without specifying a parent
111     *  class loader.
112     * @return The return code.
113     * @since 1.7
114     */
115    public static int execute(String programName, ClassLoader docletParentClassLoader, String... args) {
116        Start jdoc = new Start(programName, docletParentClassLoader);
117        return jdoc.begin(args);
118    }
119
120    /**
121     * Programmatic interface.
122     * @param programName  Name of the program (for error messages).
123     * @param defaultDocletClassName  Fully qualified class name.
124     * @param args   The command line parameters.
125     * @return The return code.
126     */
127    public static int execute(String programName,
128                              String defaultDocletClassName,
129                              String... args) {
130        Start jdoc = new Start(programName, defaultDocletClassName);
131        return jdoc.begin(args);
132    }
133
134    /**
135     * Programmatic interface.
136     * @param programName  Name of the program (for error messages).
137     * @param defaultDocletClassName  Fully qualified class name.
138     * @param docletParentClassLoader The parent class loader used when
139     *  creating the doclet classloader. If null, the class loader used
140     *  to instantiate doclets will be created without specifying a parent
141     *  class loader.
142     * @param args   The command line parameters.
143     * @return The return code.
144     * @since 1.7
145     */
146    public static int execute(String programName,
147                              String defaultDocletClassName,
148                              ClassLoader docletParentClassLoader,
149                              String... args) {
150        Start jdoc = new Start(programName, defaultDocletClassName, docletParentClassLoader);
151        return jdoc.begin(args);
152    }
153
154    /**
155     * Programmatic interface.
156     * @param programName  Name of the program (for error messages).
157     * @param errWriter    PrintWriter to receive error messages.
158     * @param warnWriter    PrintWriter to receive error messages.
159     * @param noticeWriter    PrintWriter to receive error messages.
160     * @param defaultDocletClassName  Fully qualified class name.
161     * @param args   The command line parameters.
162     * @return The return code.
163     */
164    public static int execute(String programName,
165                              PrintWriter errWriter,
166                              PrintWriter warnWriter,
167                              PrintWriter noticeWriter,
168                              String defaultDocletClassName,
169                              String... args) {
170        Start jdoc = new Start(programName,
171                               errWriter, warnWriter, noticeWriter,
172                               defaultDocletClassName);
173        return jdoc.begin(args);
174    }
175
176    /**
177     * Programmatic interface.
178     * @param programName  Name of the program (for error messages).
179     * @param errWriter    PrintWriter to receive error messages.
180     * @param warnWriter    PrintWriter to receive error messages.
181     * @param noticeWriter    PrintWriter to receive error messages.
182     * @param defaultDocletClassName  Fully qualified class name.
183     * @param docletParentClassLoader The parent class loader used when
184     *  creating the doclet classloader. If null, the class loader used
185     *  to instantiate doclets will be created without specifying a parent
186     *  class loader.
187     * @param args   The command line parameters.
188     * @return The return code.
189     * @since 1.7
190     */
191    public static int execute(String programName,
192                              PrintWriter errWriter,
193                              PrintWriter warnWriter,
194                              PrintWriter noticeWriter,
195                              String defaultDocletClassName,
196                              ClassLoader docletParentClassLoader,
197                              String... args) {
198        Start jdoc = new Start(programName,
199                               errWriter, warnWriter, noticeWriter,
200                               defaultDocletClassName,
201                               docletParentClassLoader);
202        return jdoc.begin(args);
203    }
204}
205