aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/hyphenation
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-10-07 15:09:38 +0000
committerJeremias Maerki <jeremias@apache.org>2005-10-07 15:09:38 +0000
commit19ac0323da85dc9b1c8e4be8e8cf2f7a89d45563 (patch)
tree1bd669c627e301310f6a14571df8ecc78bad9d86 /src/java/org/apache/fop/hyphenation
parent8ab0104a0e8f17b8ad472cc999f9a87f6d569c59 (diff)
downloadxmlgraphics-fop-19ac0323da85dc9b1c8e4be8e8cf2f7a89d45563.tar.gz
xmlgraphics-fop-19ac0323da85dc9b1c8e4be8e8cf2f7a89d45563.zip
Log failure to load a hyphenation file.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@307144 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/hyphenation')
-rw-r--r--src/java/org/apache/fop/hyphenation/Hyphenator.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java
index 1e8c52e66..4d4a1d03e 100644
--- a/src/java/org/apache/fop/hyphenation/Hyphenator.java
+++ b/src/java/org/apache/fop/hyphenation/Hyphenator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.util.Hashtable;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class is the main entry point to the hyphenation package.
@@ -34,8 +38,13 @@ import java.util.Hashtable;
*/
public class Hyphenator {
+ /** logging instance */
+ protected static Log log = LogFactory.getLog(Hyphenator.class);
+
/**@todo Don't use statics */
private static Hashtable hyphenTrees = new Hashtable();
+ /** Used to avoid multiple error messages for the same language if a pattern file is missing. */
+ private static Set missingHyphenationTrees;
private HyphenationTree hyphenTree = null;
private int remainCharCount = 2;
@@ -56,6 +65,10 @@ public class Hyphenator {
if (country != null && !country.equals("none")) {
key += "_" + country;
}
+ // See if there was an error finding this hyphenation tree before
+ if (missingHyphenationTrees != null && missingHyphenationTrees.contains(key)) {
+ return null;
+ }
// first try to find it in the cache
if (hyphenTrees.containsKey(key)) {
return (HyphenationTree)hyphenTrees.get(key);
@@ -75,9 +88,11 @@ public class Hyphenator {
if (hTree != null) {
hyphenTrees.put(key, hTree);
} else {
- /**@todo Proper logging please */
- //log.error("Couldn't find hyphenation pattern "
- // + key);
+ log.error("Couldn't find hyphenation pattern " + key);
+ if (missingHyphenationTrees == null) {
+ missingHyphenationTrees = new java.util.HashSet();
+ }
+ missingHyphenationTrees.add(key);
}
return hTree;
}
@@ -177,8 +192,7 @@ public class Hyphenator {
new FileInputStream(hyphenFile)));
hTree = (HyphenationTree)ois.readObject();
} catch (Exception e) {
- /**@todo Proper logging please */
- e.printStackTrace();
+ log.error("Error while loading the hyphenation file", e);
} finally {
if (ois != null) {
try {