/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Command Line Interface of XJC.
*/
public class Driver {
// use the platform default proxy if available.
// see sun.net.spi.DefaultProxySelector for details.
try {
} catch (SecurityException e) {
// failing to set this property isn't fatal
}
// run all the work in another thread so that the -Xss option
// will take effect when compiling a large schema. See
public void run() {
try {
} catch( Throwable e ) {
ex[0]=e;
}
}
};
// re-throw
else
}
}
try {
} catch (BadCommandLineException e) {
// there was an error in the command line.
// print usage and abort.
if(e.getMessage()!=null) {
}
usage(e.getOptions(),false);
}
}
/**
* specified PrintStream.
*
* <p>
* This method could be used to trigger XJC from other tools,
* such as Ant or IDE.
*
* @param args
* specified command line parameters. If there is an error
* in the parameters, {@link BadCommandLineException} will
* be thrown.
* @param status
* Status report of the compilation will be sent to this object.
* Useful to update users so that they will know something is happening.
* Only ignorable messages should be sent to this stream.
*
* This parameter can be null to suppress messages.
*
* @param out
* Various non-ignorable output (error messages, etc)
* will go to this stream.
*
* @return
* If the compiler runs successfully, this method returns 0.
* All non-zero values indicate an error. The error message
* will be sent to the specified PrintStream.
*/
throws Exception {
class Listener extends XJCListener {
ConsoleErrorReporter cer = new ConsoleErrorReporter(out==null?new PrintStream(new NullStream()):out);
}
}
}
}
}
}
}
}
/**
* specified PrintStream.
*
* <p>
* This method could be used to trigger XJC from other tools,
* such as Ant or IDE.
*
* @param args
* specified command line parameters. If there is an error
* in the parameters, {@link BadCommandLineException} will
* be thrown.
* @param listener
*
* @return
* If the compiler runs successfully, this method returns 0.
* All non-zero values indicate an error. The error message
* will be sent to the specified PrintStream.
*/
public static int run(String[] args, @NotNull final XJCListener listener) throws BadCommandLineException {
// recognize those special options before we start parsing options.
return -1;
}
return -1;
}
}
try {
} catch (WeAreDone _) {
return -1;
} catch(BadCommandLineException e) {
e.initOptions(opt);
throw e;
}
// display a warning if the user specified the default package
// this should work, but is generally a bad idea
listener.message(Messages.format(Messages.WARNING_MSG, Messages.format(Messages.DEFAULT_PACKAGE_WARNING)));
}
// set up the context class loader so that the user-specified classes
// can be loaded from there
// parse a grammar file
//-----------------------------------------
try {
}
final boolean[] hadWarning = new boolean[1];
}
hadWarning[0] = true;
}
public void pollAbort() throws AbortException {
if(listener.isCanceled())
throw new AbortException();
}
};
// dump DOM forest and quit
try {
return 0;
} catch (SAXException e) {
// the error should have already been reported
} catch (IOException e) {
}
return -1;
}
try {
if(p==null) continue;
}
return 0;
} catch (SAXException e) {
// the error should have already been reported
}
return -1;
}
return -1;
}
}
case SIGNATURE :
try {
return 0;
} catch (IOException e) {
return -1;
}
case CODE :
case DRYRUN :
case ZIP :
{
// generate actual code
{// don't want to hold outline in memory for too long.
return -1;
}
}
break; // enough
// then print them out
try {
else
} else
}
} catch (IOException e) {
return -1;
}
break;
}
default :
assert false;
}
try {
} catch (IOException e) {
return -1;
}
}
return 0;
} catch( StackOverflowError e ) {
// in the debug mode, propagate the error so that
// the full stack trace will be dumped to the screen.
throw e;
else {
// otherwise just print a suggested workaround and
// quit without filling the user's screen
return -1;
}
}
}
}
/**
* Operation mode.
*/
private static enum Mode {
// normal mode. compile the code
CODE,
// dump the signature of the generated code
// dump DOMForest
// same as CODE but don't produce any Java source code
// same as CODE but pack all the outputs into a zip and dumps to stdout
ZIP,
// testing a new binding mode
}
/**
* Command-line arguments processor.
*
* <p>
* This class contains options that only make sense
* for the command line interface.
*/
{
/** Operation mode. */
/** A switch that determines the behavior in the BGM mode. */
public boolean noNS = false;
/** Parse XJC-specific options. */
noNS = true;
return 1;
}
i++;
throw new BadCommandLineException(
mode = m;
return 2;
}
}
throw new BadCommandLineException(
}
usage(this,false);
throw new WeAreDone();
}
usage(this,true);
throw new WeAreDone();
}
return super.parseArgument(args, i);
}
}
/**
* Used to signal that we've finished processing.
*/
/**
* Prints the usage screen and exits the process.
*
* @param opts
* If the parsing of options have started, set a partly populated
* {@link Options} object.
*/
if (privateUsage) {
}
}
}
}
}