[FOray-commit] SF.net SVN: foray: [8311] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-10-06 22:21:00
|
Revision: 8311
http://svn.sourceforge.net/foray/?rev=8311&view=rev
Author: victormote
Date: 2006-10-06 15:20:46 -0700 (Fri, 06 Oct 2006)
Log Message:
-----------
Rename three hyphenation classes to FOray-specific names to avoid confusion with the implemented interfaces.
Modified Paths:
--------------
trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java
Added Paths:
-----------
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenBreak.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenation.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenationServer.java
Removed Paths:
-------------
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java
trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java
Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -137,7 +137,8 @@
final SessionConfig configuration) {
final URL hyphenationDir =
configuration.optionHyphenationBaseDirectory();
- return new org.foray.hyphenR.HyphenationServer(logger, hyphenationDir);
+ return new org.foray.hyphenR.FOrayHyphenationServer(logger,
+ hyphenationDir);
}
public static GraphicServer makeGraphicServer(final Log logger)
Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenBreak.java (from rev 8310, trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java)
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenBreak.java (rev 0)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenBreak.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known contributors:
+ * Carlos Villegas <ca...@un...> (Original author), who credited
+ * TeX for the basic scheme.
+ */
+
+package org.foray.hyphenR;
+
+import org.foray.common.WKConstants;
+
+import org.axsl.hyphenR.HyphenBreak;
+
+import java.io.Serializable;
+
+/**
+ * <p>Specialized information about a specific hyphenation break opportunity in
+ * a word.
+ * This handles "hard" hyphenation cases, such as those where the word changes
+ * spelling when it is hyphenated.
+ * See {@link org.axsl.hyphenR.HyphenBreak} for more information about the
+ * general use of this class.</p>
+ *
+ * <p>A 'full' hyphen is made of 3 parts:
+ * the pre-break text, post-break text and no-break. If no line-break
+ * is generated at this position, the no-break text is used, otherwise,
+ * pre-break and post-break are used. Typically, pre-break is equal to
+ * the hyphen character and the others are empty.</p>
+ */
+public class FOrayHyphenBreak implements Serializable, HyphenBreak {
+
+ /** Constant needed for serialization. */
+ private static final long serialVersionUID = 990405609314441965L;
+
+ private String preBreak;
+ private String noBreak;
+ private String postBreak;
+
+ FOrayHyphenBreak(final String pre, final String no, final String post) {
+ preBreak = pre;
+ noBreak = no;
+ postBreak = post;
+ }
+
+ FOrayHyphenBreak(final String pre) {
+ preBreak = pre;
+ noBreak = null;
+ postBreak = null;
+ }
+
+ public String toString() {
+ if (noBreak == null
+ && postBreak == null
+ && preBreak != null
+ && preBreak.equals("-")) {
+ return "-";
+ }
+ final StringBuffer res = new StringBuffer("{");
+ res.append(preBreak);
+ res.append("}{");
+ res.append(postBreak);
+ res.append("}{");
+ res.append(noBreak);
+ res.append('}');
+ return res.toString();
+ }
+
+ /**
+ * Returns the "no break" String.
+ * @return Returns the noBreak.
+ */
+ public String getNoBreak() {
+ return this.noBreak;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String preDelete() {
+ /* TODO: Implement this. */
+ return WKConstants.EMPTY_STRING;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String preInsert() {
+ /* TODO: Implement this. */
+ return WKConstants.EMPTY_STRING;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String postDelete() {
+ /* TODO: Implement this. */
+ return WKConstants.EMPTY_STRING;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String postInsert() {
+ /* TODO: Implement this. */
+ return WKConstants.EMPTY_STRING;
+ }
+
+}
Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenation.java (from rev 8273, trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java)
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenation.java (rev 0)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenation.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known contributors:
+ * Carlos Villegas <ca...@un...> (original author)
+ */
+
+package org.foray.hyphenR;
+
+import org.axsl.hyphenR.HyphenBreak;
+import org.axsl.hyphenR.HyphenationException;
+
+/**
+ * This class represents a hyphenated word.
+ */
+public class FOrayHyphenation implements org.axsl.hyphenR.Hyphenation {
+
+ private String word;
+
+ private int[] hyphenPoints;
+
+ /* Always store the weights using the Liang weights. */
+ private byte[] hyphenValues;
+
+ FOrayHyphenation(final String word, final int[] points,
+ final byte[] values) {
+ this.word = word;
+ this.hyphenPoints = points;
+ this.hyphenValues = values;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int[] getPoints() {
+ return this.hyphenPoints;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getLiangWeights() {
+ return this.hyphenValues;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getWeights() {
+ if (this.hyphenValues == null) {
+ return null;
+ }
+ final byte[] returnArray = new byte[this.hyphenValues.length];
+ for (int i = 0; i < this.hyphenValues.length; i++) {
+ final byte value = this.hyphenValues[i];
+ try {
+ returnArray[i] = convertLiangToWeight(value);
+ } catch (final HyphenationException e) {
+ /* TODO: This exception should be passed upstream further. */
+ returnArray[i] = Byte.MIN_VALUE;
+ }
+ }
+ return returnArray;
+ }
+
+ public String toString() {
+ final StringBuffer str = new StringBuffer();
+ int start = 0;
+ for (int i = 0; i < hyphenPoints.length; i++) {
+ str.append(word.substring(start, hyphenPoints[i]) + "-");
+ start = hyphenPoints[i];
+ }
+ str.append(word.substring(start));
+ return str.toString();
+ }
+
+ /**
+ * Converts the raw value from the Liang data to a weighted value.
+ * In the Liang system, 1) even values are negative, 2) odd values are
+ * positive, and the magnitude of the number conveys the magnitude of
+ * the direction.
+ * @param liangValue Any positive byte value that contains a Liang-style
+ * algorithm weight. (Liang input is only in the range 0 to 5, but we will
+ * handle any positive input).
+ * @return A value that reflects the numeric weight of the raw Liang value.
+ */
+ public static byte convertLiangToWeight(final byte liangValue)
+ throws HyphenationException {
+ if (liangValue < 0) {
+ throw new HyphenationException("Invalid Liang input: "
+ + liangValue);
+ }
+ byte modifiedLiangValue = liangValue;
+ /* Save the low-order bit. */
+ final boolean good = (modifiedLiangValue & 1) == 1;
+ modifiedLiangValue ++;
+ modifiedLiangValue /= 2;
+ if (! good) {
+ modifiedLiangValue *= -1;
+ }
+ return modifiedLiangValue;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public HyphenBreak getHyphenBreak(final int index) {
+ /* TODO: Consider implementing this. */
+ return null;
+ }
+
+}
Copied: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenationServer.java (from rev 8306, trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java)
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenationServer.java (rev 0)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/FOrayHyphenationServer.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -0,0 +1,439 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known contributors:
+ * @author Carlos Villegas <ca...@un...> (original author)
+ */
+
+package org.foray.hyphenR;
+
+import org.foray.common.FOrayConstants;
+import org.foray.common.StringUtilPre5;
+
+import org.axsl.hyphenR.HyphenationException;
+
+import org.apache.commons.logging.Log;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * This class is the main entry point to the hyphenation package.
+ */
+public class FOrayHyphenationServer
+ implements org.axsl.hyphenR.HyphenationServer {
+
+ public static final String PATTERN_RESOURCE_PATH =
+ "org/foray/hyphenR/resource/patterns";
+
+ private static final String PATTERN_MISSING_TEXT =
+ "Hyphenation pattern not found: ";
+
+ private Log logger;
+
+ /**
+ * Collection of HyphenationTree instances that have been successfully
+ * deserialized or parsed. The key is the language or language and country
+ * connected by an underscore (e.g. en_US).
+ */
+ private HashMap hyphenTrees = new HashMap();
+
+ /**
+ * Collection of language and language_country combinations for which we
+ * already know we can't instantiate a HyphenationTree. This is used to
+ * log only one error message per language.
+ */
+ private ArrayList hyphenTreesNotFound = new ArrayList();
+
+ private boolean errorDump = false;
+ private String hyphenationDir;
+
+ /**
+ * Constructor.
+ * @param logger The Log instance for user messages.
+ */
+ public FOrayHyphenationServer(final Log logger, final URL hyphenationDir) {
+ this.logger = logger;
+ // TODO: This is klunky. Use the URL.
+ this.hyphenationDir = hyphenationDir.getFile();
+ }
+
+ private HyphenationTree getHyphenationTree(final String languageKey,
+ final String country) {
+ /* TODO: This logic needs some work. We should look first for the
+ * countryKey in the cache, then resources, then filesystem. If it is
+ * not found, only then look for the languageKey. */
+
+ if (languageKey == null) {
+ return null;
+ }
+
+ /* Build the country key. */
+ String countryKey = null;
+ if (country != null
+ && ! country.equals("")
+ && ! country.equals("none")) {
+ countryKey = languageKey + "_" + country;
+ }
+
+ /* Try to find the country key in the cache. Look for it before the
+ * lanuguage key because the country key is more specific. */
+ if (countryKey != null
+ && hyphenTrees.containsKey(countryKey)) {
+ return (HyphenationTree) hyphenTrees.get(countryKey);
+ }
+
+ /* Try to find the language key in the cache. */
+ if (hyphenTrees.containsKey(languageKey)) {
+ return (HyphenationTree) hyphenTrees.get(languageKey);
+ }
+
+ /* See if we have already tried and failed. */
+ for (int i = 0; i < this.hyphenTreesNotFound.size(); i++) {
+ final String key = (String) this.hyphenTreesNotFound.get(i);
+ if (languageKey.equals(key)) {
+ return null;
+ }
+ if (countryKey != null
+ && countryKey.equals(key)) {
+ return null;
+ }
+ }
+
+ HyphenationTree hTree = null;
+ /* Look for it as a jar file resource. */
+ if (countryKey != null) {
+ hTree = getHyphenationTree(countryKey);
+ if (hTree != null) {
+ hyphenTrees.put(countryKey, hTree);
+ return hTree;
+ }
+ }
+
+ hTree = getHyphenationTree(languageKey);
+ if (hTree != null) {
+ hyphenTrees.put(languageKey, hTree);
+ return hTree;
+ }
+
+ /* Now look for it in the filesystem. */
+ if (countryKey != null) {
+ hTree = loadHyphenationTree(countryKey);
+ if (hTree != null) {
+ hyphenTrees.put(countryKey, hTree);
+ return hTree;
+ }
+ }
+
+ hTree = loadHyphenationTree(languageKey);
+ if (hTree != null) {
+ hyphenTrees.put(languageKey, hTree);
+ return hTree;
+ }
+
+ /* Log a warning and add it to the list of not found keys. */
+ if (countryKey != null) {
+ getLogger().warn(PATTERN_MISSING_TEXT + countryKey);
+ }
+ getLogger().warn(PATTERN_MISSING_TEXT + languageKey);
+ hyphenTreesNotFound.add(languageKey);
+ return hTree;
+ }
+
+ private InputStream getResourceStream(final String key) {
+ InputStream is = null;
+ // Try to use Context Class Loader to load the properties file.
+ try {
+ final Method getCCL =
+ Thread.class.getMethod("getContextClassLoader", new Class[0]);
+ if (getCCL != null) {
+ final ClassLoader contextClassLoader =
+ (ClassLoader) getCCL.invoke(Thread.currentThread(),
+ new Object[0]);
+ is = contextClassLoader.getResourceAsStream(
+ PATTERN_RESOURCE_PATH + "/" + key
+ + "." + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
+ }
+ } catch (final Exception e) { }
+
+ if (is == null) {
+ is = FOrayHyphenationServer.class.getResourceAsStream(
+ "/" + PATTERN_RESOURCE_PATH + "/" + key
+ + "." + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
+ }
+
+ return is;
+ }
+
+ private HyphenationTree getHyphenationTree(final String key) {
+ HyphenationTree hTree = null;
+ ObjectInputStream ois = null;
+ InputStream is = null;
+ try {
+ is = getResourceStream(key);
+ if (is == null) {
+ return null;
+ }
+ ois = new ObjectInputStream(is);
+ hTree = (HyphenationTree) ois.readObject();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (ois != null) {
+ try {
+ ois.close();
+ } catch (final IOException e) {
+ getLogger().error("can't close hyphenation object stream");
+ }
+ }
+ }
+ return hTree;
+ }
+
+ /**
+ * Load a tree from serialized file or xml file using configuration
+ * settings.
+ */
+ private HyphenationTree loadHyphenationTree(final String key) {
+ if (this.hyphenationDir == null) {
+ return null;
+ }
+ HyphenationTree hTree = null;
+ // I use here the following convention. The file name specified in
+ // the configuration is taken as the base name. First we try
+ // name + the serialization extension, assuming a serialized
+ // yphenationTree. If that fails
+ // we try name + ".xml", assumming a raw hyphenation pattern file.
+
+ // first try serialized object
+ File hyphenFile = new File(this.hyphenationDir,
+ key + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
+ if (hyphenFile.exists()) {
+ ObjectInputStream ois = null;
+ try {
+ ois = new ObjectInputStream(new FileInputStream(hyphenFile));
+ hTree = (HyphenationTree) ois.readObject();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (ois != null) {
+ try {
+ ois.close();
+ } catch (final IOException e) { }
+ }
+ }
+ return hTree;
+ }
+
+ // try the raw XML file
+ hyphenFile = new File(this.hyphenationDir, key + ".xml");
+ if (hyphenFile.exists()) {
+ hTree = new HyphenationTree();
+ if (errorDump) {
+ getLogger().error("reading " + this.hyphenationDir + key
+ + ".xml");
+ }
+ try {
+ hTree.loadPatterns(hyphenFile.getPath(), getLogger());
+ if (errorDump) {
+ getLogger().debug("Stats: ");
+ hTree.printStats(getLogger());
+ }
+ return hTree;
+ } catch (final HyphenationException ex) {
+ if (errorDump) {
+ getLogger().error("Can't load user patterns "
+ + "from xml file " + this.hyphenationDir
+ + key + ".xml");
+ }
+ return null;
+ }
+ }
+ if (errorDump) {
+ getLogger().error("Tried to load "
+ + hyphenFile.toString()
+ + "\nCannot find compiled nor xml file for "
+ + "hyphenation pattern" + key);
+ }
+ return null;
+ }
+
+ public org.axsl.hyphenR.Hyphenation hyphenate(final CharSequence word,
+ final int offset, final int len, final String language,
+ final String country, final int remainCount, final int pushCount,
+ final boolean includeInhibitors) {
+ return this.hyphenate(word.toString().toCharArray(), offset, len,
+ language, country, remainCount, pushCount, includeInhibitors);
+ }
+
+ public org.axsl.hyphenR.Hyphenation hyphenate(final char[] word,
+ final int offset, final int len, final String language,
+ final String country, final int remainCount,
+ final int pushCount, final boolean includeInhibitors) {
+ final HyphenationTree hTree = getHyphenationTree(language, country);
+ if (hTree == null) {
+ return null;
+ }
+ return hTree.hyphenate(word, offset, len, remainCount, pushCount,
+ includeInhibitors);
+ }
+
+ public org.axsl.hyphenR.Hyphenation hyphenate(final int[] word,
+ final int offset, final int len, final String language,
+ final String country, final int remainCount, final int pushCount,
+ final boolean includeInhibitors) {
+ /* Convert to a String using the 32-bit ICU4J method. */
+ /* TODO: After Java 5 is the minimum, use the standard String
+ * constructor instead. */
+ final String string = StringUtilPre5.newString(word, offset, len);
+ /* FIXME: The Hyphenation instance needs to know that it was created
+ * from an int[] instead of a char[], so that it can properly handle
+ * surrogate pairs (an int that would convert to 2 chars).*/
+ return this.hyphenate(string, offset, len,
+ language, country, remainCount, pushCount, includeInhibitors);
+ }
+
+ public Log getLogger() {
+ return this.logger;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int wordSize(final char[] characters, final int wordStart,
+ final String language, final String country) {
+ if (characters == null) {
+ return 0;
+ }
+ boolean wordendFound = false;
+ int counter = 0;
+ final int[] newWord = new int[characters.length]; // create a buffer
+ while ((!wordendFound)
+ && ((wordStart + counter) < characters.length)) {
+ final int tk = characters[wordStart + counter];
+ if (StringUtilPre5.isLetter(tk)) {
+ newWord[counter] = tk;
+ counter++;
+ } else {
+ wordendFound = true;
+ }
+ }
+ return counter;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int wordSize(final CharSequence characters, final int wordStart,
+ final String language, final String country) {
+ if (characters == null) {
+ return 0;
+ }
+ return wordSize(characters.toString().toCharArray(), wordStart,
+ language, country);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int wordSize(final int[] characters, final int wordStart,
+ final String language, final String country) {
+ if (characters == null) {
+ return 0;
+ }
+ /* Convert to a String using the 32-bit ICU4J method. */
+ /* TODO: After Java 5 is the minimum, use the standard String
+ * constructor instead. */
+ final String string = StringUtilPre5.newString(characters, wordStart,
+ characters.length - wordStart);
+ /* FIXME: Return value needs to be reduced by the number of surrogate
+ * pairs (an int that would convert to 2 chars) found.*/
+ return wordSize(string, wordStart, language, country);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int wordStarts(final char[] characters, final int startIndex,
+ final String language, final String country) {
+ if (characters == null) {
+ return -1;
+ }
+ /* TODO: We need to handle language and country here. */
+ for (int i = startIndex; i < characters.length; i++) {
+ final char c = characters[i];
+ switch(c) {
+ case '"':
+ case '\'': {
+
+ continue;
+ }
+ default: {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int wordStarts(final CharSequence characters, final int startIndex,
+ final String language, final String country) {
+ if (characters == null) {
+ return -1;
+ }
+ return wordStarts(characters.toString().toCharArray(), startIndex,
+ language, country);
+ }
+
+ public int wordStarts(final int[] characters, final int startIndex,
+ final String language, final String country) {
+ if (characters == null) {
+ return -1;
+ }
+ /* Convert to a String using the 32-bit ICU4J method. */
+ /* TODO: After Java 5 is the minimum, use the standard String
+ * constructor instead. */
+ final String string = StringUtilPre5.newString(characters, startIndex,
+ characters.length - startIndex);
+ /* FIXME: Return value needs to be reduced by the number of surrogate
+ * pairs (an int that would convert to 2 chars) found.*/
+ return wordStarts(string, startIndex, language, country);
+ }
+
+}
Deleted: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphen.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -1,135 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known contributors:
- * Carlos Villegas <ca...@un...> (Original author), who credited
- * TeX for the basic scheme.
- */
-
-package org.foray.hyphenR;
-
-import org.foray.common.WKConstants;
-
-import org.axsl.hyphenR.HyphenBreak;
-
-import java.io.Serializable;
-
-/**
- * <p>Specialized information about a specific hyphenation break opportunity in
- * a word.
- * This handles "hard" hyphenation cases, such as those where the word changes
- * spelling when it is hyphenated.
- * See {@link org.axsl.hyphenR.HyphenBreak} for more information about the
- * general use of this class.</p>
- *
- * <p>A 'full' hyphen is made of 3 parts:
- * the pre-break text, post-break text and no-break. If no line-break
- * is generated at this position, the no-break text is used, otherwise,
- * pre-break and post-break are used. Typically, pre-break is equal to
- * the hyphen character and the others are empty.</p>
- */
-public class Hyphen implements Serializable, HyphenBreak {
-
- /** Constant needed for serialization. */
- private static final long serialVersionUID = 990405609314441965L;
-
- private String preBreak;
- private String noBreak;
- private String postBreak;
-
- Hyphen(final String pre, final String no, final String post) {
- preBreak = pre;
- noBreak = no;
- postBreak = post;
- }
-
- Hyphen(final String pre) {
- preBreak = pre;
- noBreak = null;
- postBreak = null;
- }
-
- public String toString() {
- if (noBreak == null
- && postBreak == null
- && preBreak != null
- && preBreak.equals("-")) {
- return "-";
- }
- final StringBuffer res = new StringBuffer("{");
- res.append(preBreak);
- res.append("}{");
- res.append(postBreak);
- res.append("}{");
- res.append(noBreak);
- res.append('}');
- return res.toString();
- }
-
- /**
- * Returns the "no break" String.
- * @return Returns the noBreak.
- */
- public String getNoBreak() {
- return this.noBreak;
- }
-
- /**
- * {@inheritDoc}
- */
- public String preDelete() {
- /* TODO: Implement this. */
- return WKConstants.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- */
- public String preInsert() {
- /* TODO: Implement this. */
- return WKConstants.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- */
- public String postDelete() {
- /* TODO: Implement this. */
- return WKConstants.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- */
- public String postInsert() {
- /* TODO: Implement this. */
- return WKConstants.EMPTY_STRING;
- }
-
-}
Deleted: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/Hyphenation.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known contributors:
- * Carlos Villegas <ca...@un...> (original author)
- */
-
-package org.foray.hyphenR;
-
-import org.axsl.hyphenR.HyphenBreak;
-import org.axsl.hyphenR.HyphenationException;
-
-/**
- * This class represents a hyphenated word.
- */
-public class Hyphenation implements org.axsl.hyphenR.Hyphenation {
-
- private String word;
-
- private int[] hyphenPoints;
-
- /* Always store the weights using the Liang weights. */
- private byte[] hyphenValues;
-
- Hyphenation(final String word, final int[] points, final byte[] values) {
- this.word = word;
- this.hyphenPoints = points;
- this.hyphenValues = values;
- }
-
- /**
- * {@inheritDoc}
- */
- public int[] getPoints() {
- return this.hyphenPoints;
- }
-
- /**
- * {@inheritDoc}
- */
- public byte[] getLiangWeights() {
- return this.hyphenValues;
- }
-
- /**
- * {@inheritDoc}
- */
- public byte[] getWeights() {
- if (this.hyphenValues == null) {
- return null;
- }
- final byte[] returnArray = new byte[this.hyphenValues.length];
- for (int i = 0; i < this.hyphenValues.length; i++) {
- final byte value = this.hyphenValues[i];
- try {
- returnArray[i] = convertLiangToWeight(value);
- } catch (final HyphenationException e) {
- /* TODO: This exception should be passed upstream further. */
- returnArray[i] = Byte.MIN_VALUE;
- }
- }
- return returnArray;
- }
-
- public String toString() {
- final StringBuffer str = new StringBuffer();
- int start = 0;
- for (int i = 0; i < hyphenPoints.length; i++) {
- str.append(word.substring(start, hyphenPoints[i]) + "-");
- start = hyphenPoints[i];
- }
- str.append(word.substring(start));
- return str.toString();
- }
-
- /**
- * Converts the raw value from the Liang data to a weighted value.
- * In the Liang system, 1) even values are negative, 2) odd values are
- * positive, and the magnitude of the number conveys the magnitude of
- * the direction.
- * @param liangValue Any positive byte value that contains a Liang-style
- * algorithm weight. (Liang input is only in the range 0 to 5, but we will
- * handle any positive input).
- * @return A value that reflects the numeric weight of the raw Liang value.
- */
- public static byte convertLiangToWeight(final byte liangValue)
- throws HyphenationException {
- if (liangValue < 0) {
- throw new HyphenationException("Invalid Liang input: "
- + liangValue);
- }
- byte modifiedLiangValue = liangValue;
- /* Save the low-order bit. */
- final boolean good = (modifiedLiangValue & 1) == 1;
- modifiedLiangValue ++;
- modifiedLiangValue /= 2;
- if (! good) {
- modifiedLiangValue *= -1;
- }
- return modifiedLiangValue;
- }
-
- /**
- * {@inheritDoc}
- */
- public HyphenBreak getHyphenBreak(final int index) {
- /* TODO: Consider implementing this. */
- return null;
- }
-
-}
Deleted: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationServer.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -1,438 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-/*
- * Known contributors:
- * @author Carlos Villegas <ca...@un...> (original author)
- */
-
-package org.foray.hyphenR;
-
-import org.foray.common.FOrayConstants;
-import org.foray.common.StringUtilPre5;
-
-import org.axsl.hyphenR.HyphenationException;
-
-import org.apache.commons.logging.Log;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * This class is the main entry point to the hyphenation package.
- */
-public class HyphenationServer implements org.axsl.hyphenR.HyphenationServer {
-
- public static final String PATTERN_RESOURCE_PATH =
- "org/foray/hyphenR/resource/patterns";
-
- private static final String PATTERN_MISSING_TEXT =
- "Hyphenation pattern not found: ";
-
- private Log logger;
-
- /**
- * Collection of HyphenationTree instances that have been successfully
- * deserialized or parsed. The key is the language or language and country
- * connected by an underscore (e.g. en_US).
- */
- private HashMap hyphenTrees = new HashMap();
-
- /**
- * Collection of language and language_country combinations for which we
- * already know we can't instantiate a HyphenationTree. This is used to
- * log only one error message per language.
- */
- private ArrayList hyphenTreesNotFound = new ArrayList();
-
- private boolean errorDump = false;
- private String hyphenationDir;
-
- /**
- * Constructor.
- * @param logger The Log instance for user messages.
- */
- public HyphenationServer(final Log logger, final URL hyphenationDir) {
- this.logger = logger;
- // TODO: This is klunky. Use the URL.
- this.hyphenationDir = hyphenationDir.getFile();
- }
-
- private HyphenationTree getHyphenationTree(final String languageKey,
- final String country) {
- /* TODO: This logic needs some work. We should look first for the
- * countryKey in the cache, then resources, then filesystem. If it is
- * not found, only then look for the languageKey. */
-
- if (languageKey == null) {
- return null;
- }
-
- /* Build the country key. */
- String countryKey = null;
- if (country != null
- && ! country.equals("")
- && ! country.equals("none")) {
- countryKey = languageKey + "_" + country;
- }
-
- /* Try to find the country key in the cache. Look for it before the
- * lanuguage key because the country key is more specific. */
- if (countryKey != null
- && hyphenTrees.containsKey(countryKey)) {
- return (HyphenationTree) hyphenTrees.get(countryKey);
- }
-
- /* Try to find the language key in the cache. */
- if (hyphenTrees.containsKey(languageKey)) {
- return (HyphenationTree) hyphenTrees.get(languageKey);
- }
-
- /* See if we have already tried and failed. */
- for (int i = 0; i < this.hyphenTreesNotFound.size(); i++) {
- final String key = (String) this.hyphenTreesNotFound.get(i);
- if (languageKey.equals(key)) {
- return null;
- }
- if (countryKey != null
- && countryKey.equals(key)) {
- return null;
- }
- }
-
- HyphenationTree hTree = null;
- /* Look for it as a jar file resource. */
- if (countryKey != null) {
- hTree = getHyphenationTree(countryKey);
- if (hTree != null) {
- hyphenTrees.put(countryKey, hTree);
- return hTree;
- }
- }
-
- hTree = getHyphenationTree(languageKey);
- if (hTree != null) {
- hyphenTrees.put(languageKey, hTree);
- return hTree;
- }
-
- /* Now look for it in the filesystem. */
- if (countryKey != null) {
- hTree = loadHyphenationTree(countryKey);
- if (hTree != null) {
- hyphenTrees.put(countryKey, hTree);
- return hTree;
- }
- }
-
- hTree = loadHyphenationTree(languageKey);
- if (hTree != null) {
- hyphenTrees.put(languageKey, hTree);
- return hTree;
- }
-
- /* Log a warning and add it to the list of not found keys. */
- if (countryKey != null) {
- getLogger().warn(PATTERN_MISSING_TEXT + countryKey);
- }
- getLogger().warn(PATTERN_MISSING_TEXT + languageKey);
- hyphenTreesNotFound.add(languageKey);
- return hTree;
- }
-
- private InputStream getResourceStream(final String key) {
- InputStream is = null;
- // Try to use Context Class Loader to load the properties file.
- try {
- final Method getCCL =
- Thread.class.getMethod("getContextClassLoader", new Class[0]);
- if (getCCL != null) {
- final ClassLoader contextClassLoader =
- (ClassLoader) getCCL.invoke(Thread.currentThread(),
- new Object[0]);
- is = contextClassLoader.getResourceAsStream(
- PATTERN_RESOURCE_PATH + "/" + key
- + "." + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
- }
- } catch (final Exception e) { }
-
- if (is == null) {
- is = HyphenationServer.class.getResourceAsStream(
- "/" + PATTERN_RESOURCE_PATH + "/" + key
- + "." + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
- }
-
- return is;
- }
-
- private HyphenationTree getHyphenationTree(final String key) {
- HyphenationTree hTree = null;
- ObjectInputStream ois = null;
- InputStream is = null;
- try {
- is = getResourceStream(key);
- if (is == null) {
- return null;
- }
- ois = new ObjectInputStream(is);
- hTree = (HyphenationTree) ois.readObject();
- } catch (final Exception e) {
- e.printStackTrace();
- } finally {
- if (ois != null) {
- try {
- ois.close();
- } catch (final IOException e) {
- getLogger().error("can't close hyphenation object stream");
- }
- }
- }
- return hTree;
- }
-
- /**
- * Load a tree from serialized file or xml file using configuration
- * settings.
- */
- private HyphenationTree loadHyphenationTree(final String key) {
- if (this.hyphenationDir == null) {
- return null;
- }
- HyphenationTree hTree = null;
- // I use here the following convention. The file name specified in
- // the configuration is taken as the base name. First we try
- // name + the serialization extension, assuming a serialized
- // yphenationTree. If that fails
- // we try name + ".xml", assumming a raw hyphenation pattern file.
-
- // first try serialized object
- File hyphenFile = new File(this.hyphenationDir,
- key + FOrayConstants.BINARY_SERIALIZATION_EXTENSION);
- if (hyphenFile.exists()) {
- ObjectInputStream ois = null;
- try {
- ois = new ObjectInputStream(new FileInputStream(hyphenFile));
- hTree = (HyphenationTree) ois.readObject();
- } catch (final Exception e) {
- e.printStackTrace();
- } finally {
- if (ois != null) {
- try {
- ois.close();
- } catch (final IOException e) { }
- }
- }
- return hTree;
- }
-
- // try the raw XML file
- hyphenFile = new File(this.hyphenationDir, key + ".xml");
- if (hyphenFile.exists()) {
- hTree = new HyphenationTree();
- if (errorDump) {
- getLogger().error("reading " + this.hyphenationDir + key
- + ".xml");
- }
- try {
- hTree.loadPatterns(hyphenFile.getPath(), getLogger());
- if (errorDump) {
- getLogger().debug("Stats: ");
- hTree.printStats(getLogger());
- }
- return hTree;
- } catch (final HyphenationException ex) {
- if (errorDump) {
- getLogger().error("Can't load user patterns "
- + "from xml file " + this.hyphenationDir
- + key + ".xml");
- }
- return null;
- }
- }
- if (errorDump) {
- getLogger().error("Tried to load "
- + hyphenFile.toString()
- + "\nCannot find compiled nor xml file for "
- + "hyphenation pattern" + key);
- }
- return null;
- }
-
- public org.axsl.hyphenR.Hyphenation hyphenate(final CharSequence word,
- final int offset, final int len, final String language,
- final String country, final int remainCount, final int pushCount,
- final boolean includeInhibitors) {
- return this.hyphenate(word.toString().toCharArray(), offset, len,
- language, country, remainCount, pushCount, includeInhibitors);
- }
-
- public org.axsl.hyphenR.Hyphenation hyphenate(final char[] word,
- final int offset, final int len, final String language,
- final String country, final int remainCount,
- final int pushCount, final boolean includeInhibitors) {
- final HyphenationTree hTree = getHyphenationTree(language, country);
- if (hTree == null) {
- return null;
- }
- return hTree.hyphenate(word, offset, len, remainCount, pushCount,
- includeInhibitors);
- }
-
- public org.axsl.hyphenR.Hyphenation hyphenate(final int[] word,
- final int offset, final int len, final String language,
- final String country, final int remainCount, final int pushCount,
- final boolean includeInhibitors) {
- /* Convert to a String using the 32-bit ICU4J method. */
- /* TODO: After Java 5 is the minimum, use the standard String
- * constructor instead. */
- final String string = StringUtilPre5.newString(word, offset, len);
- /* FIXME: The Hyphenation instance needs to know that it was created
- * from an int[] instead of a char[], so that it can properly handle
- * surrogate pairs (an int that would convert to 2 chars).*/
- return this.hyphenate(string, offset, len,
- language, country, remainCount, pushCount, includeInhibitors);
- }
-
- public Log getLogger() {
- return this.logger;
- }
-
- /**
- * {@inheritDoc}
- */
- public int wordSize(final char[] characters, final int wordStart,
- final String language, final String country) {
- if (characters == null) {
- return 0;
- }
- boolean wordendFound = false;
- int counter = 0;
- final int[] newWord = new int[characters.length]; // create a buffer
- while ((!wordendFound)
- && ((wordStart + counter) < characters.length)) {
- final int tk = characters[wordStart + counter];
- if (StringUtilPre5.isLetter(tk)) {
- newWord[counter] = tk;
- counter++;
- } else {
- wordendFound = true;
- }
- }
- return counter;
- }
-
- /**
- * {@inheritDoc}
- */
- public int wordSize(final CharSequence characters, final int wordStart,
- final String language, final String country) {
- if (characters == null) {
- return 0;
- }
- return wordSize(characters.toString().toCharArray(), wordStart,
- language, country);
- }
-
- /**
- * {@inheritDoc}
- */
- public int wordSize(final int[] characters, final int wordStart,
- final String language, final String country) {
- if (characters == null) {
- return 0;
- }
- /* Convert to a String using the 32-bit ICU4J method. */
- /* TODO: After Java 5 is the minimum, use the standard String
- * constructor instead. */
- final String string = StringUtilPre5.newString(characters, wordStart,
- characters.length - wordStart);
- /* FIXME: Return value needs to be reduced by the number of surrogate
- * pairs (an int that would convert to 2 chars) found.*/
- return wordSize(string, wordStart, language, country);
- }
-
- /**
- * {@inheritDoc}
- */
- public int wordStarts(final char[] characters, final int startIndex,
- final String language, final String country) {
- if (characters == null) {
- return -1;
- }
- /* TODO: We need to handle language and country here. */
- for (int i = startIndex; i < characters.length; i++) {
- final char c = characters[i];
- switch(c) {
- case '"':
- case '\'': {
-
- continue;
- }
- default: {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- public int wordStarts(final CharSequence characters, final int startIndex,
- final String language, final String country) {
- if (characters == null) {
- return -1;
- }
- return wordStarts(characters.toString().toCharArray(), startIndex,
- language, country);
- }
-
- public int wordStarts(final int[] characters, final int startIndex,
- final String language, final String country) {
- if (characters == null) {
- return -1;
- }
- /* Convert to a String using the 32-bit ICU4J method. */
- /* TODO: After Java 5 is the minimum, use the standard String
- * constructor instead. */
- final String string = StringUtilPre5.newString(characters, startIndex,
- characters.length - startIndex);
- /* FIXME: Return value needs to be reduced by the number of surrogate
- * pairs (an int that would convert to 2 chars) found.*/
- return wordStarts(string, startIndex, language, country);
- }
-
-}
Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/HyphenationTree.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -300,7 +300,7 @@
* before the hyphenation point.
* @param pushCharCount Minimum number of characters allowed after
* the hyphenation point.
- * @return a {@link Hyphenation Hyphenation} object representing
+ * @return a {@link FOrayHyphenation Hyphenation} object representing
* the hyphenated word or null if word is not hyphenated.
*/
public org.axsl.hyphenR.Hyphenation hyphenate(final char[] w,
@@ -312,7 +312,7 @@
}
final String theWord = new String(w, offset, len);
- Hyphenation hyphenation = checkExceptions(theWord, remainCharCount,
+ FOrayHyphenation hyphenation = checkExceptions(theWord, remainCharCount,
pushCharCount);
if (hyphenation != null) {
return hyphenation;
@@ -328,7 +328,7 @@
* @param k
* @return The new Hyphenation instance.
*/
- private Hyphenation createHyphenation(final String theWord,
+ private FOrayHyphenation createHyphenation(final String theWord,
final int[] points, final byte[] values, final int k) {
if (k > 0) {
// trim result array
@@ -336,7 +336,7 @@
System.arraycopy(points, 0, returnPoints, 0, k);
final byte[] returnValues = new byte[k];
System.arraycopy(values, 0, returnValues, 0, k);
- return new Hyphenation(theWord, returnPoints, returnValues);
+ return new FOrayHyphenation(theWord, returnPoints, returnValues);
}
return null;
}
@@ -357,7 +357,7 @@
return word;
}
- private Hyphenation checkExceptions(final String sw,
+ private FOrayHyphenation checkExceptions(final String sw,
final int remainCharCount, final int pushCharCount) {
if (! stoplist.containsKey(sw)) {
return null;
@@ -387,7 +387,7 @@
return createHyphenation(sw, result, values, k);
}
- private Hyphenation checkAlgorithm(final String theWord,
+ private FOrayHyphenation checkAlgorithm(final String theWord,
final int remainCharCount, final int pushCharCount,
final char[] word, final boolean includeInhibitors) {
final int len = theWord.length();
@@ -474,7 +474,7 @@
* store the hyphenation exceptions.
* @param word normalized word
* @param hyphenatedword a ArrayList of alternating strings and
- * {@link Hyphen hyphen} objects.
+ * {@link FOrayHyphenBreak hyphen} objects.
*/
public void addException(final String word,
final ArrayList hyphenatedword) {
Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternConsumer.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -54,7 +54,7 @@
* result obtained by the algorithm for cases for which this
* fails or the user wants to provide his own hyphenation.
* A hyphenatedword is a ArrayList of alternating String's and
- * {@link Hyphen Hyphen} instances
+ * {@link FOrayHyphenBreak Hyphen} instances
*/
void addException(String word, ArrayList hyphenatedword);
Modified: trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java
===================================================================
--- trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java 2006-10-06 22:14:43 UTC (rev 8310)
+++ trunk/foray/foray-hyphen-r/src/java/org/foray/hyphenR/PatternParser.java 2006-10-06 22:20:46 UTC (rev 8311)
@@ -230,7 +230,8 @@
h[0] = hyphenChar;
// we use here hyphenChar which is not necessarily
// the one to be printed
- res.add(new Hyphen(new String(h), null, null));
+ res.add(new FOrayHyphenBreak(new String(h), null,
+ null));
}
}
if (buf.length() > 0) {
@@ -250,7 +251,7 @@
if (item instanceof String) {
res.append((String) item);
} else {
- final Hyphen hyphen = (Hyphen) item;
+ final FOrayHyphenBreak hyphen = (FOrayHyphenBreak) item;
if (hyphen.getNoBreak() != null) {
res.append(hyphen.getNoBreak());
}
@@ -301,7 +302,7 @@
if (token.length() > 0) {
exception.add(token.toString());
}
- exception.add(new Hyphen(attrs.getValue("pre"),
+ exception.add(new FOrayHyphenBreak(attrs.getValue("pre"),
attrs.getValue("no"), attrs.getValue("post")));
currElement = ELEM_HYPHEN;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|