Revision: 7786
Author: victormote
Date: 2006-07-15 16:51:05 -0700 (Sat, 15 Jul 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=7786&view=rev
Log Message:
-----------
Minor refactoring and documentation.
Modified Paths:
--------------
trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java
Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-07-15 23:38:12 UTC (rev 7785)
+++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-07-15 23:51:05 UTC (rev 7786)
@@ -45,28 +45,37 @@
*/
public class CommandLineOptions {
- /* input not set */
- private static final int NOT_SET = 0;
- /* input: fo file */
- private static final int FO_INPUT = 1;
- /* input: xml+xsl file */
- private static final int XSLT_INPUT = 2;
+ /** Constant indicating that the input mode has not been set. */
+ private static final int INPUT_NOT_SET = 0;
- /* user configuration file */
- URL userConfigFile = null;
- /* input fo file */
- File fofile = null;
- /* xsltfile (xslt transformation as input) */
- File xsltfile = null;
- /* xml file (xslt transformation as input) */
- File xmlfile = null;
- /* output file */
+ /** Constant indicating that the input is XSL-FO. */
+ private static final int INPUT_FO = 1;
+
+ /** Constant indicating that the input is XML + XSLT. */
+ private static final int INPUT_XSLT = 2;
+
+ /** The user configuration file. */
+ URL userConfig = null;
+
+ /** The input XSL-FO. Should be null for XSLT input. */
+ File foInput = null;
+
+ /** The input XSLT. Should be null for XSL-FO input. */
+ File xsltInput = null;
+
+ /** The input XML file. Should be null for XSL-FO input. */
+ File xmlInput = null;
+
+ /** The output file. */
public File outfile = null;
- /* input mode */
- int inputmode = NOT_SET;
- /* output mode */
- int outputmode = NOT_SET;
- /* language for user information */
+
+ /** The input mode. */
+ int inputmode = INPUT_NOT_SET;
+
+ /** The output mode. */
+ int outputmode = INPUT_NOT_SET;
+
+ /** Language for user information */
String language = null;
private SessionConfig sessionConfig;
@@ -142,7 +151,7 @@
+ "specify the name of the configuration file");
}
try {
- this.userConfigFile = URLFactory.createURL(
+ this.userConfig = URLFactory.createURL(
args[currentArgument + 1]);
} catch (MalformedURLException e) {
throw new FOrayException(e);
@@ -158,15 +167,15 @@
return success;
}
if (args[currentArgument].equals("-fo")) {
- inputmode = FO_INPUT;
+ inputmode = INPUT_FO;
if ((currentArgument + 1 == args.length)
|| (args[currentArgument + 1].charAt(0) == '-')) {
throw new FOrayException("you must specify the fo file "
+ "for the '-fo' option");
}
- fofile = new File(args[currentArgument + 1]);
+ foInput = new File(args[currentArgument + 1]);
try {
- this.sessionConfig.setBaseDocument(fofile.toURL());
+ this.sessionConfig.setBaseDocument(foInput.toURL());
} catch (MalformedURLException e) {
// Ignore.
}
@@ -174,26 +183,26 @@
return true;
}
if (args[currentArgument].equals("-xsl")) {
- inputmode = XSLT_INPUT;
+ inputmode = INPUT_XSLT;
if ((currentArgument + 1 == args.length)
|| (args[currentArgument + 1].charAt(0) == '-')) {
throw new FOrayException("you must specify the stylesheet "
+ "file for the '-xsl' option");
}
- xsltfile = new File(args[currentArgument + 1]);
+ xsltInput = new File(args[currentArgument + 1]);
currentArgument++;
return true;
}
if (args[currentArgument].equals("-xml")) {
- inputmode = XSLT_INPUT;
+ inputmode = INPUT_XSLT;
if ((currentArgument + 1 == args.length)
|| (args[currentArgument + 1].charAt(0) == '-')) {
throw new FOrayException("you must specify the input file "
+ "for the '-xml' option");
}
- xmlfile = new File(args[currentArgument + 1]);
+ xmlInput = new File(args[currentArgument + 1]);
try {
- this.sessionConfig.setBaseDocument(xmlfile.toURL());
+ this.sessionConfig.setBaseDocument(xmlInput.toURL());
} catch (MalformedURLException e) {
// Ignore.
}
@@ -282,10 +291,10 @@
return true;
}
if (args[currentArgument].charAt(0) != '-') {
- if (inputmode == NOT_SET) {
- inputmode = FO_INPUT;
- fofile = new File(args[currentArgument]);
- } else if (outputmode == NOT_SET) {
+ if (inputmode == INPUT_NOT_SET) {
+ inputmode = INPUT_FO;
+ foInput = new File(args[currentArgument]);
+ } else if (outputmode == INPUT_NOT_SET) {
outputmode = OutputTargetFactory.RENDER_PDF;
outfile = new File(args[currentArgument]);
} else {
@@ -334,7 +343,7 @@
}
private void setOutputMode(int mode) throws FOrayException {
- if (outputmode == NOT_SET) {
+ if (outputmode == INPUT_NOT_SET) {
outputmode = mode;
} else {
throw new FOrayException("you can only set one output method");
@@ -346,55 +355,55 @@
* way
*/
private void checkSettings() throws FOrayException, FileNotFoundException {
- if (inputmode == NOT_SET) {
+ if (inputmode == INPUT_NOT_SET) {
throw new FOrayException("No input file specified");
}
- if (outputmode == NOT_SET) {
+ if (outputmode == INPUT_NOT_SET) {
throw new FOrayException("No output file specified");
}
- if (inputmode == XSLT_INPUT) {
+ if (inputmode == INPUT_XSLT) {
// check whether xml *and* xslt file have been set
- if (xmlfile == null) {
+ if (xmlInput == null) {
throw new FOrayException("XML file must be specified for the "
+ "transform mode");
}
- if (xsltfile == null) {
+ if (xsltInput == null) {
throw new FOrayException("XSLT file must be specified for the "
+ "transform mode");
}
// warning if fofile has been set in xslt mode
- if (fofile != null) {
+ if (foInput != null) {
log.warn("Can't use fo file with transform mode! Ignoring.\n"
+ "Your input is " + "\n xmlfile: "
- + xmlfile.getAbsolutePath()
+ + xmlInput.getAbsolutePath()
+ "\nxsltfile: "
- + xsltfile.getAbsolutePath()
+ + xsltInput.getAbsolutePath()
+ "\n fofile: "
- + fofile.getAbsolutePath());
+ + foInput.getAbsolutePath());
}
- if (!xmlfile.exists()) {
+ if (!xmlInput.exists()) {
throw new FileNotFoundException("xml file "
- + xmlfile.getAbsolutePath()
+ + xmlInput.getAbsolutePath()
+ " not found ");
}
- if (!xsltfile.exists()) {
+ if (!xsltInput.exists()) {
throw new FileNotFoundException("xsl file "
- + xsltfile.getAbsolutePath()
+ + xsltInput.getAbsolutePath()
+ " not found ");
}
- } else if (inputmode == FO_INPUT) {
- if (xmlfile != null || xsltfile != null) {
+ } else if (inputmode == INPUT_FO) {
+ if (xmlInput != null || xsltInput != null) {
log.warn("fo input mode, but xmlfile or xslt file are set:");
- log.error("xml file: " + xmlfile.toString());
- log.error("xslt file: " + xsltfile.toString());
+ log.error("xml file: " + xmlInput.toString());
+ log.error("xslt file: " + xsltInput.toString());
}
- if (!fofile.exists()) {
+ if (!foInput.exists()) {
throw new FileNotFoundException("fo file "
- + fofile.getAbsolutePath()
+ + foInput.getAbsolutePath()
+ " not found ");
}
@@ -419,12 +428,12 @@
*/
public InputHandler getInputHandler() throws FOrayException {
switch (inputmode) {
- case FO_INPUT:
- return new FOInputHandler(log, fofile);
- case XSLT_INPUT:
- return new TraxInputHandler(log, xmlfile, xsltfile);
+ case INPUT_FO:
+ return new FOInputHandler(log, foInput);
+ case INPUT_XSLT:
+ return new TraxInputHandler(log, xmlInput, xsltInput);
default:
- return new FOInputHandler(log, fofile);
+ return new FOInputHandler(log, foInput);
}
}
@@ -478,15 +487,15 @@
}
public File getFOFile() {
- return fofile;
+ return foInput;
}
public File getXMLFile() {
- return xmlfile;
+ return xmlInput;
}
public File getXSLFile() {
- return xsltfile;
+ return xsltInput;
}
public File getOutputFile() {
@@ -494,7 +503,7 @@
}
public URL getUserConfigFile() {
- return userConfigFile;
+ return userConfig;
}
public String getLanguage() {
@@ -506,12 +515,12 @@
*/
public File getInputFile() {
switch (inputmode) {
- case FO_INPUT:
- return fofile;
- case XSLT_INPUT:
- return xmlfile;
+ case INPUT_FO:
+ return foInput;
+ case INPUT_XSLT:
+ return xmlInput;
default:
- return fofile;
+ return foInput;
}
}
@@ -591,17 +600,17 @@
}
log.debug("Input mode: ");
switch (inputmode) {
- case NOT_SET:
+ case INPUT_NOT_SET:
log.debug("not set");
break;
- case FO_INPUT:
+ case INPUT_FO:
log.debug("FO ");
- log.debug("fo input file: " + fofile.toString());
+ log.debug("fo input file: " + foInput.toString());
break;
- case XSLT_INPUT:
+ case INPUT_XSLT:
log.debug("xslt transformation");
- log.debug("xml input file: " + xmlfile.toString());
- log.debug("xslt stylesheet: " + xsltfile.toString());
+ log.debug("xml input file: " + xmlInput.toString());
+ log.debug("xslt stylesheet: " + xsltInput.toString());
break;
default:
log.debug("unknown input type");
@@ -652,9 +661,9 @@
}
log.debug("OPTIONS");
- if (userConfigFile != null) {
+ if (userConfig != null) {
log.debug("user configuration file: "
- + userConfigFile.toString());
+ + userConfig.toString());
} else {
log.debug("no user configuration file is used [default]");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|