package org.apache.fop.apps;
-// FOP
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.apache.fop.configuration.Configuration;
import org.apache.fop.fo.FOTree;
import org.apache.fop.layout.AreaTree;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.version.Version;
import org.apache.fop.xml.FoXmlSerialHandler;
import org.apache.fop.xml.Namespaces;
public class Driver {
/** If true, full error stacks are reported */
private static boolean _errorDump = false;
-
+
private InputHandler inputHandler;
private XMLReader parser;
private InputSource saxSource;
_errorDump =
Configuration.getBooleanValue("debugMode").booleanValue();
String version = Version.getVersion();
- MessageHandler.logln(version);
+ Fop.logger.config(version);
}
/**
package org.apache.fop.apps;
-import org.apache.fop.messaging.MessageHandler;
+import java.util.logging.Logger;
public class Fop {
public static long startTime;
public static long startPCi;
public static long endPCi;
+
+ protected static final Logger logger = Logger.getLogger("org.apache.fop");
public static void main(String[] args) {
//System.out.println("PC time : " + (endPCi - startPCi));
} catch (FOPException e) {
- MessageHandler.errorln("ERROR: " + e.getMessage());
+ logger.warning(e.getMessage());
if ((bool = Options.isDebugMode()) != null
&& bool.booleanValue()) {
e.printStackTrace();
}
} catch (java.io.FileNotFoundException e) {
- MessageHandler.errorln("ERROR: " + e.getMessage());
+ logger.warning(e.getMessage());
if ((bool = Options.isDebugMode()) != null
&& bool.booleanValue()) {
e.printStackTrace();
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
-import org.apache.fop.messaging.MessageHandler;
-
abstract public class InputHandler {
abstract public InputSource getInputSource();
abstract public XMLReader getParser() throws FOPException;
-
/**
* create an InputSource from a File
*
if (parserClassName == null) {
parserClassName = "org.apache.xerces.parsers.SAXParser";
}
- MessageHandler.logln("using SAX parser " + parserClassName);
+ Fop.logger.config("using SAX parser " + parserClassName);
try {
return (XMLReader)Class.forName(parserClassName).newInstance();
import java.util.HashMap;
import java.util.Set;
import java.util.Iterator;
-
+import java.util.logging.Level;
// fop
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.configuration.Configuration;
import org.apache.fop.configuration.ConfigurationReader;
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
} catch (Exception e) {}
}
if (debug) {
- MessageHandler.logln("base directory: " + baseDir);
+ Fop.logger.config("base directory: " + baseDir);
}
if (dumpConfig) {
// quiet mode - this is the last setting, so there is no way to
// supress the logging of messages during options processing
if ((bool = isQuiet()) != null) {
- MessageHandler.setQuiet(bool.booleanValue());
+ if (bool.booleanValue()) {
+ Fop.logger.setLevel(Level.OFF);
+ }
}
}
getConfResourceFile(fname, ConfigurationReader.class);
if (debug) {
- MessageHandler.logln(
+ Fop.logger.config(
"reading configuration file " + fname);
}
ConfigurationReader reader =
boolean readOk = true;
userConfigFile = new File(userConfigFileName);
if (userConfigFile != null) {
- MessageHandler.logln(
+ Fop.logger.config(
"reading user configuration file " + userConfigFileName);
ConfigurationReader reader = new ConfigurationReader(
InputHandler.fileInputSource(userConfigFile));
try {
reader.start();
} catch (org.apache.fop.apps.FOPException error) {
- MessageHandler.logln(
+ Fop.logger.config(
"Can't find user configuration file "
+ userConfigFile + " in user locations");
if (debug) {
// Try reading the file using loadConfig()
loadConfiguration(userConfigFileName);
} catch (FOPException ex) {
- MessageHandler.logln("Can't find user configuration file "
+ Fop.logger.warning("Can't find user configuration file "
+ userConfigFile + " in system locations");
if (debug) {
reader.dumpError(ex);
// warning if foFile has been set in xslt mode
if (foFile != null) {
- MessageHandler.errorln(
- "WARNING: "
- + "Can't use fo file with transform mode! Ignoring.\n"
+ Fop.logger.warning(
+ "Can't use fo file with transform mode! Ignoring.\n"
+ "Your input is " + "\n xmlFile: "
+ xmlFile.getAbsolutePath()
+ "\nxsltFile: "
} else if (inputmode == FO_INPUT) {
if (xmlFile != null || xsltFile != null) {
- MessageHandler.errorln(
- "WARNING: fo input mode, but xmlFile or xslt file are set:"
+ Fop.logger.warning(
+ "fo input mode, but xmlFile or xslt file are set:"
);
- MessageHandler.errorln("xml file: " + xmlFile.toString());
- MessageHandler.errorln("xslt file: " + xsltFile.toString());
+ Fop.logger.warning("xml file: " + xmlFile.toString());
+ Fop.logger.warning("xslt file: " + xsltFile.toString());
}
if (!foFile.exists()) {
throw new FileNotFoundException("fo file "
* options and some examples
*/
public static void printUsage() {
- MessageHandler.errorln(
+ Fop.logger.info(
"\nUSAGE\n"
+ "Fop [options] [-fo|-xml] infile [-xsl file] "
+ "[-awt|-pdf|-mif|-pcl|-ps|-txt|-at|-print] [outputFile]\n"
* shows the options for print output
*/
public static void printUsagePrintOutput() {
- MessageHandler.errorln(
+ Fop.logger.info(
"USAGE:"
+ " -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false]"
+ " org.apache.fop.apps.Fop (..) -print \n"
System.out.print("Input mode: ");
switch (inputmode) {
case NOT_SET:
- MessageHandler.logln("not set");
+ Fop.logger.config("not set");
break;
case FO_INPUT:
- MessageHandler.logln("fo ");
- MessageHandler.logln("fo input file: " + foFile.toString());
+ Fop.logger.config("fo ");
+ Fop.logger.config("fo input file: " + foFile.toString());
break;
default:
- MessageHandler.logln("unknown input type");
+ Fop.logger.config("unknown input type");
}
System.out.print("Output mode: ");
switch (outputmode) {
case NOT_SET:
- MessageHandler.logln("not set");
+ Fop.logger.config("not set");
break;
case PDF_OUTPUT:
- MessageHandler.logln("pdf");
- MessageHandler.logln("output file: " + outputFile.toString());
+ Fop.logger.config("pdf");
+ Fop.logger.config("output file: " + outputFile.toString());
break;
default:
- MessageHandler.logln("unknown input type");
+ Fop.logger.config("unknown input type");
}
- MessageHandler.logln("OPTIONS");
+ Fop.logger.config("OPTIONS");
if (userConfigFile != null) {
- MessageHandler.logln("user configuration file: "
+ Fop.logger.config("user configuration file: "
+ userConfigFile.toString());
} else {
- MessageHandler.logln(
+ Fop.logger.config(
"no user configuration file is used [default]");
}
if ((bool = isDebugMode()) != null && bool.booleanValue()) {
- MessageHandler.logln("debug mode on");
+ Fop.logger.config("debug mode on");
} else {
- MessageHandler.logln("debug mode off [default]");
+ Fop.logger.config("debug mode off [default]");
}
if ((bool = doDumpConfiguration()) != null && bool.booleanValue()) {
- MessageHandler.logln("dump configuration");
+ Fop.logger.config("dump configuration");
} else {
- MessageHandler.logln("don't dump configuration [default]");
+ Fop.logger.config("don't dump configuration [default]");
}
if ((bool = isCoarseAreaXml()) != null && bool.booleanValue()) {
- MessageHandler.logln("no low level areas");
+ Fop.logger.config("no low level areas");
} else {
- MessageHandler.logln("low level areas generated[default]");
+ Fop.logger.config("low level areas generated[default]");
}
if ((bool = isQuiet()) != null && bool.booleanValue()) {
- MessageHandler.logln("quiet mode on");
+ Fop.logger.config("quiet mode on");
} else {
- MessageHandler.logln("quiet mode off [default]");
+ Fop.logger.config("quiet mode off [default]");
}
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import org.apache.fop.messaging.MessageHandler;
+import java.util.logging.Logger;
/**
* a configuration class for all general configuration aspects except those
*/
public class Configuration {
+ protected static final Logger logger = Logger.getLogger("org.apache.fop");
/**
* defines role types
*/
awtConfiguration = config;
break;
default:
- MessageHandler.errorln(
+ logger.warning(
"Can't setup configuration. Unknown configuration role/target"
);
}
break;
default:
standardConfiguration.put(key, value);
- MessageHandler.errorln("Unknown role for new configuration entry."
+ logger.warning("Unknown role for new configuration entry."
+ " Putting key:" + key + " - value:"
+ value + " into standard configuration.");
}
standardConfiguration, pdfConfiguration, awtConfiguration
};
for (int i = 0; i < configs.length; i++) {
- MessageHandler.logln("----------------------");
+ logger.config("----------------------");
configuration = configs[i];
Iterator iter = configuration.keySet().iterator();
while (iter.hasNext()) {
key = (String)iter.next();
- MessageHandler.logln("key: " + key);
+ logger.config("key: " + key);
value = configuration.get(key);
if (value instanceof String) {
- MessageHandler.logln(" value: " + value);
+ logger.config(" value: " + value);
} else if (value instanceof Boolean) {
- MessageHandler.logln
+ logger.config
(" value: " + ((Boolean)value).booleanValue());
} else if (value instanceof Integer) {
- MessageHandler.logln
+ logger.config
(" value: " + ((Integer)value).intValue());
} else if (value instanceof ArrayList) {
list = (ArrayList)value;
iterator = list.iterator();
- MessageHandler.log(" values: ");
+ StringBuffer msg = new StringBuffer(" values: ");
while (iterator.hasNext()) {
- MessageHandler.log(iterator.next() + " - ");
+ msg.append(iterator.next() + " - ");
}
- MessageHandler.logln("");
+ logger.config(msg.toString());
} else if (value instanceof HashMap) {
map = (HashMap)value;
iterator = map.keySet().iterator();
- MessageHandler.log(" values: ");
+ StringBuffer msg = new StringBuffer(" values: ");
while (iterator.hasNext()) {
tmp = (String)iterator.next();
- MessageHandler.log(" " + tmp + ":" + map.get(tmp));
+ msg.append(" " + tmp + ":" + map.get(tmp));
}
- MessageHandler.logln("");
+ logger.config(msg.toString());
}
}
}
import java.util.HashMap;
import java.util.ArrayList;
-// fop
-import org.apache.fop.messaging.MessageHandler;
-
/**
* SAX2 Handler which retrieves the configuration information and stores them in Configuration.
fontTriplets.add(fontTriplet);
} else {
// to make sure that user knows about false tag
- MessageHandler.errorln("Unknown tag in configuration file: "
+ Configuration.logger.warning("Unknown tag in configuration file: "
+ localName);
}
} // end startElement
if (activeConfiguration != null) {
activeConfiguration.put(key, value);
} else {
- MessageHandler.errorln("Unknown role >" + role
+ Configuration.logger.warning("Unknown role >" + role
+ "< for new configuration entry. \n"
+ "Putting configuration with key:" + key
+ " into standard configuration.");
// fop
import org.apache.fop.apps.Driver;
-import org.apache.fop.messaging.MessageHandler;
import org.apache.fop.apps.FOPException;
/**
public static XMLReader createParser() throws FOPException {
String parserClassName = Driver.getParserClassName();
if (errorDump) {
- MessageHandler.logln("configuration reader using SAX parser "
+ Configuration.logger.config(
+ "configuration reader using SAX parser "
+ parserClassName);
}