Path: blob/master/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java
41161 views
/*1* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package jdk.javadoc.internal.tool;2526import java.io.PrintWriter;2728/**29* Provides external entry points (tool and programmatic) for the javadoc program.30*31* <p><b>This is NOT part of any supported API.32* If you write code that depends on this, you do so at your own risk.33* This code and its internal interfaces are subject to change or34* deletion without notice.</b>35*/3637public class Main {3839/**40* This constructor should never be called.41*/42private Main() { throw new AssertionError(); }4344/**45* The main entry point called by the launcher. This will call46* System.exit with an appropriate return value.47*48* @param args the command-line parameters49*/50public static void main(String... args) {51System.exit(execute(args));52}5354/**55* Programmatic interface.56*57* @param args the command-line parameters58* @return The return code.59*/60public static int execute(String... args) {61Start jdoc = new Start();62return jdoc.begin(args).exitCode;63}6465/**66* Programmatic interface.67*68* @param writer a stream for all output69* @param args the command-line parameters70* @return The return code.71*/72public static int execute(String[] args, PrintWriter writer) {73Start jdoc = new Start(writer, writer);74return jdoc.begin(args).exitCode;75}7677/**78* Programmatic interface.79*80* @param outWriter a stream for expected output81* @param errWriter a stream for diagnostic output82* @param args the command-line parameters83* @return The return code.84*/85public static int execute(String[] args, PrintWriter outWriter, PrintWriter errWriter) {86Start jdoc = new Start(outWriter, errWriter);87return jdoc.begin(args).exitCode;88}8990public enum Result {91/** completed with no errors */92OK(0),93/** Completed with reported errors */94ERROR(1),95/** Bad command-line arguments */96CMDERR(2),97/** System error or resource exhaustion */98SYSERR(3),99/** Terminated abnormally */100ABNORMAL(4);101102Result(int exitCode) {103this.exitCode = exitCode;104}105106public boolean isOK() {107return (exitCode == 0);108}109110public final int exitCode;111112@Override113public String toString() {114return name() + '(' + exitCode + ')';115}116}117}118119120