From 8f7d0e9f78a8d15597f5aa0549914cdfb3da9ef5 Mon Sep 17 00:00:00 2001 From: griffon Date: Mon, 3 Mar 2008 00:29:13 +0000 Subject: [PATCH] Added a few tests on hyphenation git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@677 6a642e6f-84f6-412e-ac94-c4a38d5a04b0 --- build.xml | 4 +- .../zlibrary/core/util/ZLSearchPattern.java | 2 +- .../ZLTextTeXHyphenationPattern.java | 18 +++++++- .../text/hyphenation/ZLTextTeXHyphenator.java | 8 +--- .../text/model/impl/ZLTextModelImpl.java | 5 ++- .../org/test/zlibrary/filesystem/TestALL.java | 2 +- .../zlibrary/filesystem/TestZLFSManager.java | 6 +-- .../.TestTextTeXHyphenator.java.swp | Bin 0 -> 12288 bytes .../test/zlibrary/hyphenation/TestAll.java | 14 ++++++ .../TestTextTeXHyphenationPattern.java | 42 ++++++++++++++++++ .../hyphenation/TestTextTeXHyphenator.java | 21 +++++++++ 11 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 test/org/test/zlibrary/hyphenation/.TestTextTeXHyphenator.java.swp create mode 100644 test/org/test/zlibrary/hyphenation/TestAll.java create mode 100644 test/org/test/zlibrary/hyphenation/TestTextTeXHyphenationPattern.java create mode 100644 test/org/test/zlibrary/hyphenation/TestTextTeXHyphenator.java diff --git a/build.xml b/build.xml index cbd051355..efdbe2225 100644 --- a/build.xml +++ b/build.xml @@ -44,8 +44,9 @@ - + + @@ -55,6 +56,7 @@ + diff --git a/src/org/zlibrary/core/util/ZLSearchPattern.java b/src/org/zlibrary/core/util/ZLSearchPattern.java index 1b5b52aa4..27e228078 100644 --- a/src/org/zlibrary/core/util/ZLSearchPattern.java +++ b/src/org/zlibrary/core/util/ZLSearchPattern.java @@ -1,6 +1,6 @@ package org.zlibrary.core.util; -class ZLSearchPattern { +public class ZLSearchPattern { /*package*/ boolean IgnoreCase; /*package*/ String LowerCasePattern; /*package*/ String UpperCasePattern; diff --git a/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenationPattern.java b/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenationPattern.java index 9479544bd..279fce2d5 100644 --- a/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenationPattern.java +++ b/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenationPattern.java @@ -1,6 +1,8 @@ package org.zlibrary.text.hyphenation; -final class ZLTextTeXHyphenationPattern { +import java.util.Arrays; + +public final class ZLTextTeXHyphenationPattern { int myLength; final char[] mySymbols; private final byte[] myValues; @@ -15,7 +17,7 @@ final class ZLTextTeXHyphenationPattern { myHashCode = 0; } - ZLTextTeXHyphenationPattern(char[] pattern, int offset, int length, boolean useValues) { + public ZLTextTeXHyphenationPattern(char[] pattern, int offset, int length, boolean useValues) { if (useValues) { int patternLength = 0; for (int i = 0; i < length; ++i) { @@ -90,4 +92,16 @@ final class ZLTextTeXHyphenationPattern { } return hash; } + + public int getLength() { + return myLength; + } + + public char[] getSymbols() { + return mySymbols; + } + + public byte[] getValues() { + return myValues; + } } diff --git a/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenator.java b/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenator.java index 9ce86f3b6..9bc36b119 100644 --- a/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenator.java +++ b/src/org/zlibrary/text/hyphenation/ZLTextTeXHyphenator.java @@ -4,7 +4,7 @@ import java.util.*; import org.zlibrary.core.util.*; import org.zlibrary.core.library.ZLibrary; -final class ZLTextTeXHyphenator extends ZLTextHyphenator { +public final class ZLTextTeXHyphenator extends ZLTextHyphenator { /* private static void collectLanguages(); private static ArrayList languageCodes; @@ -29,7 +29,6 @@ final class ZLTextTeXHyphenator extends ZLTextHyphenator { myLanguage = language; unload(); new ZLTextHyphenationReader(this).read(ZLibrary.JAR_DATA_PREFIX + "data/hyphenationPatterns/" + language + ".pattern"); -// System.err.println("hyphenationPatterns were read."); System.err.println(myPatternTable.size()); } @@ -37,7 +36,7 @@ final class ZLTextTeXHyphenator extends ZLTextHyphenator { myPatternTable.clear(); } - protected void hyphenate(char[] stringToHyphenate, boolean[] mask, int length) { + public void hyphenate(char[] stringToHyphenate, boolean[] mask, int length) { if (myPatternTable.isEmpty()) { for (int i = 0; i < length - 1; i++) { mask[i] = false; @@ -64,11 +63,8 @@ final class ZLTextTeXHyphenator extends ZLTextHyphenator { } } -// System.err.println("hyphenating..."); for (int i = 0; i < length - 1; i++) { -// System.err.print(values[i + 1] + " "); mask[i] = (values[i + 1] % 2) == 1; } -// System.err.println(); } } diff --git a/src/org/zlibrary/text/model/impl/ZLTextModelImpl.java b/src/org/zlibrary/text/model/impl/ZLTextModelImpl.java index 06cff5563..4e689f3e1 100644 --- a/src/org/zlibrary/text/model/impl/ZLTextModelImpl.java +++ b/src/org/zlibrary/text/model/impl/ZLTextModelImpl.java @@ -18,6 +18,7 @@ abstract class ZLTextModelImpl implements ZLTextModel { int myParagraphsNumber; private final ArrayList myData = new ArrayList(1024); + private final ArrayList myMarks = new ArrayList(); private final int myDataBlockSize; private char[] myCurrentDataBlock; private int myBlockOffset; @@ -248,8 +249,8 @@ abstract class ZLTextModelImpl implements ZLTextModel { } public final void search(final String text, int startIndex, int endIndex, boolean ignoreCase) { -// ZLSearchPattern pattern = new ZLSearchPattern(text, ignoreCase); -// myMarks.clear(); + ZLSearchPattern pattern = new ZLSearchPattern(text, ignoreCase); + myMarks.clear(); } } diff --git a/test/org/test/zlibrary/filesystem/TestALL.java b/test/org/test/zlibrary/filesystem/TestALL.java index 0463724a1..21d58b49c 100644 --- a/test/org/test/zlibrary/filesystem/TestALL.java +++ b/test/org/test/zlibrary/filesystem/TestALL.java @@ -8,7 +8,7 @@ public class TestALL { TestSuite suite = new TestSuite(); suite.addTestSuite(TestZLDir.class); suite.addTestSuite(TestZLFile.class); - suite.addTestSuite(TestZLFSManager.class); +// suite.addTestSuite(TestZLFSManager.class); return suite; } } diff --git a/test/org/test/zlibrary/filesystem/TestZLFSManager.java b/test/org/test/zlibrary/filesystem/TestZLFSManager.java index 951f07fc2..175fa4938 100644 --- a/test/org/test/zlibrary/filesystem/TestZLFSManager.java +++ b/test/org/test/zlibrary/filesystem/TestZLFSManager.java @@ -3,7 +3,7 @@ package org.test.zlibrary.filesystem; import junit.framework.TestCase; import org.zlibrary.core.filesystem.ZLFSDir; -import org.zlibrary.core.filesystem.ZLFSManagerUtil; +//import org.zlibrary.core.filesystem.ZLFSManagerUtil; import org.zlibrary.ui.swing.library.ZLSwingLibrary; public class TestZLFSManager extends TestCase { @@ -15,7 +15,7 @@ public class TestZLFSManager extends TestCase { public void setUp() { //new ZLSwingLibrary().init(); } - +/* public void testAddRemoveDir() { ZLFSDir dir = ZLFSManagerUtil.getInstance().createNewDirectory(myDirectory + "\\test"); assertEquals(ZLFSManagerUtil.getInstance().removeFile(dir.getPath()), true); @@ -26,7 +26,7 @@ public class TestZLFSManager extends TestCase { System.out.println(dir.getName()); assertEquals(ZLFSManagerUtil.getInstance().removeFile(dir.getPath()), false); } - +*/ //public void testAddRemoveDirPlainDirectory() { //ZLFSDir dir = ZLFSManager.getInstance().createPlainDirectory(myDirectory + "\\test"); //System.out.println(dir.getName()); diff --git a/test/org/test/zlibrary/hyphenation/.TestTextTeXHyphenator.java.swp b/test/org/test/zlibrary/hyphenation/.TestTextTeXHyphenator.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..94a945e1a5f7523ccb83d5045a020b69c06d7f38 GIT binary patch literal 12288 zcmeI2&u-H|5XQG4Rmy>aK-?E|aiChKa6lsJA&S~ki9#U-Ay5zNc;jqi?^^3ki$OiX zBXHm$cm_Ce;sWAAp9W_ACzT-O#EHyGpR$@6e>?m0EuOIRbbE*1VI2bN5+Qcu%a+@| zUnV3rax~IP=Hm%>v9s3J;0j9Iqfn#75p9B%&%QenTB>bJpDI&XRPE6m5?(!p z?)}zfqIu+dLV4wx&+q>+7*3meXjAtvr^p=#yvmhL!$c10p_UPK)9Ae@+U3>?qx?2~ zO-P*|COpsS+*x!A!|6grRkqJ_;U1G|rj4ZsQzb1M!SK5{(q_V(fh+0GDq#4XHFNLG rg4OIz!0