aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-08-11 16:56:45 (EDT)
committerOleg Besedin2011-08-11 16:56:45 (EDT)
commit3744440aa185265e31d3dbfc80dbf646fcff8442 (patch)
tree582ed51a51783131fb5c91ff5156f50ac4777ca2
parent92e3c75a04198d5378c67f9aa43647c0b53b7021 (diff)
downloadrt.equinox.bundles-3744440aa185265e31d3dbfc80dbf646fcff8442.zip
rt.equinox.bundles-3744440aa185265e31d3dbfc80dbf646fcff8442.tar.gz
rt.equinox.bundles-3744440aa185265e31d3dbfc80dbf646fcff8442.tar.bz2
Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java9
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java44
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java100
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java14
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java122
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java12
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java1
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java)2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java)8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java95
-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/custom/STextProcessor.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java)7
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java)22
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java6
19 files changed, 268 insertions, 308 deletions
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 1b62212..a412afc 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.advanced.STextProcessorFactoryNew;
-import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
+import org.eclipse.equinox.bidi.advanced.STextExpertFactory;
+import org.eclipse.equinox.bidi.advanced.ISTextExpert;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -51,10 +51,9 @@ public class STextExtensibilityTest extends STextTestBase {
data = "ABC.DEF:HOST-COM=HELLO";
lean = toUT16(data);
processor = STextProcessorFactory.getProcessor("test");
- // XXX full = STextEngine.leanToFullText(processor, null, lean, null);
- STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor("test");
- full = processorNew.leanToFullText(lean);
+ ISTextExpert expert = STextExpertFactory.getExpert("test");
+ full = expert.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 a3e9846..9d36b87 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
@@ -19,54 +19,54 @@ import org.eclipse.equinox.bidi.advanced.*;
*/
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);
+ private STextEnvironment env = STextEnvironment.DEFAULT;
+ private STextEnvironment envArabic = new STextEnvironment("ar", false, STextEnvironment.ORIENT_LTR);
+ private STextEnvironment envHebrew = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
- STextProcessorNew processorNew;
+ private ISTextExpert expert;
private void doTest1(String label, String data, String result) {
- String full = processorNew.leanToFullText(toUT16(data));
+ String full = expert.leanToFullText(toUT16(data));
assertEquals(label + " data = " + data, result, toPseudo(full));
}
private void doTest2(String label, String data, String result) {
- String full = processorNew.leanToFullText(data);
+ String full = expert.leanToFullText(data);
assertEquals(label + " data = " + data, result, toPseudo(full));
}
private void doTest3(String label, String data, String result) {
- String full = processorNew.leanToFullText(toUT16(data));
+ String full = expert.leanToFullText(toUT16(data));
assertEquals(label + " data = " + data, result, toPseudo(full));
}
public void testExtensions() {
String data;
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.COMMA_DELIMITED, env);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, env);
doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.EMAIL, env);
+ expert = STextExpertFactory.getExpert(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);
+ expert = STextExpertFactory.getExpert(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);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env);
data = toUT16("peter.pan") + "@" + toUT16("DEF.GHI");
doTest2("Email #9", data, "peter.pan@DEF@.GHI");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.FILE, env);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.FILE, env);
doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.JAVA, env);
+ expert = STextExpertFactory.getExpert(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;");
@@ -78,12 +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;");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.PROPERTY, env);
+ expert = STextExpertFactory.getExpert(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");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.REGEXP, env);
+ expert = STextExpertFactory.getExpert(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");
@@ -129,7 +129,7 @@ public class STextExtensionsTest extends STextTestBase {
doTest1("Regex #17.7", "aB*567", "aB*@567");
env = envArabic;
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.REGEXP, env);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.REGEXP, env);
data = toUT16("#BC(?") + "#" + toUT16("DEF)GHI");
doTest2("Regex #0.0", data, "<&#BC(?#DEF)GHI&^");
data = toUT16("#BC(?") + "#" + toUT16("DEF");
@@ -167,7 +167,7 @@ public class STextExtensionsTest extends STextTestBase {
doTest2("Regex #16.2", data, "<&#HI\\eJKL&^");
env = envHebrew;
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.SQL, env);
+ expert = STextExpertFactory.getExpert(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");
@@ -185,22 +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");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.SYSTEM_USER, env);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.SYSTEM_USER, env);
doTest1("System #1", "HOST(JACK)", "HOST@(JACK)");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.UNDERSCORE, env);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.UNDERSCORE, env);
doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.URL, env);
+ expert = STextExpertFactory.getExpert(STextProcessorFactory.URL, env);
doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.XPATH, env);
+ expert = STextExpertFactory.getExpert(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 ");
- processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.EMAIL, env);
+ expert = STextExpertFactory.getExpert(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 e6de101..30e8789 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,64 +11,51 @@
package org.eclipse.equinox.bidi.internal.tests;
+import org.eclipse.equinox.bidi.STextProcessorFactory;
import org.eclipse.equinox.bidi.advanced.*;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests fullToLean method
*/
-
public class STextFullToLeanTest extends STextTestBase {
- static final STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
- static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
+ private static final STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
+ private static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
- STextProcessor processor;
- String descriptorID;
+ private String type;
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);
- // XXX
- STextProcessorNew processorLTR = STextProcessorFactoryNew.getProcessor(descriptorID, envLTR);
- lean = processorLTR.fullToLeanText(text);
+ ISTextExpert expertLTR = STextExpertFactory.getExpert(type, envLTR);
+ lean = expertLTR.fullToLeanText(text);
assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
- //full = STextEngine.leanToFullText(processor, envLTR, lean, null);
- full = processorLTR.leanToFullText(lean);
+ full = expertLTR.leanToFullText(lean);
assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
- //map = STextEngine.leanToFullMap(processor, envLTR, lean, null);
- map = processorLTR.leanToFullMap(lean);
+ map = expertLTR.leanToFullMap(lean);
label = msg + "leanToFullMap() LTR";
assertEquals(label, array_display(l2fMapLTR), array_display(map));
- // map = STextEngine.fullToLeanMap(processor, envLTR, text, null);
- map = processorLTR.fullToLeanMap(text);
+ map = expertLTR.fullToLeanMap(text);
label = msg + "fullToLeanMap() LTR";
assertEquals(label, array_display(f2lMapLTR), array_display(map));
- STextProcessorNew processorRTL = STextProcessorFactoryNew.getProcessor(descriptorID, envRTL);
-
- //lean = STextEngine.fullToLeanText(processor, envRTL, text, null);
- lean = processorRTL.fullToLeanText(text);
-
+ ISTextExpert expertRTL = STextExpertFactory.getExpert(type, envRTL);
+ lean = expertRTL.fullToLeanText(text);
assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
- //full = STextEngine.leanToFullText(processor, envRTL, lean, null);
- full = processorRTL.leanToFullText(lean);
+ full = expertRTL.leanToFullText(lean);
assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
- //map = STextEngine.leanToFullMap(processor, envRTL, lean, null);
- map = processorRTL.leanToFullMap(lean);
+ map = expertRTL.leanToFullMap(lean);
label = msg + "leanToFullMap() RTL";
assertEquals(label, array_display(l2fMapRTL), array_display(map));
- //map = STextEngine.fullToLeanMap(processor, envRTL, text, null);
- map = processorRTL.fullToLeanMap(text);
+ map = expertRTL.fullToLeanMap(text);
label = msg + "fullToLeanMap() RTL";
assertEquals(label, array_display(f2lMapRTL), array_display(map));
@@ -76,69 +63,54 @@ public class STextFullToLeanTest extends STextTestBase {
private void doTest2(String msg) {
String text, data, full, lean, model;
- int[] state = new int[1];
int state1, state2, state3;
data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
text = toUT16(data);
- state[0] = -1;
- //lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
+ ISTextExpertStateful expertLTR = STextExpertFactory.getPrivateExpert(type, envLTR);
+ expertLTR.setState(-1);
+ lean = expertLTR.fullToLeanText(text);
- // XXX state = -1?
- STextProcessorNew processorLTR = STextProcessorFactoryNew.getMultipassProcessor(descriptorID, envLTR);
- lean = processorLTR.fullToLeanText(text);
-
- state1 = state[0];
+ state1 = expertLTR.getState();
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);
- // XXX state = -1?
- STextProcessorNew processorLTR2 = STextProcessorFactoryNew.getMultipassProcessor(descriptorID, envLTR);
- full = processorLTR2.leanToFullText(lean);
+ ISTextExpertStateful expertLTR2 = STextExpertFactory.getPrivateExpert(type, envLTR);
+ expertLTR2.setState(-1);
+ full = expertLTR2.leanToFullText(lean);
assertEquals(msg + "LTR full", data, toPseudo(full));
- assertEquals(msg + "state from leanToFullText", state1, state[0]);
+ assertEquals(msg + "state from leanToFullText", state1, expertLTR2.getState());
data = "THIS IS A COMMENT LINE";
text = toUT16(data);
- state[0] = state1;
- // lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
- lean = processorLTR.fullToLeanText(text);
+ expertLTR.setState(state1);
+ lean = expertLTR.fullToLeanText(text);
- state2 = state[0];
+ state2 = expertLTR.getState();
model = "THIS IS A COMMENT LINE";
assertEquals(msg + "LTR lean2", model, toPseudo(lean));
- state[0] = state1;
- //full = STextEngine.leanToFullText(processor, envLTR, lean, state);
- full = processorLTR2.leanToFullText(lean);
+ expertLTR2.setState(state1);
+ full = expertLTR2.leanToFullText(lean);
assertEquals(msg + "LTR full2", data, toPseudo(full));
- assertEquals(msg + "state from leanToFullText2", state2, state[0]);
+ assertEquals(msg + "state from leanToFullText2", state2, expertLTR2.getState());
data = "SOME MORE */ where \"COL3\"@=123";
text = toUT16(data);
- state[0] = state2;
- //lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
- lean = processorLTR.fullToLeanText(text);
+ expertLTR.setState(state2);
+ lean = expertLTR.fullToLeanText(text);
- state3 = state[0];
+ state3 = expertLTR.getState();
model = "SOME MORE */ where \"COL3\"=123";
assertEquals(msg + "LTR lean3", model, toPseudo(lean));
- state[0] = state2;
-
- /* XXX this does not work, need re-do
- // XXX state?
- //full = STextEngine.leanToFullText(processor, envLTR, lean, state);
- full = processorLTR.leanToFullText(lean);
+ expertLTR.setState(state2);
+ full = expertLTR.leanToFullText(lean);
assertEquals(msg + "LTR full3", data, toPseudo(full));
- assertEquals(msg + "state from leanToFullText3", state3, state[0]);
- */
+ assertEquals(msg + "state from leanToFullText3", state3, expertLTR.getState());
}
public void testFullToLean() {
-
- descriptorID = "comma";
+ type = STextProcessorFactory.COMMA_DELIMITED;
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};
@@ -285,7 +257,7 @@ public class STextFullToLeanTest extends STextTestBase {
doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2);
// test fullToLeanText with initial state
- descriptorID = "sql";
+ type = STextProcessorFactory.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 ba85c79..56e45b4 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
@@ -19,17 +19,18 @@ import org.eclipse.equinox.bidi.advanced.*;
*/
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);
+ private STextEnvironment envLTR = new STextEnvironment("ar", false, STextEnvironment.ORIENT_LTR);
+ private STextEnvironment envRTL = new STextEnvironment("ar", false, STextEnvironment.ORIENT_RTL);
+
+ private ISTextExpert expertLTR = STextExpertFactory.getExpert(STextProcessorFactory.RTL_ARITHMETIC, envLTR);
+ private ISTextExpert expertRTL = STextExpertFactory.getExpert(STextProcessorFactory.RTL_ARITHMETIC, envRTL);
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 = processorLTR.leanToFullText(lean);
+ String fullLTR = expertLTR.leanToFullText(lean);
assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
- STextProcessorNew processorRTL = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.RTL_ARITHMETIC, envRTL);
- String fullRTL = processorRTL.leanToFullText(lean);
+ String fullRTL = expertRTL.leanToFullText(lean);
assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
}
@@ -46,6 +47,5 @@ public class STextMathTest extends STextTestBase {
verifyOneLine("Math #8", "8#BC*DE", "<&8#BC*DE&^", "8#BC*DE");
verifyOneLine("Math #9", "9#BC/DE", "<&9#BC/DE&^", "9#BC/DE");
verifyOneLine("Math #10", "10ab+cd-ef", "10ab+cd-ef", ">@10ab+cd-ef@^");
-
}
}
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 5cfebb6..e78a98b 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
@@ -47,38 +47,30 @@ public class STextMethodsTest extends STextTestBase {
private void doTestState() {
String data, lean, full, model;
- int[] state = new int[1];
- state[0] = -1;
- //processor = STextProcessorFactory.PROC_JAVA;
-
- STextProcessorNew processorNew = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.JAVA);
+ ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextProcessorFactory.JAVA);
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
- //full = STextEngine.leanToFullText(processor, null, lean, state);
- full = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.leanToFullText(lean);
model = "A=B+C;@*/ D@=E@+F;";
assertEquals("full3", model, toPseudo(full));
}
private void doTestOrientation() {
- int orient;
- orient = STextEnvironment.DEFAULT.getOrientation();
+ int orient = STextEnvironment.DEFAULT.getOrientation();
assertEquals("orient #1", STextEnvironment.ORIENT_LTR, orient);
orient = envIGN.getOrientation();
@@ -94,19 +86,16 @@ public class STextMethodsTest extends STextTestBase {
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);
+ ISTextExpert expertLTR = STextExpertFactory.getExpert(processorDefID, envLTR);
+ ISTextExpert expertRTL = STextExpertFactory.getExpert(processorDefID, envRTL);
+ ISTextExpert expertCRL = STextExpertFactory.getExpert(processorDefID, envCRL);
lean = toUT16(data);
- //full = STextEngine.leanToFullText(processor, envLTR, lean, null);
- full = processorLTR.leanToFullText(lean);
+ full = expertLTR.leanToFullText(lean);
assertEquals(label + "LTR full", resLTR, toPseudo(full));
- //full = STextEngine.leanToFullText(processor, envRTL, lean, null);
- full = processorRTL.leanToFullText(lean);
+ full = expertRTL.leanToFullText(lean);
assertEquals("label + RTL full", resRTL, toPseudo(full));
- //full = STextEngine.leanToFullText(processor, envCRL, lean, null);
- full = processorCRL.leanToFullText(lean);
+ full = expertCRL.leanToFullText(lean);
assertEquals(label + "CON full", resCon, toPseudo(full));
}
@@ -117,25 +106,20 @@ public class STextMethodsTest extends STextTestBase {
private void doTestLeanOffsets() {
String lean, data, label;
- int[] state = new int[1];
- //processor = STextProcessorFactory.PROC_JAVA;
- STextProcessorNew processorNew = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.JAVA);
+ ISTextExpert expert = STextExpertFactory.getExpert(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 = processorNew.leanBidiCharOffsets(lean);
+ offsets = expert.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 = processorNew.leanBidiCharOffsets(lean);
+ offsets = expert.leanBidiCharOffsets(lean);
model = new int[] {6, 10, 12};
label = "leanBidiCharOffsets() #2 ";
assertEquals(label, array_display(model), array_display(offsets));
@@ -144,28 +128,21 @@ 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;
- STextProcessorNew processorNew = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.COMMA_DELIMITED, envLTR);
- STextProcessorNew processorRTL = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.COMMA_DELIMITED, envRTL);
- STextProcessorNew processorCLR = STextProcessorFactoryNew.getMultipassProcessor(STextProcessorFactory.COMMA_DELIMITED, envCLR);
+ ISTextExpert expertLTR = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envLTR);
+ ISTextExpert expertRTL = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envRTL);
+ ISTextExpert expertCLR = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envCLR);
lean = toUT16(data);
- // full = STextEngine.leanToFullText(processor, envLTR, lean, null);
- full = processorNew.leanToFullText(lean);
- // offsets = STextEngine.fullBidiCharOffsets(processor, envLTR, full, null);
- offsets = processorNew.fullBidiCharOffsets(full);
+ full = expertLTR.leanToFullText(lean);
+ offsets = expertLTR.fullBidiCharOffsets(full);
msg = label + "LTR ";
assertEquals(msg, array_display(resLTR), array_display(offsets));
- //full = STextEngine.leanToFullText(processor, envRTL, lean, null);
- full = processorRTL.leanToFullText(lean);
- //offsets = STextEngine.fullBidiCharOffsets(processor, envRTL, full, null);
- offsets = processorRTL.fullBidiCharOffsets(full);
+ full = expertRTL.leanToFullText(lean);
+ offsets = expertRTL.fullBidiCharOffsets(full);
msg = label + "RTL ";
assertEquals(msg, array_display(resRTL), array_display(offsets));
- //full = STextEngine.leanToFullText(processor, envCLR, lean, null);
- full = processorCLR.leanToFullText(lean);
- // offsets = STextEngine.fullBidiCharOffsets(processor, envCLR, full, null);
- offsets = processorCLR.fullBidiCharOffsets(full);
+ full = expertCLR.leanToFullText(lean);
+ offsets = expertCLR.fullBidiCharOffsets(full);
msg = label + "CON ";
assertEquals(msg, array_display(resCon), array_display(offsets));
}
@@ -182,79 +159,74 @@ public class STextMethodsTest extends STextTestBase {
private void doTestDirection() {
String data, lean, full, model;
int dirA, dirH;
- STextProcessorNew processorRL = STextProcessorFactoryNew.getProcessor("test.MyCommaRL");
- dirA = processorRL.getCurDirection(toUT16("###"));
- dirH = processorRL.getCurDirection(toUT16("ABC"));
+ ISTextExpert expertRL = STextExpertFactory.getExpert("test.MyCommaRL");
+ dirA = expertRL.getCurDirection(toUT16("###"));
+ dirH = expertRL.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"));
+ ISTextExpert expertRR = STextExpertFactory.getExpert("test.MyCommaRR");
+ dirA = expertRR.getCurDirection(toUT16("###"));
+ dirH = expertRR.getCurDirection(toUT16("ABC"));
assertTrue("TestDirection #2", dirA == RTL && dirH == RTL);
- STextProcessorNew processorLL = STextProcessorFactoryNew.getProcessor("test.MyCommaLL");
+ ISTextExpert expertLL = STextExpertFactory.getExpert("test.MyCommaLL");
lean = toUT16("ABC,#DEF,HOST,com");
- full = processorLL.leanToFullText(lean);
+ full = expertLL.leanToFullText(lean);
assertEquals("TestDirection #9 full", "ABC@,#DEF@,HOST,com", toPseudo(full));
lean = toUT16("ABC,DEF,HOST,com");
- full = processorLL.leanToFullText(lean);
+ full = expertLL.leanToFullText(lean);
assertEquals("TestDirection #10 full", "ABC@,DEF@,HOST,com", toPseudo(full));
STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
- STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor("test.MyCommaRL", environment);
- dirA = processorNew.getCurDirection(toUT16("###"));
- dirH = processorNew.getCurDirection(toUT16("ABC"));
+ ISTextExpert expert = STextExpertFactory.getExpert("test.MyCommaRL", environment);
+ dirA = expert.getCurDirection(toUT16("###"));
+ dirH = expert.getCurDirection(toUT16("ABC"));
assertTrue("TestDirection #10.5", dirA == RTL && dirH == LTR);
lean = toUT16("ABC,#DEF,HOST,com");
- full = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.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 = processorNew.leanToFullText(lean);
+ full = expert.leanToFullText(lean);
model = "ABC,|DEF@,HOST,com";
assertEquals("TestDirection #16 full", model, toPseudo(full));
data = "ABc,|#DEF,HOST,com";
lean = toUT16(data);
- processorNew = STextProcessorFactoryNew.getProcessor("test.MyCommaRL", envRTLMIR);
- full = processorNew.leanToFullText(lean);
+ expert = STextExpertFactory.getExpert("test.MyCommaRL", envRTLMIR);
+ full = expert.leanToFullText(lean);
model = "ABc,|#DEF,HOST,com";
assertEquals("TestDirection #17 full", model, toPseudo(full));
- int dir = processorNew.getCurDirection(lean);
+ int dir = expert.getCurDirection(lean);
assertEquals("Test curDirection", RTL, dir);
}
@@ -286,12 +258,10 @@ public class STextMethodsTest extends STextTestBase {
doTestDirection();
- STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(STextProcessorFactory.COMMA_DELIMITED);
- // processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
+ ISTextExpert expert = STextExpertFactory.getExpert(STextProcessorFactory.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 = processorNew.leanToFullText(lean);
+ String full = expert.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/STextSomeMoreTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
index ef6f017..1cb83a8 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
@@ -25,23 +25,23 @@ public class STextSomeMoreTest extends STextTestBase {
assertFalse(env1.isProcessingNeeded());
assertTrue(env2.isProcessingNeeded());
- STextProcessorNew processor1 = STextProcessorFactoryNew.getProcessor("test.Processor1", env1);
- String full = processor1.leanToFullText("abcd");
+ ISTextExpert expert1 = STextExpertFactory.getExpert("test.Processor1", env1);
+ String full = expert1.leanToFullText("abcd");
assertEquals("@a@b@c@d", toPseudo(full));
- STextProcessorNew processor2 = STextProcessorFactoryNew.getProcessor("test.Processor2", env1);
+ ISTextExpert expert2 = STextExpertFactory.getExpert("test.Processor2", env1);
boolean catchFlag = false;
try {
- full = processor2.leanToFullText("abcd");
+ full = expert2.leanToFullText("abcd");
} catch (IllegalStateException e) {
catchFlag = true;
}
assertTrue("Catch missing indexOfSpecial", catchFlag);
catchFlag = false;
- STextProcessorNew processor3 = STextProcessorFactoryNew.getProcessor("test.Processor3", env1);
+ ISTextExpert expert3 = STextExpertFactory.getExpert("test.Processor3", env1);
try {
- full = processor3.leanToFullText("abcd");
+ full = expert3.leanToFullText("abcd");
} catch (IllegalStateException e) {
catchFlag = 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
index fd37792..e43b4f2 100644
--- 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
@@ -12,6 +12,7 @@ package org.eclipse.equinox.bidi;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+// TBD combine with STextUtil; remove duplicates of those two constants
public interface STextDirection {
/**
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 c77d70f..a98e8e9 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
@@ -62,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 STextProcessorNew#leanBidiCharOffsets(String)
+ * @see ISTextExpert#leanBidiCharOffsets(String)
*
* @param text the structured text string
* @param offsets an array of offsets to characters in <code>text</code>
@@ -189,7 +189,7 @@ public final class STextUtil {
// make sure that LRE/PDF are added around the string
STextProcessor processor = new STextProcessor(separators);
- STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env);
+ ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env);
return processorNew.leanToFullText(str);
}
@@ -214,7 +214,7 @@ public final class STextUtil {
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
if (!env.isProcessingNeeded())
return str;
- STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env);
+ ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env);
return processorNew.leanToFullText(str);
}
@@ -262,7 +262,7 @@ public final class STextUtil {
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
if (!env.isProcessingNeeded())
return str;
- STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env);
+ ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env);
return processorNew.fullToLeanText(str);
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
index 63a378a..996be6e 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
@@ -74,7 +74,7 @@ package org.eclipse.equinox.bidi.advanced;
* @author Matitiahu Allouche
*
*/
-public interface STextProcessorNew {
+public interface ISTextExpert {
/**
* Constant specifying that the base direction of a structured text is LTR.
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/ISTextExpertStateful.java
index 7314de8..f69a48f 100644
--- 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/ISTextExpertStateful.java
@@ -10,11 +10,15 @@
******************************************************************************/
package org.eclipse.equinox.bidi.advanced;
-public interface STextProcessorMultipassNew extends STextProcessorNew {
+public interface ISTextExpertStateful extends ISTextExpert {
+
+ public void setState(int state);
+
+ public int getState();
/**
* Resets non-shared processor state to initial.
*/
- public void reset();
+ public void resetState();
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
new file mode 100644
index 0000000..3518830
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.STextExpertImpl;
+import org.eclipse.equinox.bidi.internal.STextExpertMultipassImpl;
+
+final public class STextExpertFactory {
+
+ /**
+ * 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 sharedDefaultExperts = new HashMap(); // String type -> expert
+
+ static private Map sharedExperts = new HashMap(); // String type -> map of { environment -> expert }
+
+ static private ISTextExpert defaultExpert;
+
+ private STextExpertFactory() {
+ // prevents instantiation
+ }
+
+ static public ISTextExpert getExpert() {
+ if (defaultExpert == null) {
+ STextProcessor descriptor = new STextProcessor(defaultSeparators);
+ defaultExpert = new STextExpertImpl(descriptor, STextEnvironment.DEFAULT);
+ }
+ return defaultExpert;
+ }
+
+ static public ISTextExpert getExpert(String type) {
+ ISTextExpert processor;
+ synchronized (sharedDefaultExperts) {
+ processor = (ISTextExpert) sharedDefaultExperts.get(type);
+ if (processor == null) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ if (descriptor == null)
+ return null;
+ processor = new STextExpertImpl(descriptor, STextEnvironment.DEFAULT);
+ sharedDefaultExperts.put(type, processor);
+ }
+ }
+ return processor;
+ }
+
+ static public ISTextExpert getExpert(String type, STextEnvironment environment) {
+ ISTextExpert processor;
+ synchronized (sharedExperts) {
+ Map processors = (Map) sharedExperts.get(type);
+ if (processors == null) {
+ processors = new HashMap(); // environment -> processor
+ sharedExperts.put(type, processors);
+ }
+ processor = (ISTextExpert) processors.get(environment);
+ if (processor == null) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ if (descriptor == null)
+ return null;
+ processor = new STextExpertImpl(descriptor, environment);
+ processors.put(type, processor);
+ }
+ }
+ return processor;
+ }
+
+ static public ISTextExpert getExpert(STextProcessor descriptor, STextEnvironment environment) {
+ return new STextExpertImpl(descriptor, environment);
+ }
+
+ static public ISTextExpertStateful getPrivateExpert(String type) {
+ return getPrivateExpert(type, STextEnvironment.DEFAULT);
+ }
+
+ static public ISTextExpertStateful getPrivateExpert(String type, STextEnvironment environment) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ if (descriptor == null)
+ return null;
+ return new STextExpertMultipassImpl(descriptor, environment);
+ }
+
+}
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
deleted file mode 100644
index 0389dd8..0000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java
+++ /dev/null
@@ -1,90 +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.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/custom/STextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
index 7b183c8..e760eff 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
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.custom;
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.advanced.ISTextExpert;
import org.eclipse.equinox.bidi.internal.STextImpl;
/**
@@ -189,8 +189,8 @@ public class STextProcessor {
*
* @param separLocation the position returned by
* {@link #indexOfSpecial indexOfSpecial}. In calls to
- * {@link STextProcessorNew#leanToFullText leanToFullText} and other
- * methods of {@link STextProcessorNew} specifying a non-null
+ * {@link ISTextExpert#leanToFullText leanToFullText} and other
+ * methods of {@link ISTextExpert} 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
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/STextExpertImpl.java
index 3cc752f..985495c 100644
--- 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/STextExpertImpl.java
@@ -11,17 +11,18 @@
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.advanced.ISTextExpert;
import org.eclipse.equinox.bidi.custom.STextProcessor;
-public class STextProcessorImplNew implements STextProcessorNew {
+public class STextExpertImpl implements ISTextExpert {
protected STextProcessor structuredTextDescriptor;
protected STextEnvironment environment;
+ // XXX potentially problematic - implementation might write into it?
private final static int[] initialState = new int[] {0};
- public STextProcessorImplNew(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
+ public STextExpertImpl(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
this.structuredTextDescriptor = structuredTextDescriptor;
this.environment = environment;
}
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/STextExpertMultipassImpl.java
index 230dc16..c46ee3c 100644
--- 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/STextExpertMultipassImpl.java
@@ -11,10 +11,10 @@
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.advanced.ISTextExpertStateful;
import org.eclipse.equinox.bidi.custom.STextProcessor;
-public class STextProcessorMultipassImplNew extends STextProcessorImplNew implements STextProcessorMultipassNew {
+public class STextExpertMultipassImpl extends STextExpertImpl implements ISTextExpertStateful {
/**
* Constant to use in the first element of the <code>state</code>
@@ -24,11 +24,11 @@ public class STextProcessorMultipassImplNew extends STextProcessorImplNew implem
*/
public static final int STATE_INITIAL = 0;
- private int[] state;
+ private int[] state = new int[] {STATE_INITIAL};
- public STextProcessorMultipassImplNew(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
+ public STextExpertMultipassImpl(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
super(structuredTextDescriptor, environment);
- reset();
+ resetState();
}
public String leanToFullText(String text) {
@@ -59,8 +59,16 @@ public class STextProcessorMultipassImplNew extends STextProcessorImplNew implem
return structuredTextDescriptor.getDirection(environment, text);
}
- public void reset() {
- state = new int[] {STATE_INITIAL};
+ public void resetState() {
+ state[0] = STATE_INITIAL;
+ }
+
+ public void setState(int newState) {
+ state[0] = newState;
+ }
+
+ public int getState() {
+ return state[0];
}
}
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 cdbc3f4..c102319 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
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal;
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.advanced.ISTextExpert;
import org.eclipse.equinox.bidi.custom.*;
public class STextImpl {
@@ -155,45 +155,45 @@ public class STextImpl {
/**
* When the orientation is <code>ORIENT_LTR</code> and the
* structured text has a RTL base direction,
- * {@link STextProcessorNew#leanToFullText leanToFullText}
+ * {@link ISTextExpert#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 STextProcessorNew#leanToFullText leanToFullText}
+ * {@link ISTextExpert#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 STextProcessorNew#leanToFullText leanToFullText}
+ * direction, {@link ISTextExpert#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 STextProcessorNew#leanToFullText leanToFullText}
+ * direction, {@link ISTextExpert#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 STextProcessorNew#leanToFullText leanToFullText}
+ * {@link ISTextExpert#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 STextProcessorNew#leanToFullText leanToFullText}
+ * {@link ISTextExpert#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 STextProcessorNew#leanToFullText leanToFullText} does not add any directional
+ * {@link ISTextExpert#leanToFullText leanToFullText} does not add any directional
* formatting characters as either prefix or suffix of the <i>full</i> text.
* <p>
- * @see STextProcessorNew#leanToFullText STextEngine.leanToFullText
+ * @see ISTextExpert#leanToFullText STextEngine.leanToFullText
*/
public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
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 6fb4fcd..bb4dff1 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
@@ -11,7 +11,7 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
+import org.eclipse.equinox.bidi.advanced.ISTextExpert;
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 STextProcessorNew#leanToFullText}
+ * {@link ISTextExpert#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 STextProcessorNew#leanToFullText explanation of state in leanToFullText
+ * @see ISTextExpert#leanToFullText explanation of state in leanToFullText
*
* @author Matitiahu Allouche
*/
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 4c504a2..c5d3bb9 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
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
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.advanced.ISTextExpert;
import org.eclipse.equinox.bidi.custom.*;
/**
@@ -21,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 STextProcessorNew#leanToFullText}
+ * {@link ISTextExpert#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).
@@ -29,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 STextProcessorNew#leanToFullText explanation of state in leanToFullText
+ * @see ISTextExpert#leanToFullText explanation of state in leanToFullText
*
* @author Matitiahu Allouche
*/
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 90a53f0..9fbe5e4 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
@@ -11,7 +11,7 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
+import org.eclipse.equinox.bidi.advanced.ISTextExpert;
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 STextProcessorNew#leanToFullText}
+ * {@link ISTextExpert#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 STextProcessorNew#leanToFullText explanation of state in leanToFullText
+ * @see ISTextExpert#leanToFullText explanation of state in leanToFullText
*
* @author Matitiahu Allouche
*/