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 000000000..94a945e1a Binary files /dev/null and b/test/org/test/zlibrary/hyphenation/.TestTextTeXHyphenator.java.swp differ diff --git a/test/org/test/zlibrary/hyphenation/TestAll.java b/test/org/test/zlibrary/hyphenation/TestAll.java new file mode 100644 index 000000000..4d28489f3 --- /dev/null +++ b/test/org/test/zlibrary/hyphenation/TestAll.java @@ -0,0 +1,14 @@ +package org.test.zlibrary.hyphenation; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class TestAll { + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTestSuite(TestTextTeXHyphenationPattern.class); + suite.addTestSuite(TestTextTeXHyphenator.class); + return suite; + } +} + diff --git a/test/org/test/zlibrary/hyphenation/TestTextTeXHyphenationPattern.java b/test/org/test/zlibrary/hyphenation/TestTextTeXHyphenationPattern.java new file mode 100644 index 000000000..dba23c92a --- /dev/null +++ b/test/org/test/zlibrary/hyphenation/TestTextTeXHyphenationPattern.java @@ -0,0 +1,42 @@ +package org.test.zlibrary.hyphenation; + +import java.util.Arrays; + +import org.zlibrary.text.hyphenation.ZLTextTeXHyphenationPattern; + +import junit.framework.TestCase; + +public class TestTextTeXHyphenationPattern extends TestCase { + public void testCreateEmptyPattern() { + int length = 0; + char[] pattern = new char[length]; + ZLTextTeXHyphenationPattern p = new ZLTextTeXHyphenationPattern(pattern, 0, length, true); + assertEquals(p.getLength(), 0); + assertEquals(Arrays.toString(p.getSymbols()), "[]"); + assertEquals(Arrays.toString(p.getValues()), "[0]"); + } + + public void testCreatePatternEnglish() { + int length = 3; + char[] pattern = new char[length]; + pattern[0] = 'a'; + pattern[1] = '2'; + pattern[2] = 'b'; + ZLTextTeXHyphenationPattern p = new ZLTextTeXHyphenationPattern(pattern, 0, length, true); + assertEquals(p.getLength(), 2); + assertEquals(Arrays.toString(p.getSymbols()), "[a, b]"); + assertEquals(Arrays.toString(p.getValues()), "[0, 2, 0]"); + } + + public void testCreatePatternRussian() { + int length = 3; + char[] pattern = new char[length]; + pattern[0] = 'à'; + pattern[1] = '2'; + pattern[2] = 'á'; + ZLTextTeXHyphenationPattern p = new ZLTextTeXHyphenationPattern(pattern, 0, length, true); + assertEquals(p.getLength(), 2); + assertEquals(Arrays.toString(p.getSymbols()), "[à, á]"); + assertEquals(Arrays.toString(p.getValues()), "[0, 2, 0]"); + } +} diff --git a/test/org/test/zlibrary/hyphenation/TestTextTeXHyphenator.java b/test/org/test/zlibrary/hyphenation/TestTextTeXHyphenator.java new file mode 100644 index 000000000..1816d9ed2 --- /dev/null +++ b/test/org/test/zlibrary/hyphenation/TestTextTeXHyphenator.java @@ -0,0 +1,21 @@ +package org.test.zlibrary.hyphenation; + +import java.util.Arrays; + +import org.zlibrary.text.hyphenation.ZLTextTeXHyphenator; + +import junit.framework.TestCase; + +public class TestTextTeXHyphenator extends TestCase { + + public void testAddPattern() { + ZLTextTeXHyphenator hyphenator = new ZLTextTeXHyphenator(); + hyphenator.load("en"); + String s = "griffon"; + int length = s.length(); + boolean[] mask = new boolean[length]; + char[] buf = s.toCharArray(); + hyphenator.hyphenate(buf, mask, length); + System.err.println(Arrays.toString(mask)); + } +}