Browse Source

1.) Moved the business logic for determining which starter to create from apps.CommandLineOptions to apps.Fop; CLO is now Starter-free.

2.) Made the input and output type constants in CLO public, to make the CLO.getOutputMode() and CLO.getInputMode() accessor functions meaningful.  (Should probably make uniform with the very similar constants in the Driver class in the future.)


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196760 13f79535-47bb-0310-9956-ffa450edef68
pull/30/head
Glen Mazza 21 years ago
parent
commit
6c8c8d50c2

+ 13
- 37
src/java/org/apache/fop/apps/CommandLineOptions.java View File

public class CommandLineOptions { public class CommandLineOptions {


/* input / output not set */ /* input / output not set */
private static final int NOT_SET = 0;
public static final int NOT_SET = 0;
/* input: fo file */ /* input: fo file */
private static final int FO_INPUT = 1;
public static final int FO_INPUT = 1;
/* input: xml+xsl file */ /* input: xml+xsl file */
private static final int XSLT_INPUT = 2;
public static final int XSLT_INPUT = 2;
/* output: pdf file */ /* output: pdf file */
private static final int PDF_OUTPUT = 1;
public static final int PDF_OUTPUT = 1;
/* output: screen using swing */ /* output: screen using swing */
private static final int AWT_OUTPUT = 2;
public static final int AWT_OUTPUT = 2;
/* output: mif file */ /* output: mif file */
private static final int MIF_OUTPUT = 3;
public static final int MIF_OUTPUT = 3;
/* output: sent swing rendered file to printer */ /* output: sent swing rendered file to printer */
private static final int PRINT_OUTPUT = 4;
public static final int PRINT_OUTPUT = 4;
/* output: pcl file */ /* output: pcl file */
private static final int PCL_OUTPUT = 5;
public static final int PCL_OUTPUT = 5;
/* output: postscript file */ /* output: postscript file */
private static final int PS_OUTPUT = 6;
public static final int PS_OUTPUT = 6;
/* output: text file */ /* output: text file */
private static final int TXT_OUTPUT = 7;
public static final int TXT_OUTPUT = 7;
/* output: svg file */ /* output: svg file */
private static final int SVG_OUTPUT = 8;
public static final int SVG_OUTPUT = 8;
/* output: XML area tree */ /* output: XML area tree */
private static final int AREA_OUTPUT = 9;
public static final int AREA_OUTPUT = 9;
/* output: RTF file */ /* output: RTF file */
private static final int RTF_OUTPUT = 10;
public static final int RTF_OUTPUT = 10;


/* show configuration information */ /* show configuration information */
private Boolean dumpConfiguration = Boolean.FALSE; private Boolean dumpConfiguration = Boolean.FALSE;
return rendererOptions; return rendererOptions;
} }


/**
* Get the starter for the process.
* @return the starter.
* @throws FOPException In case of failure while getting the starter
*/
public Starter getStarter() throws FOPException {
Starter starter = null;
switch (outputmode) {
case AWT_OUTPUT:
try {
starter = new AWTStarter(this);
} catch (FOPException e) {
throw e;
} catch (Exception e) {
throw new FOPException("AWTStarter could not be loaded.", e);
}
break;
default:
starter = new CommandLineStarter(this);
}
starter.enableLogging(log);
return starter;
}

/** /**
* Returns the input mode (type of input data, ex. NOT_SET or FO_INPUT) * Returns the input mode (type of input data, ex. NOT_SET or FO_INPUT)
* @return the input mode * @return the input mode

+ 9
- 1
src/java/org/apache/fop/apps/Fop.java View File

*/ */
package org.apache.fop.apps; package org.apache.fop.apps;


import org.apache.avalon.framework.logger.ConsoleLogger;

/** /**
* The main application class for the FOP command line interface (CLI). * The main application class for the FOP command line interface (CLI).
*/ */
*/ */
public static void main(String[] args) { public static void main(String[] args) {
CommandLineOptions options = null; CommandLineOptions options = null;
Starter starter = null;


try { try {
options = new CommandLineOptions(args); options = new CommandLineOptions(args);
Starter starter = options.getStarter();
if (options.getOutputMode() == CommandLineOptions.AWT_OUTPUT) {
starter = new AWTStarter(options);
} else {
starter = new CommandLineStarter(options);
}
starter.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_INFO));
starter.run(); starter.run();
} catch (FOPException e) { } catch (FOPException e) {
if (e.getMessage() == null) { if (e.getMessage() == null) {

Loading…
Cancel
Save