325N/A/*
325N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.tools.internal.xjc;
325N/A
325N/Aimport java.io.PrintStream;
325N/A
325N/Aimport com.sun.tools.internal.xjc.api.ErrorListener;
325N/Aimport com.sun.tools.internal.xjc.outline.Outline;
325N/A
325N/A/**
325N/A * Call-back interface that can be implemented by the caller of {@link Driver}
325N/A * to receive output from XJC.
325N/A *
325N/A * <p>
325N/A * Most of the messages XJC produce once the real work starts is structured
325N/A * as (message,source). Those outputs will be reported to various methods on
325N/A * {@link ErrorListener}, which is inherited by this interface.
325N/A *
325N/A * <p>
325N/A * The other messages (such as the usage screen when there was an error in
325N/A * the command line option) will go to the {@link #message(String)} method.
325N/A *
325N/A * @author Kohsuke Kawaguchi
325N/A * @since JAXB 2.0 EA
325N/A */
325N/Apublic abstract class XJCListener implements ErrorListener {
325N/A
325N/A /**
325N/A * @deprecated
325N/A * Override {@link #generatedFile(String, int, int)}.
325N/A * Deprecated in 2.0.1.
325N/A */
325N/A public void generatedFile(String fileName) {}
325N/A
325N/A /**
325N/A * Called for each file generated by XJC.
325N/A *
325N/A * <p>
325N/A * XJC may generate not only source files but also resources files.
325N/A * The file name includes the path portions that correspond with the package name.
325N/A *
325N/A * <p>
325N/A * When generating files into a directory, file names will be relative to the
325N/A * output directory. When generating files into a zip file, file names will be
325N/A * those in the zip file.
325N/A *
325N/A * @param fileName
325N/A * file names like "org/acme/foo/Foo.java" or "org/acme/foo/jaxb.properties".
325N/A *
325N/A * @since 2.0.1
325N/A */
325N/A public void generatedFile(String fileName, int current, int total ) {
325N/A generatedFile(fileName); // backward compatibility
325N/A }
325N/A
325N/A /**
325N/A * Other miscellenous messages that do not have structures
325N/A * will be reported through this method.
325N/A *
325N/A * This method is used like {@link PrintStream#println(String)}.
325N/A * The callee is expected to add '\n'.
325N/A */
325N/A public void message(String msg) {}
325N/A
325N/A /**
325N/A * Called after the schema is compiled and the code generation strategy is determined,
325N/A * but before any code is actually generated as files.
325N/A *
325N/A * @param outline
325N/A * never null. this is the root object that represents the code generation strategy.
325N/A */
325N/A public void compiled(Outline outline) {}
325N/A
325N/A /**
325N/A * XJC will periodically invoke this method to see if it should cancel a compilation.
325N/A *
325N/A * <p>
325N/A * As long as this method returns false, XJC will keep going. If this method ever returns
325N/A * true, XJC will abort the processing right away and
325N/A * returns non-zero from {@link Driver#run(String[], XJCListener)}.
325N/A * Note that XJC will not report an abortion through the {@link #message(String)} method.
325N/A *
325N/A * <p>
325N/A * Note that despite all the efforts to check this method frequently, XJC may still fail to
325N/A * invoke this method for a long time. Such scenario would include network related problems
325N/A * or other I/O block (you can't even interrupt the thread while I/O is blocking.)
325N/A * So just beware that this is not a cure-all.
325N/A *
325N/A * @return
325N/A * true if the {@link XJCListener} wants to abort the processing.
325N/A * @since 2.1
325N/A */
325N/A public boolean isCanceled() {
325N/A return false;
325N/A }
325N/A}