Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/rmi/rmic/newrmic/BatchEnvironment.java
38923 views
/*1* Copyright (c) 2003, 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*/2425package sun.rmi.rmic.newrmic;2627import com.sun.javadoc.ClassDoc;28import com.sun.javadoc.RootDoc;29import java.io.File;30import java.text.MessageFormat;31import java.util.ArrayList;32import java.util.Collections;33import java.util.List;3435import static sun.rmi.rmic.newrmic.Constants.*;3637/**38* The environment for an rmic compilation batch.39*40* A BatchEnvironment contains a RootDoc, which is the entry point41* into the doclet environment for the associated rmic compilation42* batch. A BatchEnvironment collects the source files generated43* during the batch's execution, for eventual source code compilation44* and, possibly, deletion. Errors that occur during generation45* activity should be reported through the BatchEnvironment's "error"46* method.47*48* A protocol-specific generator class may require the use of a49* particular BatchEnvironment subclass for enhanced environment50* functionality. A BatchEnvironment subclass must declare a51* public constructor with one parameter of type RootDoc.52*53* WARNING: The contents of this source file are not part of any54* supported API. Code that depends on them does so at its own risk:55* they are subject to change or removal without notice.56*57* @author Peter Jones58**/59public class BatchEnvironment {6061private final RootDoc rootDoc;6263/** cached ClassDoc for certain types used by rmic */64private final ClassDoc docRemote;65private final ClassDoc docException;66private final ClassDoc docRemoteException;67private final ClassDoc docRuntimeException;6869private boolean verbose = false;70private final List<File> generatedFiles = new ArrayList<File>();7172/**73* Creates a new BatchEnvironment with the specified RootDoc.74**/75public BatchEnvironment(RootDoc rootDoc) {76this.rootDoc = rootDoc;7778/*79* Initialize cached ClassDoc for types used by rmic. Note80* that any of these could be null if the boot class path is81* incorrect, which could cause a NullPointerException later.82*/83docRemote = rootDoc().classNamed(REMOTE);84docException = rootDoc().classNamed(EXCEPTION);85docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);86docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);87}8889/**90* Returns the RootDoc for this environment.91**/92public RootDoc rootDoc() {93return rootDoc;94}9596public ClassDoc docRemote() { return docRemote; }97public ClassDoc docException() { return docException; }98public ClassDoc docRemoteException() { return docRemoteException; }99public ClassDoc docRuntimeException() { return docRuntimeException; }100101/**102* Sets this environment's verbosity status.103**/104public void setVerbose(boolean verbose) {105this.verbose = verbose;106}107108/**109* Returns this environment's verbosity status.110**/111public boolean verbose() {112return verbose;113}114115/**116* Adds the specified file to the list of source files generated117* during this batch.118**/119public void addGeneratedFile(File file) {120generatedFiles.add(file);121}122123/**124* Returns the list of files generated during this batch.125**/126public List<File> generatedFiles() {127return Collections.unmodifiableList(generatedFiles);128}129130/**131* Outputs the specified (non-error) message.132**/133public void output(String msg) {134rootDoc.printNotice(msg);135}136137/**138* Reports an error using the specified resource key and text139* formatting arguments.140**/141public void error(String key, String... args) {142rootDoc.printError(Resources.getText(key, args));143}144}145146147