cvs commit: xml-fop/src/org/apache/fop/apps Options.java
pbwest 2002/11/01 18:02:30 Modified:src/org/apache/fop/apps Tag: FOP_0-20-0_Alt-Design Options.java Log: Removed languages config file handling. Revision ChangesPath No revision No revision 1.9.4.2 +3 -40 xml-fop/src/org/apache/fop/apps/Attic/Options.java Index: Options.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Attic/Options.java,v retrieving revision 1.9.4.1 retrieving revision 1.9.4.2 diff -u -r1.9.4.1 -r1.9.4.2 --- Options.java 7 May 2002 04:52:35 - 1.9.4.1 +++ Options.java 2 Nov 2002 02:02:30 - 1.9.4.2 @@ -22,7 +22,6 @@ import org.apache.fop.messaging.MessageHandler; import org.apache.fop.configuration.Configuration; import org.apache.fop.configuration.ConfigurationReader; -import org.apache.fop.configuration.LanguageFileReader; /** * Options handles loading of configuration files and @@ -221,7 +220,7 @@ * effect of command line parsing. * * The standard configuration file has been read and its contents - * stored in the Configuration HahMaps. If a user configuration file + * stored in the Configuration HashMaps. If a user configuration file * was specified in the command line arguments, or, failing that, in * the standard configuration file, it had been read and its contents * have overridden the Configuration maps. @@ -278,9 +277,6 @@ MessageHandler.logln("base directory: " + baseDir); } -if ((str = Configuration.getStringValue("languageConfigFileName")) -!= null) loadLanguagesConfig(str); - if (dumpConfig) { Configuration.dumpConfiguration(); System.exit(0); @@ -319,7 +315,7 @@ /** * Convenience class for common functionality required by the config - * files and the language files. + * files. * @param Class object of requesting class. * @return an InputStream generated through a call to * getResourceAsStream on the context ClassLoader @@ -420,39 +416,6 @@ loadConfiguration(userConfigFileName); } } -} - -/** - * Loads language configuration file from a system standard place. - * The context class loader and the ConfigurationReader - * class loader are asked in turn to getResourceAsStream - * on fname from a directory called conf. - * If the languages configuration file is found, the results of reading - * the file are stored in Configation as HashMaps under three - * keys: - * languagesMap, countriesMap and - * scriptsMap. - * - * @param fname the name of the configuration file to load. - * @exception org.apache.fop.fo.FOPException if the configuration file - * cannot be discovered. - */ -public static void loadLanguagesConfig(String fname) -throws FOPException { -InputStream configfile = -getConfResourceFile(fname, LanguageFileReader.class); - -if (debug) { -MessageHandler.logln( -"reading language configuration file " + fname); -} -LanguageFileReader reader = -new LanguageFileReader(new InputSource(configfile)); -reader.start(); -// Now add the HashMaps to the Configuration -Configuration.put("languagesMap", reader.getLanguagesHashMap()); -Configuration.put("countriesMap", reader.getCountriesHashMap()); -Configuration.put("scriptsMap", reader.getScriptsHashMap()); } /** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/apps Options.java
pbwest 02/05/06 21:52:35 Modified:src/org/apache/fop/apps Tag: FOP_0-20-0_Alt-Design Options.java Log: Options merged with CommandLineOptions for experimental development. Revision ChangesPath No revision No revision 1.9.4.1 +813 -77 xml-fop/src/org/apache/fop/apps/Options.java Index: Options.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Options.java,v retrieving revision 1.9 retrieving revision 1.9.4.1 diff -u -r1.9 -r1.9.4.1 --- Options.java 10 Aug 2001 08:18:43 - 1.9 +++ Options.java 7 May 2002 04:52:35 - 1.9.4.1 @@ -1,5 +1,5 @@ /* - * $Id: Options.java,v 1.9 2001/08/10 08:18:43 keiron Exp $ + * $Id: Options.java,v 1.9.4.1 2002/05/07 04:52:35 pbwest Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -12,101 +12,322 @@ // java import java.io.File; +import java.io.FileNotFoundException; import java.io.InputStream; +import java.util.HashMap; +import java.util.Set; +import java.util.Iterator; // fop import org.apache.fop.messaging.MessageHandler; import org.apache.fop.configuration.Configuration; import org.apache.fop.configuration.ConfigurationReader; +import org.apache.fop.configuration.LanguageFileReader; /** * Options handles loading of configuration files and * additional setting of commandline options */ public class Options { -boolean errorDump = false; -public Options() throws FOPException { -this.loadStandardConfiguration(); -initOptions(); +/** + * Render to PDF. OutputStream must be set + */ +public static final int RENDER_PDF = 1; + +/* input / output 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; +private static final int LAST_INPUT_MODE = XSLT_INPUT; + +/* output: pdf file */ +private static final int PDF_OUTPUT = 1; +private static final int LAST_OUTPUT_MODE = PDF_OUTPUT; + +private static final String defaultConfigFile = "config.xml"; +private static final String defaultUserConfigFile = "userconfig.xml"; +/** + * An array of String indexed by the integer constants representing + * the various input modes. Provided so that integer modes can be + * mapped to a more descriptive string, and vice versa. + */ +public static final String[] inputModes; +/** + * An array of String indexed by the integer constants representing + * the various output modes. Provided so that integer modes can be + * mapped to a more descriptive string, and vice versa. + */ +public static final String[] outputModes; + +static { +inputModes = new String[LAST_INPUT_MODE + 1]; +inputModes[NOT_SET] = "NotSet"; +inputModes[FO_INPUT] = "fo"; +inputModes[XSLT_INPUT] = "xslt"; + +outputModes = new String[LAST_OUTPUT_MODE + 1]; +outputModes[NOT_SET] = "NotSet"; +outputModes[PDF_OUTPUT] = "pdf"; } -public Options(File userConfigFile) throws FOPException { -this(); -this.loadUserconfiguration(userConfigFile); +/** + * @param mode the mode whose index in the array inputModes is to be + * returned. + * @return the int index of the mode string in the array, or -1 if the + * mode string is not found in the array + */ +public static int inputModeIndex(String mode) +throws FOPException { +for (int i = 0; i <= LAST_INPUT_MODE; i++) { +if (inputModes[i] != null) +if (mode.equals(inputModes[i])) +return i; +} +throw new FOPException("Input mode " + mode + " not known"); } -public Options(CommandLineOptions clOptions) throws FOPException { -this(); -this.setCommandLineOptions(clOptions); +/** + * @param mode the mode whose index in the array outputModes is to be + * returned. + * @return the int index of the mode string in the array, or -1 if the + * mode string is not found in the array + */ +public static int outputModeIndex(String mode) +throws FOPException { +for (int i = 0; i <= LAST_INPUT_MODE; i++) { +if (outputModes[i] != null) +if (mode.equals(outputModes[i])) +return i; +} +throw new FOPException("Output mod
cvs commit: xml-fop/src/org/apache/fop/apps Options.java
keiron 01/08/10 01:18:43 Modified:src/org/apache/fop/apps Options.java Log: improved error message a bit if config couldn't be loaded Revision ChangesPath 1.9 +4 -3 xml-fop/src/org/apache/fop/apps/Options.java Index: Options.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Options.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Options.java 2001/07/30 20:29:18 1.8 +++ Options.java 2001/08/10 08:18:43 1.9 @@ -1,5 +1,5 @@ /* - * $Id: Options.java,v 1.8 2001/07/30 20:29:18 tore Exp $ + * $Id: Options.java,v 1.9 2001/08/10 08:18:43 keiron Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -158,8 +158,9 @@ try { reader.start(); } catch (org.apache.fop.apps.FOPException error) { -MessageHandler.errorln("Can't find user configuration file " - + userConfigFile); +MessageHandler.errorln("Could not load user configuration file " + + userConfigFile + " - error: " + + error.getMessage()); MessageHandler.errorln("using default values"); if (errorDump) { reader.dumpError(error); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/apps Options.java
keiron 01/07/04 06:53:31 Modified:src/org/apache/fop/apps Options.java Log: fixed error where configfile was not being set Revision ChangesPath 1.7 +91 -92xml-fop/src/org/apache/fop/apps/Options.java Index: Options.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Options.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Options.java 2001/07/04 12:40:42 1.6 +++ Options.java 2001/07/04 13:53:28 1.7 @@ -1,10 +1,9 @@ -/* +/* $Id: Options.java,v 1.7 2001/07/04 13:53:28 keiron Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ - package org.apache.fop.apps; //sax @@ -18,89 +17,88 @@ import org.apache.fop.messaging.MessageHandler; import org.apache.fop.configuration.Configuration; import org.apache.fop.configuration.ConfigurationReader; - + /** - * Options handles loading of configuration files and + * Options handles loading of configuration files and * additional setting of commandline options */ public class Options { - boolean errorDump = false; - -public Options () - throws FOPException -{ - this.loadStandardConfiguration(); - initOptions (); +boolean errorDump = false; + +public Options () throws FOPException { +this.loadStandardConfiguration(); +initOptions (); } - -public Options (File userConfigFile) - throws FOPException -{ - this(); - this.loadUserconfiguration(userConfigFile); + +public Options (File userConfigFile) throws FOPException { +this(); +this.loadUserconfiguration(userConfigFile); } - -public Options (CommandLineOptions clOptions) - throws FOPException +public Options (CommandLineOptions clOptions) throws FOPException { - this(); - this.setCommandLineOptions(clOptions); +this(); +this.setCommandLineOptions(clOptions); } - -//initializing option settings + +//initializing option settings void initOptions () { - if (Configuration.getBooleanValue("quiet").booleanValue()) { - MessageHandler.setQuiet(true); - } - if (Configuration.getBooleanValue("debugMode").booleanValue()) { - errorDump = true; - } -if (Configuration.getBooleanValue("dumpConfiguration").booleanValue()) { - Configuration.put("dumpConfiguration","true"); - Configuration.dumpConfiguration(); - } +if (Configuration.getBooleanValue("quiet").booleanValue()) { +MessageHandler.setQuiet(true); +} +if (Configuration.getBooleanValue("debugMode").booleanValue()) { +errorDump = true; +} +if (Configuration.getBooleanValue( + "dumpConfiguration").booleanValue()) { +Configuration.put("dumpConfiguration","true"); +Configuration.dumpConfiguration(); +} } - + //setting clOptions void setCommandLineOptions(CommandLineOptions clOptions) { - //load user configuration file,if there is one - File userConfigFile = clOptions.getUserConfigFile(); +//load user configuration file,if there is one +File userConfigFile = clOptions.getUserConfigFile(); if (userConfigFile != null) { this.loadUserconfiguration(userConfigFile); } - + //debug mode - if (clOptions.isDebugMode() != null) { - errorDump = clOptions.isDebugMode().booleanValue(); - Configuration.put("debugMode",new Boolean(errorDump)); - } - - //show configuration settings - boolean dumpConfiguration; - if (clOptions.dumpConfiguration() != null) { - dumpConfiguration = clOptions.dumpConfiguration().booleanValue(); - } else { - dumpConfiguration = Configuration.getBooleanValue("dumpConfiguration").booleanValue(); - } -if (dumpConfiguration) { - Configuration.put("dumpConfiguration","true"); - Configuration.dumpConfiguration(); +if (clOptions.isDebugMode() != null) { +errorDump = clOptions.isDebugMode().booleanValue(); +Configuration.put("debugMode",new Boolean(errorDump)); +} + +//show configuration settings +boolean dumpConfiguration; +if (
cvs commit: xml-fop/src/org/apache/fop/apps Options.java
keiron 01/06/05 05:55:20 Modified:src/org/apache/fop/apps Options.java Log: sets baseDir to a URL string rather than a file path string Revision ChangesPath 1.4 +5 -2 xml-fop/src/org/apache/fop/apps/Options.java Index: Options.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Options.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Options.java 2001/04/12 00:12:43 1.3 +++ Options.java 2001/06/05 12:55:18 1.4 @@ -98,8 +98,11 @@ //set base directory String baseDir = Configuration.getStringValue("baseDir"); if (baseDir == null) { -baseDir = new File(clOptions.getInputFile().getAbsolutePath()).getParent(); -Configuration.put("baseDir",baseDir); +try { +baseDir = new File(clOptions.getInputFile().getAbsolutePath()).getParentFile().toURL().toExternalForm(); +Configuration.put("baseDir", baseDir); +} catch(Exception e) { +} } if (errorDump) { MessageHandler.logln("base directory: " + baseDir); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]