summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatitiahu Allouche2011-08-15 11:07:19 (EDT)
committer Oleg Besedin2011-08-15 11:07:19 (EDT)
commit96133d5719013acd843bd601f78ba0d706de1d20 (patch)
treece7bddae76387c7443dfbcc7f078acc42f0376fa
parent9dfa830ee7dcc2978dc6a34bcd801a1577cc4eab (diff)
downloadrt.equinox.bundles-96133d5719013acd843bd601f78ba0d706de1d20.zip
rt.equinox.bundles-96133d5719013acd843bd601f78ba0d706de1d20.tar.gz
rt.equinox.bundles-96133d5719013acd843bd601f78ba0d706de1d20.tar.bz2
Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/plugin.xml24
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java26
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java32
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java55
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java47
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java)252
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java34
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTest.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java)6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java)4
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java)2
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java)6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java)4
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java)4
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java (renamed from bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java)4
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/tests/STextTestSuite.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessor.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java)538
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java48
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java)240
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java34
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java61
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java22
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextOffsets.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java)832
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java7
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java5
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java58
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java74
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java138
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java15
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java20
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java15
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java2
-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.java17
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java5
49 files changed, 1291 insertions, 1432 deletions
diff --git a/bundles/org.eclipse.equinox.bidi.tests/plugin.xml b/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
index 3e80188..dcd6a39 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
+++ b/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
@@ -10,32 +10,32 @@
type="test">
</typeDescription>
<typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestProcessor1"
- description="Test processor 1"
- type="test.Processor1">
+ class="org.eclipse.equinox.bidi.internal.tests.TestHandler1"
+ description="Test Handler 1"
+ type="test.Handler1">
</typeDescription>
<typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestProcessor2"
- description="Test processor 2"
- type="test.Processor2">
+ class="org.eclipse.equinox.bidi.internal.tests.TestHandler2"
+ description="Test Handler 2"
+ type="test.Handler2">
</typeDescription>
<typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestProcessor3"
- description="Test processor 3"
- type="test.Processor3">
+ class="org.eclipse.equinox.bidi.internal.tests.TestHandler3"
+ description="Test Handler 3"
+ type="test.Handler3">
</typeDescription>
<typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaRL"
+ class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRL"
description="Test my comma RL"
type="test.MyCommaRL">
</typeDescription>
<typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaRR"
+ class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRR"
description="Test my comma RR"
type="test.MyCommaRR">
</typeDescription>
<typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaLL"
+ class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaLL"
description="Test my comma LL"
type="test.MyCommaLL">
</typeDescription>
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 a412afc..0e76dac 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
@@ -11,46 +11,46 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextProcessorFactory;
-import org.eclipse.equinox.bidi.advanced.STextExpertFactory;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.advanced.STextExpertFactory;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
- * Tests contribution of BiDi processors.
+ * Tests contribution of BiDi handlers.
*/
public class STextExtensibilityTest extends STextTestBase {
public void testBaseContributions() {
- String[] types = STextProcessorFactory.getAllProcessorIDs();
+ String[] types = STextTypeHandlerFactory.getAllHandlerIDs();
assertNotNull(types);
assertTrue(types.length > 0);
// check one of the types that we know should be there
assertTrue(isTypePresent(types, "regex"));
- STextProcessor processor = STextProcessorFactory.getProcessor("regex");
- assertNotNull(processor);
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler("regex");
+ assertNotNull(handler);
}
public void testOtherContributions() {
- String[] types = STextProcessorFactory.getAllProcessorIDs();
+ String[] types = STextTypeHandlerFactory.getAllHandlerIDs();
assertNotNull(types);
assertTrue(types.length > 0);
// check the type added by the test bundle
assertTrue(isTypePresent(types, "test"));
- STextProcessor processor = STextProcessorFactory.getProcessor("test");
- assertNotNull(processor);
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler("test");
+ assertNotNull(handler);
- processor = STextProcessorFactory.getProcessor("badtest");
- assertNull(processor);
+ handler = STextTypeHandlerFactory.getHandler("badtest");
+ assertNull(handler);
String data, lean, full, model;
data = "ABC.DEF:HOST-COM=HELLO";
lean = toUT16(data);
- processor = STextProcessorFactory.getProcessor("test");
+ handler = STextTypeHandlerFactory.getHandler("test");
ISTextExpert expert = STextExpertFactory.getExpert("test");
full = expert.leanToFullText(lean);
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 9d36b87..a01e7a6 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,7 +11,7 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
import org.eclipse.equinox.bidi.advanced.*;
/**
@@ -43,30 +43,30 @@ public class STextExtensionsTest extends STextTestBase {
public void testExtensions() {
String data;
- expert = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, env);
doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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;
- expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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;
- expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.EMAIL, env);
data = toUT16("peter.pan") + "@" + toUT16("DEF.GHI");
doTest2("Email #9", data, "peter.pan@DEF@.GHI");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.FILE, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.FILE, env);
doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.JAVA, env);
+ expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.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;");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.PROPERTY, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.REGEXP, env);
+ expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.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;
- expert = STextExpertFactory.getExpert(STextProcessorFactory.REGEXP, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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;
- expert = STextExpertFactory.getExpert(STextProcessorFactory.SQL, env);
+ expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.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");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.SYSTEM_USER, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.SYSTEM_USER, env);
doTest1("System #1", "HOST(JACK)", "HOST@(JACK)");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.UNDERSCORE, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.UNDERSCORE, env);
doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.URL, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.URL, env);
doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.XPATH, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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 ");
- expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env);
+ expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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 30e8789..d6f1987 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.STextProcessorFactory;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
import org.eclipse.equinox.bidi.advanced.*;
/**
@@ -110,7 +110,7 @@ public class STextFullToLeanTest extends STextTestBase {
}
public void testFullToLean() {
- type = STextProcessorFactory.COMMA_DELIMITED;
+ type = STextTypeHandlerFactory.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};
@@ -257,7 +257,7 @@ public class STextFullToLeanTest extends STextTestBase {
doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2);
// test fullToLeanText with initial state
- type = STextProcessorFactory.SQL;
+ type = STextTypeHandlerFactory.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 56e45b4..3ebef2d 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,7 +11,7 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
import org.eclipse.equinox.bidi.advanced.*;
/**
@@ -22,8 +22,8 @@ public class STextMathTest extends STextTestBase {
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 ISTextExpert expertLTR = STextExpertFactory.getExpert(STextTypeHandlerFactory.RTL_ARITHMETIC, envLTR);
+ private ISTextExpert expertRTL = STextExpertFactory.getExpert(STextTypeHandlerFactory.RTL_ARITHMETIC, envRTL);
private void verifyOneLine(String msg, String data, String resLTR, String resRTL) {
String lean = toUT16(data);
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 e78a98b..3429077 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
@@ -12,7 +12,7 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextDirection;
-import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
import org.eclipse.equinox.bidi.advanced.*;
/**
@@ -47,26 +47,31 @@ public class STextMethodsTest extends STextTestBase {
private void doTestState() {
String data, lean, full, model;
- ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextProcessorFactory.JAVA);
+ ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA);
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
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 = expert.leanToFullText(lean);
-
- model = "A=B+C; D=E+F;";
+ model = data;
assertEquals("full2", model, toPseudo(full));
- data = "A=B+C;*/ D=E+F;";
+
+ data = "SOME MORE COMMENTS";
lean = toUT16(data);
full = expert.leanToFullText(lean);
+ model = data;
+ assertEquals("full3", model, toPseudo(full));
+ data = "A=B+C;*/ D=E+F;";
+ lean = toUT16(data);
+ full = expert.leanToFullText(lean);
model = "A=B+C;@*/ D@=E@+F;";
- assertEquals("full3", model, toPseudo(full));
+ assertEquals("full4", model, toPseudo(full));
}
private void doTestOrientation() {
@@ -83,12 +88,12 @@ public class STextMethodsTest extends STextTestBase {
assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient);
}
- private void doTestOrient(String processorDefID, String label, String data, String resLTR, String resRTL, String resCon) {
+ private void doTestOrient(String handlerDefID, String label, String data, String resLTR, String resRTL, String resCon) {
String full, lean;
- ISTextExpert expertLTR = STextExpertFactory.getExpert(processorDefID, envLTR);
- ISTextExpert expertRTL = STextExpertFactory.getExpert(processorDefID, envRTL);
- ISTextExpert expertCRL = STextExpertFactory.getExpert(processorDefID, envCRL);
+ ISTextExpert expertLTR = STextExpertFactory.getExpert(handlerDefID, envLTR);
+ ISTextExpert expertRTL = STextExpertFactory.getExpert(handlerDefID, envRTL);
+ ISTextExpert expertCRL = STextExpertFactory.getExpert(handlerDefID, envCRL);
lean = toUT16(data);
full = expertLTR.leanToFullText(lean);
@@ -106,7 +111,7 @@ public class STextMethodsTest extends STextTestBase {
private void doTestLeanOffsets() {
String lean, data, label;
- ISTextExpert expert = STextExpertFactory.getExpert(STextProcessorFactory.JAVA);
+ ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA);
int[] offsets;
int[] model;
@@ -128,9 +133,9 @@ public class STextMethodsTest extends STextTestBase {
private void doTestFullOffsets(String label, String data, int[] resLTR, int[] resRTL, int[] resCon) {
String full, lean, msg;
int[] offsets;
- ISTextExpert expertLTR = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envLTR);
- ISTextExpert expertRTL = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envRTL);
- ISTextExpert expertCLR = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envCLR);
+ ISTextExpert expertLTR = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, envLTR);
+ ISTextExpert expertRTL = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, envRTL);
+ ISTextExpert expertCLR = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, envCLR);
lean = toUT16(data);
full = expertLTR.leanToFullText(lean);
@@ -238,15 +243,15 @@ public class STextMethodsTest extends STextTestBase {
doTestOrientation();
- 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");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #1 ", "", "", "", "");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
+ doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
doTestSkipProcessing();
@@ -258,7 +263,7 @@ public class STextMethodsTest extends STextTestBase {
doTestDirection();
- ISTextExpert expert = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED);
+ ISTextExpert expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.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 = expert.leanToFullText(lean);
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
deleted file mode 100644
index 9ebb2d0..0000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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;
-
-
-/**
- * Tests null processor
- */
-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];
- state[0] = 3;
- full = STextEngine.leanToFullText(null, null, "abc", state);
- assertEquals("leanToFullText with state", "abc", full);
- int[] offsets = STextEngine.leanBidiCharOffsets(null, null, "abc", null);
- assertEquals("leanBidiCharOffsets", 0, offsets.length);
- offsets = STextEngine.fullBidiCharOffsets(null, null, "abc", null);
- assertEquals("fullBidiCharOffsets", 0, offsets.length);
- String lean = STextEngine.fullToLeanText(null, null, "abc", null);
- assertEquals("fullToLeanText", "abc", lean);
- lean = STextEngine.fullToLeanText(null, null, "abc", state);
- assertEquals("fullToLeanText with state", "abc", lean);
- int[] map = STextEngine.leanToFullMap(null, null, "abc", null);
- int[] model = {0, 1, 2};
- assertEquals("leanToFullMap", array_display(model), array_display(map));
- map = STextEngine.fullToLeanMap(null, null, "abc", null);
- 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/STextUtilTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java
index 89c437b..b4661a8 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/STextProcessorTest.java
@@ -1,126 +1,126 @@
-/*******************************************************************************
- * 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 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
- */
-
-public class STextUtilTest extends STextTestBase {
-
- private static final String HEBREW = "iw";
-
- private static final String HEBREW2 = "he";
-
- private static final String ARABIC = "ar";
-
- private static final String FARSI = "fa";
-
- private static final String URDU = "ur";
-
- private Locale locale;
-
- protected void setUp() throws Exception {
- super.setUp();
- locale = Locale.getDefault();
- }
-
- protected void tearDown() {
- Locale.setDefault(locale);
- }
-
- private void doTest1(String data, String result) {
- Locale.setDefault(Locale.ENGLISH);
- String full = STextUtil.process(toUT16(data));
- assertEquals("Util #1 full EN - ", data, toPseudo(full));
- Locale.setDefault(new Locale(HEBREW2));
- full = STextUtil.process(toUT16(data));
- assertEquals("Util #1 full HE - ", result, toPseudo(full));
- Locale.setDefault(new Locale(ARABIC));
- full = STextUtil.process(toUT16(data));
- assertEquals("Util #1 full AR - ", result, toPseudo(full));
- Locale.setDefault(new Locale(FARSI));
- full = STextUtil.process(toUT16(data));
- assertEquals("Util #1 full FA - ", result, toPseudo(full));
- Locale.setDefault(new Locale(URDU));
- full = STextUtil.process(toUT16(data));
- assertEquals("Util #1 full UR - ", result, toPseudo(full));
- Locale.setDefault(new Locale(HEBREW));
- full = STextUtil.process(toUT16(data));
- String ful2 = STextUtil.process(toUT16(data), (String) null);
- assertEquals("Util #1 full - ", result, toPseudo(full));
- assertEquals("Util #1 ful2 - ", result, toPseudo(ful2));
- String lean = STextUtil.deprocess(full);
- assertEquals("Util #1 lean - ", data, toPseudo(lean));
- }
-
- private void doTest2(String msg, String data, String result) {
- doTest2(msg, data, result, data);
- }
-
- private void doTest2(String msg, String data, String result, String resLean) {
- String full = STextUtil.process(toUT16(data), "*");
- assertEquals(msg + "full", result, toPseudo(full));
- String lean = STextUtil.deprocess(full);
- assertEquals(msg + "lean", resLean, toPseudo(lean));
- }
-
- private void doTest3(String msg, String data, String result) {
- doTest3(msg, data, result, data);
- }
-
- private void doTest3(String msg, String data, String result, String resLean) {
- 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, descriptor);
- assertEquals(msg + "lean", resLean, toPseudo(lean));
- }
-
- private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) {
- String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix;
- String lean = toUT16(data);
- String full = STextUtil.insertMarks(lean, offsets, direction, affix);
- assertEquals(txt, result, toPseudo(full));
- }
-
- public void testBidiComplexUtil() {
-
- // Test process() and deprocess() with default delimiters
- doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
- // Test process() and deprocess() with specified delimiters
- doTest2("Util #2.1 - ", "", "");
- doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC");
- doTest2("Util #2.3 - ", "abc", "abc");
- doTest2("Util #2.4 - ", "!abc", ">@!abc@^");
- doTest2("Util #2.5 - ", "abc!", ">@abc!@^");
- doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^");
- // Test process() and deprocess() with specified expression type
- doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^");
- doTest3("Util #3.2 - ", "", "");
- doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
- // Test insertMarks()
- doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G");
- doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^");
- doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G");
- doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^");
- doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, "");
- doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, "");
- doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG");
- doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^");
- }
-}
+/*******************************************************************************
+ * 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 java.util.Locale;
+import org.eclipse.equinox.bidi.STextProcessor;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
+
+/**
+ * Tests methods in BidiComplexUtil
+ */
+
+public class STextProcessorTest extends STextTestBase {
+
+ private static final String HEBREW = "iw";
+
+ private static final String HEBREW2 = "he";
+
+ private static final String ARABIC = "ar";
+
+ private static final String FARSI = "fa";
+
+ private static final String URDU = "ur";
+
+ private Locale locale;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ locale = Locale.getDefault();
+ }
+
+ protected void tearDown() {
+ Locale.setDefault(locale);
+ }
+
+ private void doTest1(String data, String result) {
+ Locale.setDefault(Locale.ENGLISH);
+ String full = STextProcessor.process(toUT16(data));
+ assertEquals("Util #1 full EN - ", data, toPseudo(full));
+ Locale.setDefault(new Locale(HEBREW2));
+ full = STextProcessor.process(toUT16(data));
+ assertEquals("Util #1 full HE - ", result, toPseudo(full));
+ Locale.setDefault(new Locale(ARABIC));
+ full = STextProcessor.process(toUT16(data));
+ assertEquals("Util #1 full AR - ", result, toPseudo(full));
+ Locale.setDefault(new Locale(FARSI));
+ full = STextProcessor.process(toUT16(data));
+ assertEquals("Util #1 full FA - ", result, toPseudo(full));
+ Locale.setDefault(new Locale(URDU));
+ full = STextProcessor.process(toUT16(data));
+ assertEquals("Util #1 full UR - ", result, toPseudo(full));
+ Locale.setDefault(new Locale(HEBREW));
+ full = STextProcessor.process(toUT16(data));
+ String ful2 = STextProcessor.process(toUT16(data), (String) null);
+ assertEquals("Util #1 full - ", result, toPseudo(full));
+ assertEquals("Util #1 ful2 - ", result, toPseudo(ful2));
+ String lean = STextProcessor.deprocess(full);
+ assertEquals("Util #1 lean - ", data, toPseudo(lean));
+ }
+
+ private void doTest2(String msg, String data, String result) {
+ doTest2(msg, data, result, data);
+ }
+
+ private void doTest2(String msg, String data, String result, String resLean) {
+ String full = STextProcessor.process(toUT16(data), "*");
+ assertEquals(msg + "full", result, toPseudo(full));
+ String lean = STextProcessor.deprocess(full);
+ assertEquals(msg + "lean", resLean, toPseudo(lean));
+ }
+
+ private void doTest3(String msg, String data, String result) {
+ doTest3(msg, data, result, data);
+ }
+
+ private void doTest3(String msg, String data, String result, String resLean) {
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler(STextTypeHandlerFactory.COMMA_DELIMITED);
+ String full = STextProcessor.process(toUT16(data), handler);
+ assertEquals(msg + "full", result, toPseudo(full));
+ String lean = STextProcessor.deprocess(full, handler);
+ assertEquals(msg + "lean", resLean, toPseudo(lean));
+ }
+
+ private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) {
+ String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix;
+ String lean = toUT16(data);
+ String full = STextProcessor.insertMarks(lean, offsets, direction, affix);
+ assertEquals(txt, result, toPseudo(full));
+ }
+
+ public void testBidiComplexUtil() {
+
+ // Test process() and deprocess() with default delimiters
+ doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
+ // Test process() and deprocess() with specified delimiters
+ doTest2("Util #2.1 - ", "", "");
+ doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC");
+ doTest2("Util #2.3 - ", "abc", "abc");
+ doTest2("Util #2.4 - ", "!abc", ">@!abc@^");
+ doTest2("Util #2.5 - ", "abc!", ">@abc!@^");
+ doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^");
+ // Test process() and deprocess() with specified expression type
+ doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^");
+ doTest3("Util #3.2 - ", "", "");
+ doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
+ // Test insertMarks()
+ doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G");
+ doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^");
+ doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G");
+ doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^");
+ doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, "");
+ doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, "");
+ doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG");
+ doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^");
+ }
+}
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 1cb83a8..0166a2d 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,11 +25,11 @@ public class STextSomeMoreTest extends STextTestBase {
assertFalse(env1.isProcessingNeeded());
assertTrue(env2.isProcessingNeeded());
- ISTextExpert expert1 = STextExpertFactory.getExpert("test.Processor1", env1);
+ ISTextExpert expert1 = STextExpertFactory.getExpert("test.Handler1", env1);
String full = expert1.leanToFullText("abcd");
assertEquals("@a@b@c@d", toPseudo(full));
- ISTextExpert expert2 = STextExpertFactory.getExpert("test.Processor2", env1);
+ ISTextExpert expert2 = STextExpertFactory.getExpert("test.Handler2", env1);
boolean catchFlag = false;
try {
full = expert2.leanToFullText("abcd");
@@ -39,7 +39,7 @@ public class STextSomeMoreTest extends STextTestBase {
assertTrue("Catch missing indexOfSpecial", catchFlag);
catchFlag = false;
- ISTextExpert expert3 = STextExpertFactory.getExpert("test.Processor3", env1);
+ ISTextExpert expert3 = STextExpertFactory.getExpert("test.Handler3", env1);
try {
full = expert3.leanToFullText("abcd");
} catch (IllegalStateException e) {
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 b720803..c62cbee 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
@@ -11,8 +11,8 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextProcessorFactory;
import org.eclipse.equinox.bidi.STextStringRecord;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
/**
* Tests the StringRecord class
@@ -24,7 +24,7 @@ public class STextStringRecordTest extends STextTestBase {
// check handling of invalid arguments
catchFlag = false;
try {
- sr = STextStringRecord.addRecord(null, 1, STextProcessorFactory.EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord(null, 1, STextTypeHandlerFactory.EMAIL, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
@@ -35,38 +35,38 @@ public class STextStringRecordTest extends STextTestBase {
} catch (IllegalArgumentException e) {
catchFlag = true;
}
- assertTrue("Catch null processor argument", catchFlag);
+ assertTrue("Catch null handler argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 0, STextProcessorFactory.EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord("abc", 0, STextTypeHandlerFactory.EMAIL, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid segment count argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, -1, 1);
+ sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, -1, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid start argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 4, 1);
+ sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, 4, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid start argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 0, 0);
+ sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, 0, 0);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch invalid limit argument", catchFlag);
catchFlag = false;
try {
- sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 0, 5);
+ sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.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.EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord(str, 1, STextTypeHandlerFactory.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.EMAIL, 0, 1);
+ sr = STextStringRecord.addRecord(str, 1, STextTypeHandlerFactory.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.EMAIL, 0, 2);
- sr.addSegment(STextProcessorFactory.JAVA, 4, 5);
- sr.addSegment(STextProcessorFactory.FILE, 6, 7);
+ sr = STextStringRecord.addRecord("thisisalongstring", 3, STextTypeHandlerFactory.EMAIL, 0, 2);
+ sr.addSegment(STextTypeHandlerFactory.JAVA, 4, 5);
+ sr.addSegment(STextTypeHandlerFactory.FILE, 6, 7);
catchFlag = false;
try {
- sr.addSegment(STextProcessorFactory.EMAIL, 10, 13);
+ sr.addSegment(STextTypeHandlerFactory.EMAIL, 10, 13);
} catch (IllegalStateException e) {
catchFlag = true;
}
assertTrue("Catch too many segments", catchFlag);
assertEquals(3, sr.getSegmentCount());
- assertEquals(STextProcessorFactory.EMAIL, sr.getProcessor(0));
- assertEquals(STextProcessorFactory.JAVA, sr.getProcessor(1));
- assertEquals(STextProcessorFactory.FILE, sr.getProcessor(2));
+ assertEquals(STextTypeHandlerFactory.EMAIL, sr.getHandler(0));
+ assertEquals(STextTypeHandlerFactory.JAVA, sr.getHandler(1));
+ assertEquals(STextTypeHandlerFactory.FILE, sr.getHandler(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/STextTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTest.java
index 6d8149a..2292c0d 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTest.java
@@ -10,9 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
-public class STextTest extends STextProcessor {
+public class STextTest extends STextTypeHandler {
public STextTest() {
super("-=.:");
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java
index 294d98f..ae2bd7e 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java
@@ -14,7 +14,7 @@ package org.eclipse.equinox.bidi.internal.tests;
import junit.framework.TestCase;
/**
- * Base functionality for the processor tests.
+ * Base functionality for the handler tests.
*/
public class STextTestBase extends TestCase {
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/TestHandler1.java
index 2d3f4de..3974caa 100644
--- 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/TestHandler1.java
@@ -13,7 +13,7 @@ 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 class TestHandler1 extends STextTypeHandler {
public int getSpecialsCount(STextEnvironment env) {
return 1;
@@ -26,8 +26,8 @@ public class TestProcessor1 extends STextProcessor {
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);
+ STextTypeHandler.insertMark(text, charTypes, offsets, i);
+ STextTypeHandler.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/TestHandler2.java
index fd75890..acf1f8a 100644
--- 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/TestHandler2.java
@@ -11,9 +11,9 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
-public class TestProcessor2 extends STextProcessor {
+public class TestHandler2 extends STextTypeHandler {
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/TestHandler3.java
index 4a1f77d..354a8c9 100644
--- 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/TestHandler3.java
@@ -13,7 +13,7 @@ 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 class TestHandler3 extends STextTypeHandler {
public int getSpecialsCount(STextEnvironment env) {
return 1;
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/TestHandlerMyComma.java
index e295661..89688a0 100644
--- 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/TestHandlerMyComma.java
@@ -13,9 +13,9 @@ 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;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
-public class TestProcessorMyComma extends STextProcessor {
+public class TestHandlerMyComma extends STextTypeHandler {
private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
protected final static int LTR = STextDirection.DIR_LTR;
@@ -24,7 +24,7 @@ public class TestProcessorMyComma extends STextProcessor {
final int dirArabic;
final int dirHebrew;
- public TestProcessorMyComma(int dirArabic, int dirHebrew) {
+ public TestHandlerMyComma(int dirArabic, int dirHebrew) {
this.dirArabic = dirArabic;
this.dirHebrew = 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/TestHandlerMyCommaLL.java
index 1755396..c901c86 100644
--- 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/TestHandlerMyCommaLL.java
@@ -10,9 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.tests;
-public class TestProcessorMyCommaLL extends TestProcessorMyComma {
+public class TestHandlerMyCommaLL extends TestHandlerMyComma {
- public TestProcessorMyCommaLL() {
+ public TestHandlerMyCommaLL() {
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/TestHandlerMyCommaRL.java
index 6917def..99d51e8 100644
--- 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/TestHandlerMyCommaRL.java
@@ -10,9 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.tests;
-public class TestProcessorMyCommaRL extends TestProcessorMyComma {
+public class TestHandlerMyCommaRL extends TestHandlerMyComma {
- public TestProcessorMyCommaRL() {
+ public TestHandlerMyCommaRL() {
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/TestHandlerMyCommaRR.java
index 1501704..aa92a01 100644
--- 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/TestHandlerMyCommaRR.java
@@ -10,9 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.tests;
-public class TestProcessorMyCommaRR extends TestProcessorMyComma {
+public class TestHandlerMyCommaRR extends TestHandlerMyComma {
- public TestProcessorMyCommaRR() {
+ public TestHandlerMyCommaRR() {
super(RTL, RTL);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/tests/STextTestSuite.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/tests/STextTestSuite.java
index 7b3f48c..1224705 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/tests/STextTestSuite.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/tests/STextTestSuite.java
@@ -23,12 +23,11 @@ public class STextTestSuite extends TestSuite {
public STextTestSuite() {
addTestSuite(STextExtensibilityTest.class);
addTestSuite(STextMethodsTest.class);
- addTestSuite(STextNullProcessorTest.class);
addTestSuite(STextFullToLeanTest.class);
addTestSuite(STextExtensionsTest.class);
addTestSuite(STextMathTest.class);
addTestSuite(STextSomeMoreTest.class);
- addTestSuite(STextUtilTest.class);
+ addTestSuite(STextProcessorTest.class);
addTestSuite(STextStringRecordTest.class);
}
} \ No newline at end of file
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 e43b4f2..9cb0156 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,7 +12,7 @@ package org.eclipse.equinox.bidi;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-// TBD combine with STextUtil; remove duplicates of those two constants
+// TBD combine with STextProcessor; 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/STextProcessor.java
index a98e8e9..6f90bfe 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/STextProcessor.java
@@ -1,269 +1,269 @@
-/*******************************************************************************
- * 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.advanced.*;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
-
-/**
- * This class provides a number of convenience functions facilitating the
- * processing of structured text.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- *
- * @author Matitiahu Allouche
- */
-public final class STextUtil {
-
- /**
- * The default set of separators used to segment a string: dot, colon, slash, backslash.
- */
- public static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$
-
- // left to right mark
- private static final char LRM = '\u200e';
-
- // left to right mark
- private static final char RLM = '\u200f';
-
- // left to right embedding
- private static final char LRE = '\u202a';
-
- // right to left embedding
- private static final char RLE = '\u202b';
-
- // pop directional format
- private static final char PDF = '\u202c';
-
- /**
- * Prevents instantiation.
- */
- private STextUtil() {
- // empty
- }
-
- /**
- * This method adds directional marks to the given text before the characters
- * specified in the given array of offsets. It can be used to add a prefix and/or
- * a suffix of directional formatting characters.
- * <p>
- * The directional marks will be LRMs for structured text strings with LTR base
- * direction and RLMs for strings with RTL base direction.
- * </p><p>
- * 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 ISTextExpert#leanBidiCharOffsets(String)
- *
- * @param text the structured text string
- * @param offsets an array of offsets to characters in <code>text</code>
- * before which an LRM or RLM will be inserted.
- * 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 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
- * directional marks (LRMs or RLMs) added at the specified offsets,
- * and directional formatting characters (LRE, RLE, PDF) added
- * as prefix and suffix if so required.
- */
- public static String insertMarks(String text, int[] offsets, int direction, boolean affix) {
- int textLen = text.length();
- if (textLen == 0)
- return ""; //$NON-NLS-1$
-
- String curPrefix, curSuffix, full;
- char curMark, c;
- char[] fullChars;
- if (direction == STextDirection.DIR_LTR) {
- curMark = LRM;
- curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$
- curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$
- } else {
- curMark = RLM;
- curPrefix = "\u202b\u200f"; /* RLE+RLM *///$NON-NLS-1$
- curSuffix = "\u200f\u202c"; /* RLM+PDF *///$NON-NLS-1$
- }
- // add marks at offsets
- if ((offsets != null) && (offsets.length > 0)) {
- int offLen = offsets.length;
- fullChars = new char[textLen + offLen];
- int added = 0;
- for (int i = 0, j = 0; i < textLen; i++) {
- c = text.charAt(i);
- if ((j < offLen) && (i == offsets[j])) {
- fullChars[i + added] = curMark;
- added++;
- j++;
- }
- fullChars[i + added] = c;
- }
- full = new String(fullChars);
- } else {
- full = text;
- }
- if (affix)
- return curPrefix + full + curSuffix;
- return full;
- }
-
- /**
- * Process the given text and return a string with appropriate
- * directional formatting characters. This is equivalent to calling
- * {@link #process(String str, String separators)} with the default
- * set of separators.
- * <p>
- * The processing adds directional formatting characters so that presentation
- * using the Unicode Bidirectional Algorithm will provide the expected result.
- * The text is segmented according to the provided separators.
- * Each segment has the Unicode Bidi Algorithm applied to it,
- * but as a whole, the string is oriented left to right.
- * </p><p>
- * For example, a file path such as <tt>d:\myfolder\FOLDER\MYFILE.java</tt>
- * (where capital letters indicate RTL text) should render as
- * <tt>d:\myfolder\REDLOF\ELIFYM.java</tt>.
- * </p>
- * @param str the text to be processed
- * @return the processed string
- */
- public static String process(String str) {
- return process(str, defaultSeparators);
- }
-
- /**
- * Process a string that has a particular semantic meaning to render
- * it correctly on bidi locales.
- * @see #process(String)
- * @param str the text to process
- * @param separators separators by which the string will be segmented
- * @return the processed string
- */
- public static String process(String str, String separators) {
- if ((str == null) || (str.length() <= 1))
- return str;
-
- // do not process a string that has already been processed.
- if (str.charAt(0) == LRE && str.charAt(str.length() - 1) == PDF)
- return str;
-
- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- if (!env.isProcessingNeeded())
- return str;
- // do not process a string if all the following conditions are true:
- // a) it has no RTL characters
- // b) it starts with a LTR character
- // c) it ends with a LTR character or a digit
- boolean isStringBidi = false;
- int strLength = str.length();
- char c;
- for (int i = 0; i < strLength; i++) {
- c = str.charAt(i);
- if (((c >= 0x05d0) && (c <= 0x07b1)) || ((c >= 0xfb1d) && (c <= 0xfefc))) {
- isStringBidi = true;
- break;
- }
- }
- while (!isStringBidi) {
- if (!Character.isLetter(str.charAt(0)))
- break;
- c = str.charAt(strLength - 1);
- if (!Character.isDigit(c) && !Character.isLetter(c))
- break;
- return str;
- }
-
- if (separators == null)
- separators = defaultSeparators;
-
- // make sure that LRE/PDF are added around the string
- STextProcessor processor = new STextProcessor(separators);
- ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env);
- return processorNew.leanToFullText(str);
- }
-
- /**
- * Processes a string that has a particular semantic meaning to render
- * it correctly on bidi locales.
- * @see #process(String)
- * @param str the text to process
- * @param processor a processor instance appropriate for the type of the structured text
- * @return the processed string
- */
- public static String process(String str, STextProcessor processor) {
- if ((str == null) || (str.length() <= 1))
- return str;
-
- // do not process a string that has already been processed.
- char c = str.charAt(0);
- if (((c == LRE) || (c == RLE)) && str.charAt(str.length() - 1) == PDF)
- return str;
-
- // make sure that LRE/PDF are added around the string
- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- if (!env.isProcessingNeeded())
- return str;
- ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env);
- return processorNew.leanToFullText(str);
- }
-
- /**
- * Removes directional formatting characters in the given string.
- * @param str string with directional characters to remove
- * @return string without directional formatting characters
- */
- public static String deprocess(String str) {
- if ((str == null) || (str.length() <= 1))
- return str;
- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- if (!env.isProcessingNeeded())
- return str;
-
- StringBuffer buf = new StringBuffer();
- int strLen = str.length();
- for (int i = 0; i < strLen; i++) {
- char c = str.charAt(i);
- switch (c) {
- case LRM :
- continue;
- case LRE :
- continue;
- case PDF :
- continue;
- default :
- buf.append(c);
- }
- }
- return buf.toString();
- }
-
- /**
- * Removes directional formatting characters in the given string.
- * @param str string with directional characters to remove
- * @param processor appropriate for the structured text
- * @return string without directional formatting characters
- */
- public static String deprocess(String str, STextProcessor processor) {
- if ((str == null) || (str.length() <= 1))
- return str;
-
- // make sure that LRE/PDF are added around the string
- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- if (!env.isProcessingNeeded())
- return str;
- ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env);
- return processorNew.fullToLeanText(str);
- }
-
-}
+/*******************************************************************************
+ * 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.advanced.*;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
+
+/**
+ * This class provides a number of convenience functions facilitating the
+ * processing of structured text.
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ *
+ * @author Matitiahu Allouche
+ */
+public final class STextProcessor {
+
+ /**
+ * The default set of separators used to segment a string: dot, colon, slash, backslash.
+ */
+ public static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$
+
+ // left to right mark
+ private static final char LRM = '\u200e';
+
+ // left to right mark
+ private static final char RLM = '\u200f';
+
+ // left to right embedding
+ private static final char LRE = '\u202a';
+
+ // right to left embedding
+ private static final char RLE = '\u202b';
+
+ // pop directional format
+ private static final char PDF = '\u202c';
+
+ /**
+ * Prevents instantiation.
+ */
+ private STextProcessor() {
+ // empty
+ }
+
+ /**
+ * This method adds directional marks to the given text before the characters
+ * specified in the given array of offsets. It can be used to add a prefix and/or
+ * a suffix of directional formatting characters.
+ * <p>
+ * The directional marks will be LRMs for structured text strings with LTR base
+ * direction and RLMs for strings with RTL base direction.
+ * </p><p>
+ * 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 ISTextExpert#leanBidiCharOffsets(String)
+ *
+ * @param text the structured text string
+ * @param offsets an array of offsets to characters in <code>text</code>
+ * before which an LRM or RLM will be inserted.
+ * 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 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
+ * directional marks (LRMs or RLMs) added at the specified offsets,
+ * and directional formatting characters (LRE, RLE, PDF) added
+ * as prefix and suffix if so required.
+ */
+ public static String insertMarks(String text, int[] offsets, int direction, boolean affix) {
+ int textLen = text.length();
+ if (textLen == 0)
+ return ""; //$NON-NLS-1$
+
+ String curPrefix, curSuffix, full;
+ char curMark, c;
+ char[] fullChars;
+ if (direction == STextDirection.DIR_LTR) {
+ curMark = LRM;
+ curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$
+ curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$
+ } else {
+ curMark = RLM;
+ curPrefix = "\u202b\u200f"; /* RLE+RLM *///$NON-NLS-1$
+ curSuffix = "\u200f\u202c"; /* RLM+PDF *///$NON-NLS-1$
+ }
+ // add marks at offsets
+ if ((offsets != null) && (offsets.length > 0)) {
+ int offLen = offsets.length;
+ fullChars = new char[textLen + offLen];
+ int added = 0;
+ for (int i = 0, j = 0; i < textLen; i++) {
+ c = text.charAt(i);
+ if ((j < offLen) && (i == offsets[j])) {
+ fullChars[i + added] = curMark;
+ added++;
+ j++;
+ }
+ fullChars[i + added] = c;
+ }
+ full = new String(fullChars);
+ } else {
+ full = text;
+ }
+ if (affix)
+ return curPrefix + full + curSuffix;
+ return full;
+ }
+
+ /**
+ * Process the given text and return a string with appropriate
+ * directional formatting characters. This is equivalent to calling
+ * {@link #process(String str, String separators)} with the default
+ * set of separators.
+ * <p>
+ * The processing adds directional formatting characters so that presentation
+ * using the Unicode Bidirectional Algorithm will provide the expected result.
+ * The text is segmented according to the provided separators.
+ * Each segment has the Unicode Bidi Algorithm applied to it,
+ * but as a whole, the string is oriented left to right.
+ * </p><p>
+ * For example, a file path such as <tt>d:\myfolder\FOLDER\MYFILE.java</tt>
+ * (where capital letters indicate RTL text) should render as
+ * <tt>d:\myfolder\REDLOF\ELIFYM.java</tt>.
+ * </p>
+ * @param str the text to be processed
+ * @return the processed string
+ */
+ public static String process(String str) {
+ return process(str, defaultSeparators);
+ }
+
+ /**
+ * Process a string that has a particular semantic meaning to render
+ * it correctly on bidi locales.
+ * @see #process(String)
+ * @param str the text to process
+ * @param separators separators by which the string will be segmented
+ * @return the processed string
+ */
+ public static String process(String str, String separators) {
+ if ((str == null) || (str.length() <= 1))
+ return str;
+
+ // do not process a string that has already been processed.
+ if (str.charAt(0) == LRE && str.charAt(str.length() - 1) == PDF)
+ return str;
+
+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
+ if (!env.isProcessingNeeded())
+ return str;
+ // do not process a string if all the following conditions are true:
+ // a) it has no RTL characters
+ // b) it starts with a LTR character
+ // c) it ends with a LTR character or a digit
+ boolean isStringBidi = false;
+ int strLength = str.length();
+ char c;
+ for (int i = 0; i < strLength; i++) {
+ c = str.charAt(i);
+ if (((c >= 0x05d0) && (c <= 0x07b1)) || ((c >= 0xfb1d) && (c <= 0xfefc))) {
+ isStringBidi = true;
+ break;
+ }
+ }
+ while (!isStringBidi) {
+ if (!Character.isLetter(str.charAt(0)))
+ break;
+ c = str.charAt(strLength - 1);
+ if (!Character.isDigit(c) && !Character.isLetter(c))
+ break;
+ return str;
+ }
+
+ if (separators == null)
+ separators = defaultSeparators;
+
+ // make sure that LRE/PDF are added around the string
+ STextTypeHandler handler = new STextTypeHandler(separators);
+ ISTextExpert expert = STextExpertFactory.getExpert(handler, env);
+ return expert.leanToFullText(str);
+ }
+
+ /**
+ * Processes a string that has a particular semantic meaning to render
+ * it correctly on bidi locales.
+ * @see #process(String)
+ * @param str the text to process
+ * @param handler a handler instance appropriate for the type of the structured text
+ * @return the processed string
+ */
+ public static String process(String str, STextTypeHandler handler) {
+ if ((str == null) || (str.length() <= 1))
+ return str;
+
+ // do not process a string that has already been processed.
+ char c = str.charAt(0);
+ if (((c == LRE) || (c == RLE)) && str.charAt(str.length() - 1) == PDF)
+ return str;
+
+ // make sure that LRE/PDF are added around the string
+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
+ if (!env.isProcessingNeeded())
+ return str;
+ ISTextExpert expert = STextExpertFactory.getExpert(handler, env);
+ return expert.leanToFullText(str);
+ }
+
+ /**
+ * Removes directional formatting characters in the given string.
+ * @param str string with directional characters to remove
+ * @return string without directional formatting characters
+ */
+ public static String deprocess(String str) {
+ if ((str == null) || (str.length() <= 1))
+ return str;
+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
+ if (!env.isProcessingNeeded())
+ return str;
+
+ StringBuffer buf = new StringBuffer();
+ int strLen = str.length();
+ for (int i = 0; i < strLen; i++) {
+ char c = str.charAt(i);
+ switch (c) {
+ case LRM :
+ continue;
+ case LRE :
+ continue;
+ case PDF :
+ continue;
+ default :
+ buf.append(c);
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Removes directional formatting characters in the given string.
+ * @param str string with directional characters to remove
+ * @param handler appropriate for the structured text
+ * @return string without directional formatting characters
+ */
+ public static String deprocess(String str, STextTypeHandler handler) {
+ if ((str == null) || (str.length() <= 1))
+ return str;
+
+ // make sure that LRE/PDF are added around the string
+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
+ if (!env.isProcessingNeeded())
+ return str;
+ ISTextExpert expert = STextExpertFactory.getExpert(handler, env);
+ return expert.fullToLeanText(str);
+ }
+
+}
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 f28bd6b..60d48d8 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
@@ -25,7 +25,7 @@ import java.lang.ref.SoftReference;
* A string may be itself entirely a structured text, or it may contain
* segments each of which is a structured text of a given type. Each such
* segment is identified by its starting and ending offsets within the
- * string, and by the processor which is appropriate to handle it.
+ * string, and by the handler which is appropriate to handle it.
*/
public class STextStringRecord {
/**
@@ -57,8 +57,8 @@ public class STextStringRecord {
// reference to the recorded string
private String string;
- // reference to the processors of the STT segments in the recorded string
- private String[] processors;
+ // reference to the handlers of the STT segments in the recorded string
+ private String[] handlers;
// reference to the boundaries of the STT segments in the recorded string
// (entries 0, 2, 4, ... are start offsets; entries 1, 3, 5, ... are
@@ -74,7 +74,7 @@ public class STextStringRecord {
/**
* Record a string in the pool. The caller must specify the number
- * of segments in the record (at least 1), and the processor, starting
+ * of segments in the record (at least 1), and the handler, starting
* and ending offsets for the first segment.
*
* @param string the string to record.
@@ -82,9 +82,9 @@ public class STextStringRecord {
* @param segmentCount number of segments allowed in this string.
* This number must be >= 1.
*
- * @param processor the processor appropriate to handle the type
+ * @param handler the handler appropriate to handle the type
* of structured text present in the first segment.
- * It may be one of the pre-defined processor instances, or it may be an instance
+ * It may be one of the pre-defined handler 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
@@ -102,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, String processorID, int start, int limit) {
+ public static STextStringRecord addRecord(String string, int segmentCount, String handlerID, int start, int limit) {
if (string == null)
throw new IllegalArgumentException("The string argument must not be null!"); //$NON-NLS-1$
if (segmentCount < 1)
@@ -124,24 +124,24 @@ public class STextStringRecord {
}
hashArray[last] = string.hashCode();
for (int i = 0; i < record.usedSegmentCount; i++)
- record.processors[i] = null;
+ record.handlers[i] = null;
if (segmentCount > record.totalSegmentCount) {
- record.processors = new String[segmentCount];
+ record.handlers = new String[segmentCount];
record.boundaries = new short[segmentCount * 2];
record.totalSegmentCount = segmentCount;
}
record.usedSegmentCount = 0;
record.string = string;
- record.addSegment(processorID, start, limit);
+ record.addSegment(handlerID, start, limit);
return record;
}
/**
* Add a second or further segment to a record.
*
- * @param processor the processor appropriate to handle the type
+ * @param handler the handler appropriate to handle the type
* of structured text present in this segment.
- * It may be one of the pre-defined processor instances, or it may be an instance
+ * It may be one of the pre-defined handler 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
@@ -151,7 +151,7 @@ public class STextStringRecord {
* greater than the <code>start</code> argument and not greater
* than the length of the string.
*
- * @throws IllegalArgumentException if <code>processor</code> is null,
+ * @throws IllegalArgumentException if <code>handler</code> is null,
* or if <code>start</code> or <code>limit</code> have invalid
* values.
* @throws IllegalStateException if the current segment exceeds the
@@ -159,16 +159,16 @@ public class STextStringRecord {
* in the call to {@link #addRecord addRecord} which created
* the STextStringRecord instance.
*/
- 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$
+ public void addSegment(String handlerID, int start, int limit) {
+ if (handlerID == null)
+ throw new IllegalArgumentException("The handler 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$
if (limit <= start || limit > string.length())
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] = processorID;
+ handlers[usedSegmentCount] = handlerID;
boundaries[usedSegmentCount * 2] = (short) start;
boundaries[usedSegmentCount * 2 + 1] = (short) limit;
usedSegmentCount++;
@@ -184,8 +184,8 @@ public class STextStringRecord {
* records this string.<br>
* Once a record has been found, the number of its segments can
* be retrieved using {@link #getSegmentCount getSegmentCount},
- * its processor can
- * be retrieved using {@link #getProcessor getProcessor},
+ * its handler can
+ * be retrieved using {@link #getHandler getHandler},
* its starting offset can
* be retrieved using {@link #getStart getStart},
* its ending offset can
@@ -236,7 +236,7 @@ public class STextStringRecord {
}
/**
- * Retrieve the processor of a given segment.
+ * Retrieve the handler of a given segment.
*
* @param segmentNumber number of the segment about which information
* is required. It must be >= 0 and less than the number of
@@ -244,7 +244,7 @@ public class STextStringRecord {
* in the call to {@link #addRecord addRecord} which created
* the STextStringRecord instance.
*
- * @return the processor to handle the structured text in the segment
+ * @return the handler to handle the structured text in the segment
* specified by <code>segmentNumber</code>.
*
* @throws IllegalArgumentException if <code>segmentNumber</code>
@@ -252,9 +252,9 @@ public class STextStringRecord {
*
* @see #getSegmentCount
*/
- public String getProcessor(int segmentNumber) {
+ public String getHandler(int segmentNumber) {
checkSegmentNumber(segmentNumber);
- return processors[segmentNumber];
+ return handlers[segmentNumber];
}
/**
@@ -315,7 +315,7 @@ public class STextStringRecord {
if (record == null)
continue;
record.boundaries = null;
- record.processors = null;
+ record.handlers = null;
record.totalSegmentCount = 0;
record.usedSegmentCount = 0;
recordRefs[i].clear();
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/STextTypeHandlerFactory.java
index 1887b08..41701a9 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/STextTypeHandlerFactory.java
@@ -1,120 +1,120 @@
-/*******************************************************************************
- * 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.STextTypesCollector;
-
-/**
- * This class provides access to registered structured text processors.
- *
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-final public class STextProcessorFactory {
-
- /**
- * Structured text processor for property file statements. It expects the following format:
- * <pre>
- * name=value
- * </pre>
- */
- 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
- * parts separated by underscores:
- * <pre>
- * part1_part2_part3
- * </pre>
- */
- public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$
-
- /**
- * Structured text processor for comma-delimited lists, such as:
- * <pre>
- * part1,part2,part3
- * </pre>
- */
- public static final String COMMA_DELIMITED = "comma"; //$NON-NLS-1$
-
- /**
- * Structured text processor for strings with the following format:
- * <pre>
- * system(user)
- * </pre>
- */
- public static final String SYSTEM_USER = "system"; //$NON-NLS-1$
-
- /**
- * Structured text processor for directory and file paths.
- */
- public static final String FILE = "file"; //$NON-NLS-1$
-
- /**
- * Structured text processor for e-mail addresses.
- */
- public static final String EMAIL = "email"; //$NON-NLS-1$
-
- /**
- * Structured text processor for URLs.
- */
- public static final String URL = "url"; //$NON-NLS-1$
-
- /**
- * Structured text processor for regular expressions, possibly spanning multiple lines.
- */
- public static final String REGEXP = "regex"; //$NON-NLS-1$
-
- /**
- * Structured text processor for XPath expressions.
- */
- public static final String XPATH = "xpath"; //$NON-NLS-1$
-
- /**
- * Structured text processor for Java code, possibly spanning multiple lines.
- */
- public static final String JAVA = "java"; //$NON-NLS-1$
-
- /**
- * Structured text processor for SQL statements, possibly spanning multiple lines.
- */
- public static final String SQL = "sql"; //$NON-NLS-1$
-
- /**
- * Structured text processor for arithmetic expressions, possibly with a RTL base direction.
- */
- public static final String RTL_ARITHMETIC = "math"; //$NON-NLS-1$
-
- /**
- * Prevents instantiation
- */
- private STextProcessorFactory() {
- // placeholder
- }
-
- /**
- * Retrieve all IDs of registered structured text processors.
- * @return an array of text processor IDs.
- */
- static public String[] getAllProcessorIDs() {
- return STextTypesCollector.getInstance().getTypes();
- }
-
- /**
- * Obtain a structured text processor of a given type.
- * @param id string identifying processor
- * @return a processor of the required type, or <code>null</code> if the type is unknown
- */
- static public STextProcessor getProcessor(String id) {
- return STextTypesCollector.getInstance().getProcessor(id);
- }
-
-}
+/*******************************************************************************
+ * 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.STextTypeHandler;
+import org.eclipse.equinox.bidi.internal.STextTypesCollector;
+
+/**
+ * This class provides access to registered structured text handlers.
+ *
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+final public class STextTypeHandlerFactory {
+
+ /**
+ * Structured text handler for property file statements. It expects the following format:
+ * <pre>
+ * name=value
+ * </pre>
+ */
+ public static final String PROPERTY = "property"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for compound names. It expects text to be made of one or more
+ * parts separated by underscores:
+ * <pre>
+ * part1_part2_part3
+ * </pre>
+ */
+ public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for comma-delimited lists, such as:
+ * <pre>
+ * part1,part2,part3
+ * </pre>
+ */
+ public static final String COMMA_DELIMITED = "comma"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for strings with the following format:
+ * <pre>
+ * system(user)
+ * </pre>
+ */
+ public static final String SYSTEM_USER = "system"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for directory and file paths.
+ */
+ public static final String FILE = "file"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for e-mail addresses.
+ */
+ public static final String EMAIL = "email"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for URLs.
+ */
+ public static final String URL = "url"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for regular expressions, possibly spanning multiple lines.
+ */
+ public static final String REGEXP = "regex"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for XPath expressions.
+ */
+ public static final String XPATH = "xpath"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for Java code, possibly spanning multiple lines.
+ */
+ public static final String JAVA = "java"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for SQL statements, possibly spanning multiple lines.
+ */
+ public static final String SQL = "sql"; //$NON-NLS-1$
+
+ /**
+ * Structured text handler for arithmetic expressions, possibly with a RTL base direction.
+ */
+ public static final String RTL_ARITHMETIC = "math"; //$NON-NLS-1$
+
+ /**
+ * Prevents instantiation
+ */
+ private STextTypeHandlerFactory() {
+ // placeholder
+ }
+
+ /**
+ * Retrieve all IDs of registered structured text handlers.
+ * @return an array of text handler IDs.
+ */
+ static public String[] getAllHandlerIDs() {
+ return STextTypesCollector.getInstance().getTypes();
+ }
+
+ /**
+ * Obtain a structured text handler of a given type.
+ * @param id string identifying handler
+ * @return a handler of the required type, or <code>null</code> if the type is unknown
+ */
+ static public STextTypeHandler getHandler(String id) {
+ return STextTypesCollector.getInstance().getHandler(id);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
index 996be6e..e1b986f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
@@ -14,10 +14,10 @@ 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.
+ * Several common handlers are included in <b>STextEngine</b>. For handlers
+ * supplied by other packages, a handler instance can be obtained using the
+ * {@link org.eclipse.equinox.bidi.STextTypeHandlerFactory#getHandler}
+ * method for the registered handlers, or by instantiating a private handler.
* </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.
@@ -100,7 +100,7 @@ public interface ISTextExpert {
* Add directional formatting characters to a structured text
* to ensure correct presentation.
*
- * @param processor the processor applicable to the text. If <code>null</code>,
+ * @param handler the handler 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
@@ -122,11 +122,11 @@ public interface ISTextExpert {
* 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
+ * @param handler designates a handler 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.
+ * the handler's behavior. If <code>null</code>, the default environment is used.
*
* @param text is the structured text string.
*
@@ -151,10 +151,10 @@ public interface ISTextExpert {
* 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 handler designates a handler instance
*
* @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
+ * the handler's behavior. If <code>null</code>, the default environment is used.
*
* @param text is the structured text string
*
@@ -173,10 +173,10 @@ public interface ISTextExpert {
* Remove directional formatting characters which were added to a
* structured text string to ensure correct presentation.
*
- * @param processor designates a processor instance
+ * @param handler designates a handler instance
*
* @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
+ * the handler's behavior. If <code>null</code>, the default environment is used.
*
* @param text is the structured text string including directional formatting characters.
*
@@ -195,10 +195,10 @@ public interface ISTextExpert {
* 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 handler designates a handler instance
*
* @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
+ * the handler's behavior. If <code>null</code>, the default environment is used.
*
* @param text is the structured text string including directional formatting characters.
*
@@ -225,10 +225,10 @@ public interface ISTextExpert {
* or suffixed depending on the {@link STextEnvironment#getOrientation orientation}
* of the GUI component used for display.
* </p>
- * @param processor designates a processor instance
+ * @param handler designates a handler instance
*
* @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
+ * the handler's behavior. If <code>null</code>, the default environment is used.
*
* @param text is the structured text string including directional formatting characters
*
@@ -248,10 +248,10 @@ public interface ISTextExpert {
* 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 handler designates a handler instance
*
* @param environment specifies an environment whose characteristics may affect
- * the processor's behavior. If <code>null</code>, the default environment is used.
+ * the handler's behavior. If <code>null</code>, the default environment is used.
*
* @param text is the structured text string
*
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java
index f69a48f..cebf2fd 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java
@@ -17,7 +17,7 @@ public interface ISTextExpertStateful extends ISTextExpert {
public int getState();
/**
- * Resets non-shared processor state to initial.
+ * Resets non-shared expert state to initial.
*/
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
index 3518830..220de73 100644
--- 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
@@ -12,10 +12,9 @@ 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;
+import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
+import org.eclipse.equinox.bidi.internal.STextImpl;
final public class STextExpertFactory {
@@ -36,49 +35,49 @@ final public class STextExpertFactory {
static public ISTextExpert getExpert() {
if (defaultExpert == null) {
- STextProcessor descriptor = new STextProcessor(defaultSeparators);
- defaultExpert = new STextExpertImpl(descriptor, STextEnvironment.DEFAULT);
+ STextTypeHandler handler = new STextTypeHandler(defaultSeparators);
+ defaultExpert = new STextImpl(handler, STextEnvironment.DEFAULT, null);
}
return defaultExpert;
}
static public ISTextExpert getExpert(String type) {
- ISTextExpert processor;
+ ISTextExpert expert;
synchronized (sharedDefaultExperts) {
- processor = (ISTextExpert) sharedDefaultExperts.get(type);
- if (processor == null) {
- STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
- if (descriptor == null)
+ expert = (ISTextExpert) sharedDefaultExperts.get(type);
+ if (expert == null) {
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type);
+ if (handler == null)
return null;
- processor = new STextExpertImpl(descriptor, STextEnvironment.DEFAULT);
- sharedDefaultExperts.put(type, processor);
+ expert = new STextImpl(handler, STextEnvironment.DEFAULT, null);
+ sharedDefaultExperts.put(type, expert);
}
}
- return processor;
+ return expert;
}
static public ISTextExpert getExpert(String type, STextEnvironment environment) {
- ISTextExpert processor;
+ ISTextExpert expert;
synchronized (sharedExperts) {
- Map processors = (Map) sharedExperts.get(type);
- if (processors == null) {
- processors = new HashMap(); // environment -> processor
- sharedExperts.put(type, processors);
+ Map experts = (Map) sharedExperts.get(type);
+ if (experts == null) {
+ experts = new HashMap(); // environment -> expert
+ sharedExperts.put(type, experts);
}
- processor = (ISTextExpert) processors.get(environment);
- if (processor == null) {
- STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
- if (descriptor == null)
+ expert = (ISTextExpert) experts.get(environment);
+ if (expert == null) {
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type);
+ if (handler == null)
return null;
- processor = new STextExpertImpl(descriptor, environment);
- processors.put(type, processor);
+ expert = new STextImpl(handler, environment, null);
+ experts.put(type, expert);
}
}
- return processor;
+ return expert;
}
- static public ISTextExpert getExpert(STextProcessor descriptor, STextEnvironment environment) {
- return new STextExpertImpl(descriptor, environment);
+ static public ISTextExpert getExpert(STextTypeHandler handler, STextEnvironment environment) {
+ return new STextImpl(handler, environment, new int[1]);
}
static public ISTextExpertStateful getPrivateExpert(String type) {
@@ -86,10 +85,10 @@ final public class STextExpertFactory {
}
static public ISTextExpertStateful getPrivateExpert(String type, STextEnvironment environment) {
- STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
- if (descriptor == null)
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type);
+ if (handler == null)
return null;
- return new STextExpertMultipassImpl(descriptor, environment);
+ return new STextImpl(handler, environment, new int[1]);
}
}
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 f74bd7b..ba1f0b7 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
@@ -35,32 +35,32 @@ public class STextCharTypes {
private static final int CHARTYPES_ADD = 2;
- final protected STextProcessor processor;
+ final protected STextTypeHandler handler;
final protected STextEnvironment environment;
final protected String text;
// 1 byte for each char in text
private byte[] types;
- // structured text direction. -1 means not yet computed; -2 means within processor.getDirection
+ // structured text direction. -1 means not yet computed; -2 means within handler.getDirection
private int direction = -1;
/**
* Constructor
*
- * @param processor is the processor handling this occurrence of
+ * @param handler is the handler handling this occurrence of
* structured text.
*
* @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
+ * the handler. This parameter may be specified as
* <code>null</code>, in which case the
* {@link STextEnvironment#DEFAULT DEFAULT}
* environment should be assumed.
*
* @param text is the text whose characters are analyzed.
*/
- public STextCharTypes(STextProcessor processor, STextEnvironment environment, String text) {
- this.processor = processor;
+ public STextCharTypes(STextTypeHandler handler, STextEnvironment environment, String text) {
+ this.handler = handler;
this.environment = environment;
this.text = text;
types = new byte[text.length()];
@@ -68,7 +68,7 @@ public class STextCharTypes {
public int getDirection() {
if (direction < 0)
- direction = processor.getDirection(environment, text, this);
+ direction = handler.getDirection(environment, text, this);
return direction;
}
@@ -96,10 +96,10 @@ public class STextCharTypes {
byte charType = Character.getDirectionality(text.charAt(index));
if (charType == B) {
if (direction < 0) {
- if (direction < -1) // called by processor.getDirection
+ if (direction < -1) // called by handler.getDirection
return charType; // avoid infinite recursion
- direction = -2; // signal we go within processor.getDirection
- direction = processor.getDirection(environment, text, this);
+ direction = -2; // signal we go within handler.getDirection
+ direction = handler.getDirection(environment, text, this);
}
charType = (direction == STextEnvironment.ORIENT_RTL) ? R : L;
}
@@ -125,7 +125,7 @@ public class STextCharTypes {
* be displayed.
*
* @param envir is the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
+ * the handler. This parameter may be specified as
* <code>null</code>, in which case the
* {@link STextEnvironment#DEFAULT DEFAULT}
* environment should be assumed.
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextOffsets.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextOffsets.java
index 5358ad5..4ac9270 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextOffsets.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextOffsets.java
@@ -67,7 +67,7 @@ public class STextOffsets {
/**
* Insert an offset value in the offset array so that the array
* stays in ascending order.
- * @param procData is a group of data accessible to processors.
+ * @param procData is a group of data accessible to handlers.
* @param offset is the value to insert.
*/
public void insertOffset(STextCharTypes charTypes, int offset) {
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/STextTypeHandler.java
index e760eff..5715ea1 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/STextTypeHandler.java
@@ -1,416 +1,416 @@
-/*******************************************************************************
- * 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.custom;
-
-import org.eclipse.equinox.bidi.STextDirection;
-import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.internal.STextImpl;
-
-/**
- * Generic processor to be used as superclass (base class)
- * for specific structured text processors.
- * <p>
- * Here are some guidelines about how to write structured text
- * processors.
- * <ul>
- * <li>Processor instances may be accessed simultaneously by
- * several threads. They should have no instance variables.</li>
- * <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
- * tokens. See {@link #getSeparators getSeparators}.</li>
- * <li>the direction which governs the display of tokens
- * one after the other. See {@link #getDirection getDirection}.</li>
- * <li>the number of special cases which need to be handled by
- * code specific to that processor.
- * See {@link #getSpecialsCount getSpecialsCount}.</li>
- * </ul></li>
- * <li>Before starting deeper analysis of the submitted text, the common
- * logic gives to the processor a chance to shorten the processus by
- * invoking its {@link #skipProcessing skipProcessing} method.</li>
- * <li>The common logic then analyzes the text to segment it into tokens
- * according to the appearance of separators (as retrieved using
- * {@link #getSeparators getSeparators}).</li>
- * <li>If the processor indicated a positive number of special cases as
- * return value from its {@link #getSpecialsCount getSpecialsCount}
- * method, the common logic will repeatedly invoke the processor's
- * {@link #indexOfSpecial indexOfSpecial} method to let it signal the
- * presence of special strings which may further delimit the source text.</li>
- * <li>When such a special case is signalled by the processor, the common
- * logic will call the processor's {@link #processSpecial processSpecial}
- * method to give it the opportunity to handle it as needed. Typical
- * actions that the processor may perform are to add directional marks
- * inconditionally (by calling {@link #insertMark insertMark} or
- * conditionally (by calling {@link #processSeparator processSeparator}).</li>
- * </ul>
- *
- * @author Matitiahu Allouche
- */
-public class STextProcessor {
-
- final private String separators;
-
- /**
- * Creates a new instance of the STextProcessor class.
- */
- public STextProcessor() {
- separators = ""; //$NON-NLS-1$
- }
-
- /**
- * Creates a new instance of the STextProcessor class.
- * @param separators string consisting of characters that split the text into fragments
- */
- public STextProcessor(String separators) {
- this.separators = separators;
- }
-
- /**
- * 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 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.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @param text is the structured text string before
- * addition of any directional formatting characters.
- *
- * @param charTypes is a parameter received by <code>indexOfSpecial</code>
- * uniquely to be used as argument for calls to methods which
- * need it.
- *
- * @param offsets is a parameter received by <code>indexOfSpecial</code>
- * uniquely to be used as argument for calls to methods which
- * need it.
- *
- * @param caseNumber number of the special case to locate.
- * This number varies from 1 to the number of special cases
- * returned by {@link #getSpecialsCount getSpecialsCount}
- * for this processor.
- * The meaning of this number is internal to the class
- * implementing <code>indexOfSpecial</code>.
- *
- * @param fromIndex the index within <code>text</code> to start
- * the search from.
- *
- * @return the position where the start of the special case
- * corresponding to <code>caseNumber</code> was located.
- * The method must return the first occurrence of whatever
- * identifies the start of the special case starting from
- * <code>fromIndex</code>. The method does not have to check if
- * this occurrence appears within the scope of another special
- * case (e.g. a comment starting delimiter within the scope of
- * a literal or vice-versa).
- * <br>If no occurrence is found, the method must return -1.
- *
- * @throws IllegalStateException If not overridden, this method throws an
- * <code>IllegalStateException</code>. This is appropriate behavior
- * (and does not need to be overridden) for processors whose
- * number of special cases is zero, which means that
- * <code>indexOfSpecial</code> should never be called for them.
- */
- public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
- // This method must be overridden by all subclasses with special cases.
- throw new IllegalStateException("A processor with specialsCount > 0 must have an indexOfSpecial() method."); //$NON-NLS-1$
- }
-
- /**
- * This method handles special cases specific to this processor.
- * 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
- * <code>processSpecial</code> (for instance, a comment has been started
- * in the current line but its end appears in a following line),
- * <code>processSpecial</code> should specify a final state by
- * 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, <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.
- * </p><p>
- * A processor handling special cases (with a number of
- * special cases greater than zero) must override this method.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @param text is the structured text string before
- * addition of any directional formatting characters.
- *
- * @param charTypes is a parameter received by <code>processSpecial</code>
- * uniquely to be used as argument for calls to methods which
- * need it.
- *
- * @param offsets is a parameter received by <code>processSpecial</code>
- * uniquely to be used as argument for calls to methods which
- * need it.
- *
- * @param state is an integer array with at least one element.
- * If the processor needs to signal the occurrence of a
- * special case which must be passed to the next call to
- * <code>leanToFullText</code> (for instance, a comment or a
- * literal started but not closed in the current
- * <code>text</code>), it must put a value in the first element
- * of the <code>state</code> parameter.
- * This number must be >= 1 and less or equal to the number of special
- * cases returned by {@link #getSpecialsCount getSpecialsCount}
- * by this processor.
- * This number is passed back to the caller
- * and should be specified as <code>state</code> argument
- * in the next call to <code>leanToFullText</code> together
- * with the continuation text.
- * The meaning of this number is internal to the processor.
- *
- * @param caseNumber number of the special case to handle.
- *
- * @param separLocation the position returned by
- * {@link #indexOfSpecial indexOfSpecial}. In calls to
- * {@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
- * first element of <code>state</code> and the value of
- * <code>separLocation</code> equal to <code>-1</code>.
- *
- * @return the position after the scope of the special case ends.
- * For instance, the position after the end of a comment,
- * the position after the end of a literal.
- * <br>A value greater or equal to the length of <code>text</code>
- * means that there is no further occurrence of this case in the
- * current structured text.
- *
- * @throws IllegalStateException If not overridden, this method throws an
- * <code>IllegalStateException</code>. This is appropriate behavior
- * (and does not need to be overridden) for processors whose
- * number of special cases is zero, which means that
- * <code>processSpecial</code> should never be called for them.
- */
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
- // This method must be overridden by all subclasses with any special case.
- throw new IllegalStateException("A processor with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$
- }
-
- /**
- * This method can be called from within {@link #indexOfSpecial} or
- * {@link #processSpecial} in extensions of <code>STextProcessor</code>
- * to specify that a mark character must be added before the character
- * at the specified position of the <i>lean</i> text when generating the
- * <i>full</i> text. The mark character will be LRM for structured text
- * with a LTR base direction, and RLM for structured text with RTL
- * base direction. The mark character is not added physically by this
- * method, but its position is noted and will be used when generating
- * the <i>full</i> text.
- *
- * @param text is the structured text string received as
- * parameter to <code>indexOfSpecial</code> or
- * <code>processSpecial</code>.
- *
- * @param charTypes is a parameter received by <code>indexOfSpecial</code>
- * or <code>processSpecial</code>, uniquely to be used as argument
- * for calls to <code>insertMark</code> and other methods used
- * by processors.
- *
- * @param offsets is a parameter received by <code>indexOfSpecial</code>
- * or <code>processSpecial</code>, uniquely to be used as argument
- * for calls to <code>insertMark</code> and other methods used
- * by processors.
- *
- * @param offset position of the character in the <i>lean</i> text.
- * It must be a non-negative number smaller than the length
- * of the <i>lean</i> text.
- * For the benefit of efficiency, it is better to insert
- * multiple marks in ascending order of the offsets.
- */
- public static final void insertMark(String text, STextCharTypes charTypes, STextOffsets offsets, int offset) {
- offsets.insertOffset(charTypes, offset);
- }
-
- /**
- * This method can be called from within {@link #indexOfSpecial} or
- * {@link #processSpecial} in extensions of <code>STextProcessor</code> to add
- * a directional mark before a separator if needed for correct display,
- * depending on the base direction of the text and on the class of the
- * characters in the <i>lean</i> text preceding and following the separator itself.
- * <p>
- * The logic implemented in this method considers the text before
- * <code>separLocation</code> and the text following it. If, and only if,
- * a directional mark is needed to insure that the two parts of text
- * will be laid out according to the base direction, a mark will be
- * added when generating the <i>full</i> text.
- * </p>
- * @param text is the structured text string received as
- * parameter to <code>indexOfSpecial</code> or
- * <code>processSpecial</code>.
- *
- * @param charTypes is a parameter received by <code>indexOfSpecial</code>
- * or <code>processSpecial</code>, uniquely to be used as argument
- * for calls to <code>processSeparator</code> and other methods used
- * by processors.
- *
- * @param offsets is a parameter received by <code>indexOfSpecial</code>
- * or <code>processSpecial</code>, uniquely to be used as argument
- * for calls to <code>processSeparator</code> and other methods used
- * by processors.
- *
- * @param separLocation offset of the separator in the <i>lean</i> text.
- * It must be a non-negative number smaller than the length
- * of the <i>lean</i> text.
- */
- public static final void processSeparator(String text, STextCharTypes charTypes, STextOffsets offsets, int separLocation) {
- STextImpl.processSeparator(text, charTypes, offsets, separLocation);
- }
-
- /**
- * Indicate the separators to use for the current processor.
- * This method is invoked before starting the processing.
- * <p>
- * If no separators are specified, this method returns an empty string.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @return a string grouping one-character separators which separate
- * the structured text into tokens.
- */
- public String getSeparators(STextEnvironment environment) {
- return separators;
- }
-
- /**
- * Indicate the base text direction appropriate for an instance of structured text.
- * This method is invoked before starting the processing.
- * <p>
- * If not overridden, this method returns <code>DIR_LTR</code>.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @param text is the structured text string to process.
- *
- * @return the base direction of the structured text. This direction
- * may not be the same depending on the environment and on
- * whether the structured text contains Arabic or Hebrew
- * letters.<br>
- * The value returned is either
- * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}.
- */
- public int getDirection(STextEnvironment environment, String text) {
- return STextDirection.DIR_LTR;
- }
-
- /**
- * Indicate the base text direction appropriate for an instance of structured text.
- * This method is invoked before starting the processing.
- * <p>
- * If not overridden, this method returns <code>DIR_LTR</code>.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @param text is the structured text string to process.
- *
- * @param charTypes is a parameter received uniquely to be used as argument
- * for calls to <code>getCharType</code> and other methods used
- * by processors.
- *
- * @return the base direction of the structured text. This direction
- * may not be the same depending on the environment and on
- * whether the structured text contains Arabic or Hebrew
- * letters.<br>
- * The value returned is either
- * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}.
- */
- public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
- return STextDirection.DIR_LTR;
- }
-
- /**
- * Indicate the number of special cases handled by the current processor.
- * This method is invoked before starting the processing.
- * If the number returned is zero, {@link #indexOfSpecial} and
- * {@link #processSpecial} will not be invoked.
- * <p>
- * If not overridden, this method returns <code>zero</code>.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @return the number of special cases for the associated processor.
- * Special cases exist for some types of structured text
- * processors. They are implemented by overriding methods
- * {@link STextProcessor#indexOfSpecial} and {@link STextProcessor#processSpecial}.
- * Examples of special cases are comments, literals, or
- * anything which is not identified by a one-character separator.
- *
- */
- public int getSpecialsCount(STextEnvironment environment) {
- return 0;
- }
-
- /**
- * Checks if there is a need for processing structured text.
- * This method is invoked before starting the processing. If the
- * processor returns <code>true</code>, no directional formatting
- * characters are added to the <i>lean</i> text and the processing
- * is shortened.
- * <p>
- * If not overridden, this method returns <code>false</code>.
- * </p>
- * @param environment the current environment, which may affect the behavior of
- * the processor. This parameter may be specified as
- * <code>null</code>, in which case the
- * {@link STextEnvironment#DEFAULT DEFAULT}
- * environment should be assumed.
- *
- * @param text is the structured text string to process.
- *
- * @param charTypes is a parameter received uniquely to be used as argument
- * for calls to <code>getCharType</code> and other methods used
- * by processors.
- *
- * @return a flag indicating if there is no need to process the structured
- * text to add directional formatting characters.
- *
- */
- public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) {
- return false;
- }
-
-}
+/*******************************************************************************
+ * 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.custom;
+
+import org.eclipse.equinox.bidi.STextDirection;
+import org.eclipse.equinox.bidi.advanced.ISTextExpert;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.internal.STextImpl;
+
+/**
+ * Generic handler to be used as superclass (base class)
+ * for specific structured text handlers.
+ * <p>
+ * Here are some guidelines about how to write structured text
+ * handlers.
+ * <ul>
+ * <li>Handler instances may be accessed simultaneously by
+ * several threads. They should have no instance variables.</li>
+ * <li>The common logic uses handler methods to query the
+ * characteristics of the specific handler:
+ * <ul>
+ * <li>the separators which separate the structured text into
+ * tokens. See {@link #getSeparators getSeparators}.</li>
+ * <li>the direction which governs the display of tokens
+ * one after the other. See {@link #getDirection getDirection}.</li>
+ * <li>the number of special cases which need to be handled by
+ * code specific to that handler.
+ * See {@link #getSpecialsCount getSpecialsCount}.</li>
+ * </ul></li>
+ * <li>Before starting deeper analysis of the submitted text, the common
+ * logic gives to the handler a chance to shorten the processus by
+ * invoking its {@link #skipProcessing skipProcessing} method.</li>
+ * <li>The common logic then analyzes the text to segment it into tokens
+ * according to the appearance of separators (as retrieved using
+ * {@link #getSeparators getSeparators}).</li>
+ * <li>If the handler indicated a positive number of special cases as
+ * return value from its {@link #getSpecialsCount getSpecialsCount}
+ * method, the common logic will repeatedly invoke the handler's
+ * {@link #indexOfSpecial indexOfSpecial} method to let it signal the
+ * presence of special strings which may further delimit the source text.</li>
+ * <li>When such a special case is signalled by the handler, the common
+ * logic will call the handler's {@link #processSpecial processSpecial}
+ * method to give it the opportunity to handle it as needed. Typical
+ * actions that the handler may perform are to add directional marks
+ * inconditionally (by calling {@link #insertMark insertMark} or
+ * conditionally (by calling {@link #processSeparator processSeparator}).</li>
+ * </ul>
+ *
+ * @author Matitiahu Allouche
+ */
+public class STextTypeHandler {
+
+ final private String separators;
+
+ /**
+ * Creates a new instance of the STextTypeHandler class.
+ */
+ public STextTypeHandler() {
+ separators = ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Creates a new instance of the STextTypeHandler class.
+ * @param separators string consisting of characters that split the text into fragments
+ */
+ public STextTypeHandler(String separators) {
+ this.separators = separators;
+ }
+
+ /**
+ * 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 if the number of special cases
+ * returned by {@link #getSpecialsCount} is greater than zero.
+ * </p><p>
+ * A handler handling special cases must override this method.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @param text is the structured text string before
+ * addition of any directional formatting characters.
+ *
+ * @param charTypes is a parameter received by <code>indexOfSpecial</code>
+ * uniquely to be used as argument for calls to methods which
+ * need it.
+ *
+ * @param offsets is a parameter received by <code>indexOfSpecial</code>
+ * uniquely to be used as argument for calls to methods which
+ * need it.
+ *
+ * @param caseNumber number of the special case to locate.
+ * This number varies from 1 to the number of special cases
+ * returned by {@link #getSpecialsCount getSpecialsCount}
+ * for this handler.
+ * The meaning of this number is internal to the class
+ * implementing <code>indexOfSpecial</code>.
+ *
+ * @param fromIndex the index within <code>text</code> to start
+ * the search from.
+ *
+ * @return the position where the start of the special case
+ * corresponding to <code>caseNumber</code> was located.
+ * The method must return the first occurrence of whatever
+ * identifies the start of the special case starting from
+ * <code>fromIndex</code>. The method does not have to check if
+ * this occurrence appears within the scope of another special
+ * case (e.g. a comment starting delimiter within the scope of
+ * a literal or vice-versa).
+ * <br>If no occurrence is found, the method must return -1.
+ *
+ * @throws IllegalStateException If not overridden, this method throws an
+ * <code>IllegalStateException</code>. This is appropriate behavior
+ * (and does not need to be overridden) for handlers whose
+ * number of special cases is zero, which means that
+ * <code>indexOfSpecial</code> should never be called for them.
+ */
+ public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
+ // This method must be overridden by all subclasses with special cases.
+ throw new IllegalStateException("A handler with specialsCount > 0 must have an indexOfSpecial() method."); //$NON-NLS-1$
+ }
+
+ /**
+ * This method handles special cases specific to this handler.
+ * 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
+ * <code>processSpecial</code> (for instance, a comment has been started
+ * in the current line but its end appears in a following line),
+ * <code>processSpecial</code> should specify a final state by
+ * putting its value in the first element of the <code>state</code>
+ * parameter.
+ * The meaning of this state is internal to the handler.
+ * 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.
+ * </p><p>
+ * A handler handling special cases (with a number of
+ * special cases greater than zero) must override this method.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @param text is the structured text string before
+ * addition of any directional formatting characters.
+ *
+ * @param charTypes is a parameter received by <code>processSpecial</code>
+ * uniquely to be used as argument for calls to methods which
+ * need it.
+ *
+ * @param offsets is a parameter received by <code>processSpecial</code>
+ * uniquely to be used as argument for calls to methods which
+ * need it.
+ *
+ * @param state is an integer array with at least one element.
+ * If the handler needs to signal the occurrence of a
+ * special case which must be passed to the next call to
+ * <code>leanToFullText</code> (for instance, a comment or a
+ * literal started but not closed in the current
+ * <code>text</code>), it must put a value in the first element
+ * of the <code>state</code> parameter.
+ * This number must be >= 1 and less or equal to the number of special
+ * cases returned by {@link #getSpecialsCount getSpecialsCount}
+ * by this handler.
+ * This number is passed back to the caller
+ * and should be specified as <code>state</code> argument
+ * in the next call to <code>leanToFullText</code> together
+ * with the continuation text.
+ * The meaning of this number is internal to the handler.
+ *
+ * @param caseNumber number of the special case to handle.
+ *
+ * @param separLocation the position returned by
+ * {@link #indexOfSpecial indexOfSpecial}. In calls to
+ * {@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
+ * first element of <code>state</code> and the value of
+ * <code>separLocation</code> equal to <code>-1</code>.
+ *
+ * @return the position after the scope of the special case ends.
+ * For instance, the position after the end of a comment,
+ * the position after the end of a literal.
+ * <br>A value greater or equal to the length of <code>text</code>
+ * means that there is no further occurrence of this case in the
+ * current structured text.
+ *
+ * @throws IllegalStateException If not overridden, this method throws an
+ * <code>IllegalStateException</code>. This is appropriate behavior
+ * (and does not need to be overridden) for handlers whose
+ * number of special cases is zero, which means that
+ * <code>processSpecial</code> should never be called for them.
+ */
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ // This method must be overridden by all subclasses with any special case.
+ throw new IllegalStateException("A handler with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$
+ }
+
+ /**
+ * This method can be called from within {@link #indexOfSpecial} or
+ * {@link #processSpecial} in extensions of <code>STextTypeHandler</code>
+ * to specify that a mark character must be added before the character
+ * at the specified position of the <i>lean</i> text when generating the
+ * <i>full</i> text. The mark character will be LRM for structured text
+ * with a LTR base direction, and RLM for structured text with RTL
+ * base direction. The mark character is not added physically by this
+ * method, but its position is noted and will be used when generating
+ * the <i>full</i> text.
+ *
+ * @param text is the structured text string received as
+ * parameter to <code>indexOfSpecial</code> or
+ * <code>processSpecial</code>.
+ *
+ * @param charTypes is a parameter received by <code>indexOfSpecial</code>
+ * or <code>processSpecial</code>, uniquely to be used as argument
+ * for calls to <code>insertMark</code> and other methods used
+ * by handlers.
+ *
+ * @param offsets is a parameter received by <code>indexOfSpecial</code>
+ * or <code>processSpecial</code>, uniquely to be used as argument
+ * for calls to <code>insertMark</code> and other methods used
+ * by handlers.
+ *
+ * @param offset position of the character in the <i>lean</i> text.
+ * It must be a non-negative number smaller than the length
+ * of the <i>lean</i> text.
+ * For the benefit of efficiency, it is better to insert
+ * multiple marks in ascending order of the offsets.
+ */
+ public static final void insertMark(String text, STextCharTypes charTypes, STextOffsets offsets, int offset) {
+ offsets.insertOffset(charTypes, offset);
+ }
+
+ /**
+ * This method can be called from within {@link #indexOfSpecial} or
+ * {@link #processSpecial} in extensions of <code>STextTypeHandler</code> to add
+ * a directional mark before a separator if needed for correct display,
+ * depending on the base direction of the text and on the class of the
+ * characters in the <i>lean</i> text preceding and following the separator itself.
+ * <p>
+ * The logic implemented in this method considers the text before
+ * <code>separLocation</code> and the text following it. If, and only if,
+ * a directional mark is needed to insure that the two parts of text
+ * will be laid out according to the base direction, a mark will be
+ * added when generating the <i>full</i> text.
+ * </p>
+ * @param text is the structured text string received as
+ * parameter to <code>indexOfSpecial</code> or
+ * <code>processSpecial</code>.
+ *
+ * @param charTypes is a parameter received by <code>indexOfSpecial</code>
+ * or <code>processSpecial</code>, uniquely to be used as argument
+ * for calls to <code>processSeparator</code> and other methods used
+ * by handlers.
+ *
+ * @param offsets is a parameter received by <code>indexOfSpecial</code>
+ * or <code>processSpecial</code>, uniquely to be used as argument
+ * for calls to <code>processSeparator</code> and other methods used
+ * by handlers.
+ *
+ * @param separLocation offset of the separator in the <i>lean</i> text.
+ * It must be a non-negative number smaller than the length
+ * of the <i>lean</i> text.
+ */
+ public static final void processSeparator(String text, STextCharTypes charTypes, STextOffsets offsets, int separLocation) {
+ STextImpl.processSeparator(text, charTypes, offsets, separLocation);
+ }
+
+ /**
+ * Indicate the separators to use for the current handler.
+ * This method is invoked before starting the processing.
+ * <p>
+ * If no separators are specified, this method returns an empty string.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @return a string grouping one-character separators which separate
+ * the structured text into tokens.
+ */
+ public String getSeparators(STextEnvironment environment) {
+ return separators;
+ }
+
+ /**
+ * Indicate the base text direction appropriate for an instance of structured text.
+ * This method is invoked before starting the processing.
+ * <p>
+ * If not overridden, this method returns <code>DIR_LTR</code>.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @param text is the structured text string to process.
+ *
+ * @return the base direction of the structured text. This direction
+ * may not be the same depending on the environment and on
+ * whether the structured text contains Arabic or Hebrew
+ * letters.<br>
+ * The value returned is either
+ * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}.
+ */
+ public int getDirection(STextEnvironment environment, String text) {
+ return STextDirection.DIR_LTR;
+ }
+
+ /**
+ * Indicate the base text direction appropriate for an instance of structured text.
+ * This method is invoked before starting the processing.
+ * <p>
+ * If not overridden, this method returns <code>DIR_LTR</code>.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @param text is the structured text string to process.
+ *
+ * @param charTypes is a parameter received uniquely to be used as argument
+ * for calls to <code>getCharType</code> and other methods used
+ * by handlers.
+ *
+ * @return the base direction of the structured text. This direction
+ * may not be the same depending on the environment and on
+ * whether the structured text contains Arabic or Hebrew
+ * letters.<br>
+ * The value returned is either
+ * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}.
+ */
+ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) {
+ return STextDirection.DIR_LTR;
+ }
+
+ /**
+ * Indicate the number of special cases handled by the current handler.
+ * This method is invoked before starting the processing.
+ * If the number returned is zero, {@link #indexOfSpecial} and
+ * {@link #processSpecial} will not be invoked.
+ * <p>
+ * If not overridden, this method returns <code>zero</code>.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @return the number of special cases for the associated handler.
+ * Special cases exist for some types of structured text
+ * handlers. They are implemented by overriding methods
+ * {@link STextTypeHandler#indexOfSpecial} and {@link STextTypeHandler#processSpecial}.
+ * Examples of special cases are comments, literals, or
+ * anything which is not identified by a one-character separator.
+ *
+ */
+ public int getSpecialsCount(STextEnvironment environment) {
+ return 0;
+ }
+
+ /**
+ * Checks if there is a need for processing structured text.
+ * This method is invoked before starting the processing. If the
+ * handler returns <code>true</code>, no directional formatting
+ * characters are added to the <i>lean</i> text and the processing
+ * is shortened.
+ * <p>
+ * If not overridden, this method returns <code>false</code>.
+ * </p>
+ * @param environment the current environment, which may affect the behavior of
+ * the handler. This parameter may be specified as
+ * <code>null</code>, in which case the
+ * {@link STextEnvironment#DEFAULT DEFAULT}
+ * environment should be assumed.
+ *
+ * @param text is the structured text string to process.
+ *
+ * @param charTypes is a parameter received uniquely to be used as argument
+ * for calls to <code>getCharType</code> and other methods used
+ * by handlers.
+ *
+ * @return a flag indicating if there is no need to process the structured
+ * text to add directional formatting characters.
+ *
+ */
+ public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) {
+ return false;
+ }
+
+}
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 110bcc4..ce86629 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
@@ -11,11 +11,10 @@
package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-
import org.eclipse.equinox.bidi.custom.*;
/**
- * A base processor for structured text composed of text segments separated
+ * A base handler for structured text composed of text segments separated
* by separators where the text segments may include delimited parts within
* which separators are treated like regular characters.
* <p>
@@ -23,7 +22,7 @@ import org.eclipse.equinox.bidi.custom.*;
* </p>
* @author Matitiahu Allouche
*/
-public abstract class STextDelims extends STextProcessor {
+public abstract class STextDelims extends STextTypeHandler {
public STextDelims() {
// placeholder
@@ -60,7 +59,7 @@ public abstract class STextDelims extends STextProcessor {
* of <code>text</code> if no end delimiter is found.
*/
public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
int loc = separLocation + 1;
char delim = getDelimiters().charAt((caseNumber * 2) - 1);
loc = text.indexOf(delim, loc);
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 37d5217..3f81242 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
@@ -11,11 +11,10 @@
package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-
import org.eclipse.equinox.bidi.custom.*;
/**
- * A base processor for structured text composed of text segments separated
+ * A base handler for structured text composed of text segments separated
* by separators where the text segments may include delimited parts within
* which separators are treated like regular characters and the delimiters
* may be escaped.
@@ -51,7 +50,7 @@ public abstract class STextDelimsEsc extends STextDelims {
* ignoring possibly escaped end delimiters.
*/
public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
int location = separLocation + 1;
char delim = getDelimiters().charAt((caseNumber * 2) - 1);
while (true) {
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java
deleted file mode 100644
index 985495c..0000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * 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.ISTextExpert;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
-
-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 STextExpertImpl(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/STextExpertMultipassImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java
deleted file mode 100644
index c46ee3c..0000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * 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.ISTextExpertStateful;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
-
-public class STextExpertMultipassImpl extends STextExpertImpl implements ISTextExpertStateful {
-
- /**
- * 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 = new int[] {STATE_INITIAL};
-
- public STextExpertMultipassImpl(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
- super(structuredTextDescriptor, environment);
- resetState();
- }
-
- 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 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 c102319..1137826 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
@@ -11,11 +11,10 @@
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.ISTextExpert;
+import org.eclipse.equinox.bidi.advanced.*;
import org.eclipse.equinox.bidi.custom.*;
-public class STextImpl {
+public class STextImpl implements ISTextExpertStateful {
static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -47,18 +46,67 @@ public class STextImpl {
static final int FIXES_LENGTH = PREFIX_LENGTH + SUFFIX_LENGTH;
static final int[] EMPTY_INT_ARRAY = new int[0];
static final STextEnvironment IGNORE_ENVIRONMENT = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE);
+ static final int STATE_INITIAL = 0;
- /**
- * Prevent creation of a STextImpl instance
- */
- private STextImpl() {
- // nothing to do
+ protected STextTypeHandler structuredTextHandler;
+ protected STextEnvironment environment;
+ protected int[] state;
+
+ public STextImpl(STextTypeHandler structuredTextHandler, STextEnvironment environment, int[] state) {
+ this.structuredTextHandler = structuredTextHandler;
+ this.environment = environment;
+ this.state = state;
+ }
+
+ public String leanToFullText(String text) {
+ return STextImpl.leanToFullText(structuredTextHandler, environment, text, state);
+ }
+
+ public int[] leanToFullMap(String text) {
+ return STextImpl.leanToFullMap(structuredTextHandler, environment, text, state);
+ }
+
+ public int[] leanBidiCharOffsets(String text) {
+ return STextImpl.leanBidiCharOffsets(structuredTextHandler, environment, text, state);
+ }
+
+ public String fullToLeanText(String text) {
+ return STextImpl.fullToLeanText(structuredTextHandler, environment, text, state);
+ }
+
+ public int[] fullToLeanMap(String text) {
+ return STextImpl.fullToLeanMap(structuredTextHandler, environment, text, state);
+ }
+
+ public int[] fullBidiCharOffsets(String text) {
+ return STextImpl.fullBidiCharOffsets(structuredTextHandler, environment, text, state);
}
- static long computeNextLocation(STextProcessor processor, STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] locations, int curPos) {
- String separators = processor.getSeparators(environment);
+ public int getCurDirection(String text) {
+ return structuredTextHandler.getDirection(environment, text);
+ }
+
+ public void resetState() {
+ state[0] = STATE_INITIAL;
+ }
+
+ public void setState(int newState) {
+ state[0] = newState;
+ }
+
+ public static void setState(int[] state, int newState) {
+ if (state != null)
+ state[0] = newState;
+ }
+
+ public int getState() {
+ return state[0];
+ }
+
+ static long computeNextLocation(STextTypeHandler handler, STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] locations, int curPos) {
+ String separators = handler.getSeparators(environment);
int separCount = separators.length();
- int specialsCount = processor.getSpecialsCount(environment);
+ int specialsCount = handler.getSpecialsCount(environment);
int len = text.length();
int nextLocation = len;
int idxLocation = 0;
@@ -68,7 +116,7 @@ public class STextImpl {
int location = locations[separCount + i];
if (location < curPos) {
offsets.ensureRoom();
- location = processor.indexOfSpecial(environment, text, charTypes, offsets, i + 1, curPos);
+ location = handler.indexOfSpecial(environment, text, charTypes, offsets, i + 1, curPos);
if (location < 0)
location = len;
locations[separCount + i] = location;
@@ -195,12 +243,12 @@ public class STextImpl {
* <p>
* @see ISTextExpert#leanToFullText STextEngine.leanToFullText
*/
- public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
+ public static String leanToFullText(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
return text;
- STextCharTypes charTypes = new STextCharTypes(processor, environment, text);
- STextOffsets offsets = leanToFullCommon(processor, environment, text, state, charTypes);
+ STextCharTypes charTypes = new STextCharTypes(handler, environment, text);
+ STextOffsets offsets = leanToFullCommon(handler, environment, text, state, charTypes);
int prefixLength = offsets.getPrefixLength();
int count = offsets.getCount();
if (count == 0 && prefixLength == 0)
@@ -242,12 +290,12 @@ public class STextImpl {
return new String(fullChars);
}
- public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanToFullMap(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
- STextCharTypes charTypes = new STextCharTypes(processor, environment, text);
- STextOffsets offsets = leanToFullCommon(processor, environment, text, state, charTypes);
+ STextCharTypes charTypes = new STextCharTypes(handler, environment, text);
+ STextOffsets offsets = leanToFullCommon(handler, environment, text, state, charTypes);
int prefixLength = offsets.getPrefixLength();
int[] map = new int[len];
int count = offsets.getCount(); // number of used entries
@@ -262,54 +310,42 @@ public class STextImpl {
return map;
}
- public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanBidiCharOffsets(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
- STextCharTypes charTypes = new STextCharTypes(processor, environment, text);
- STextOffsets offsets = leanToFullCommon(processor, environment, text, state, charTypes);
+ STextCharTypes charTypes = new STextCharTypes(handler, environment, text);
+ STextOffsets offsets = leanToFullCommon(handler, environment, text, state, charTypes);
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) {
+ static STextOffsets leanToFullCommon(STextTypeHandler handler, STextEnvironment environment, String text, int[] state, STextCharTypes charTypes) {
if (environment == null)
environment = STextEnvironment.DEFAULT;
- if (state == null) {
- state = new int[1];
- state[0] = STATE_INITIAL;
- }
int len = text.length();
- int direction = processor.getDirection(environment, text, charTypes);
+ int direction = handler.getDirection(environment, text, charTypes);
STextOffsets offsets = new STextOffsets();
- if (!processor.skipProcessing(environment, text, charTypes)) {
+ if (!handler.skipProcessing(environment, text, charTypes)) {
// initialize locations
- int separCount = processor.getSeparators(environment).length();
- int[] locations = new int[separCount + processor.getSpecialsCount(environment)];
+ int separCount = handler.getSeparators(environment).length();
+ int[] locations = new int[separCount + handler.getSpecialsCount(environment)];
for (int i = 0, k = locations.length; i < k; i++) {
locations[i] = -1;
}
// current position
int curPos = 0;
- if (state[0] > STATE_INITIAL) {
+ if (state != null && state[0] > STATE_INITIAL) {
offsets.ensureRoom();
int initState = state[0];
state[0] = STATE_INITIAL;
- curPos = processor.processSpecial(environment, text, charTypes, offsets, state, initState, -1);
+ curPos = handler.processSpecial(environment, text, charTypes, offsets, state, initState, -1);
}
while (true) {
// location of next token to handle
int nextLocation;
// index of next token to handle (if < separCount, this is a separator; otherwise a special case
int idxLocation;
- long res = computeNextLocation(processor, environment, text, charTypes, offsets, locations, curPos);
+ long res = computeNextLocation(handler, environment, text, charTypes, offsets, locations, curPos);
nextLocation = (int) (res & 0x00000000FFFFFFFF); /* low word */
if (nextLocation >= len)
break;
@@ -320,12 +356,12 @@ public class STextImpl {
curPos = nextLocation + 1;
} else {
idxLocation -= (separCount - 1); // because caseNumber starts from 1
- curPos = processor.processSpecial(environment, text, charTypes, offsets, state, idxLocation, nextLocation);
+ curPos = handler.processSpecial(environment, text, charTypes, offsets, state, idxLocation, nextLocation);
}
if (curPos >= len)
break;
} // end while
- } // end if (!processor.skipProcessing())
+ } // end if (!handler.skipProcessing())
int prefixLength;
int orientation = environment.getOrientation();
if (orientation == STextEnvironment.ORIENT_IGNORE)
@@ -343,12 +379,12 @@ public class STextImpl {
return offsets;
}
- public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
+ public static String fullToLeanText(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
if (text.length() == 0)
return text;
if (environment == null)
environment = STextEnvironment.DEFAULT;
- int dir = processor.getDirection(environment, text);
+ int dir = handler.getDirection(environment, text);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
int i; // used as loop index
@@ -386,7 +422,7 @@ public class STextImpl {
chars[i - cnt] = c;
}
String lean = new String(chars, 0, lenText - cnt);
- String full = leanToFullText(processor, IGNORE_ENVIRONMENT, lean, state);
+ String full = leanToFullText(handler, IGNORE_ENVIRONMENT, lean, state);
if (full.equals(text))
return lean;
@@ -431,13 +467,13 @@ public class STextImpl {
return lean;
}
- public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String full, int[] state) {
+ public static int[] fullToLeanMap(STextTypeHandler handler, STextEnvironment environment, String full, int[] state) {
int lenFull = full.length();
if (lenFull == 0)
return EMPTY_INT_ARRAY;
- String lean = fullToLeanText(processor, environment, full, state);
+ String lean = fullToLeanText(handler, environment, full, state);
int lenLean = lean.length();
- int dir = processor.getDirection(environment, lean);
+ int dir = handler.getDirection(environment, lean);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
int[] map = new int[lenFull];
@@ -462,11 +498,11 @@ public class STextImpl {
return map;
}
- public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String full, int[] state) {
+ public static int[] fullBidiCharOffsets(STextTypeHandler handler, STextEnvironment environment, String full, int[] state) {
int lenFull = full.length();
if (lenFull == 0)
return EMPTY_INT_ARRAY;
- String lean = fullToLeanText(processor, environment, full, state);
+ String lean = fullToLeanText(handler, environment, full, state);
STextOffsets offsets = new STextOffsets();
int lenLean = lean.length();
int idxLean, idxFull;
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 42e1be0..3ea4d4a 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
@@ -11,26 +11,25 @@
package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-
import org.eclipse.equinox.bidi.custom.*;
/**
- * A base processor for structured text composed of two parts separated by a separator.
+ * A base handler for structured text composed of two parts separated by a separator.
* The first occurrence of the separator delimits the end of the first part
* and the start of the second part. Further occurrences of the separator,
* if any, are treated like regular characters of the second text part.
- * The processor makes sure that the text be presented in the form
+ * The handler makes sure that the text be presented in the form
* (assuming that the equal sign is the separator):
* <pre>
* part1=part2
* </pre>
- * The string returned by {@link STextProcessor#getSeparators getSeparators}
- * for this processor should contain exactly one character.
+ * The string returned by {@link STextTypeHandler#getSeparators getSeparators}
+ * for this handler should contain exactly one character.
* Additional characters will be ignored.
*
* @author Matitiahu Allouche
*/
-public class STextSingle extends STextProcessor {
+public class STextSingle extends STextTypeHandler {
public STextSingle(String separator) {
super(separator);
@@ -52,12 +51,12 @@ public class STextSingle extends STextProcessor {
* @return the length of <code>text</code>.
*/
public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
return text.length();
}
/**
- * This method returns 1 as number of special cases handled by this processor.
+ * This method returns 1 as number of special cases handled by this handler.
*
* @return 1.
*/
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java
index bbcf564..f97f51e 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java
@@ -13,7 +13,7 @@ package org.eclipse.equinox.bidi.internal;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
public class STextTypesCollector implements IRegistryEventListener {
@@ -21,7 +21,7 @@ public class STextTypesCollector implements IRegistryEventListener {
private static final String CE_NAME = "typeDescription"; //$NON-NLS-1$
private static final String ATTR_TYPE = "type"; //$NON-NLS-1$
- private static final String ATTR_PROCESSOR = "class"; //$NON-NLS-1$
+ private static final String ATTR_HANDLER = "class"; //$NON-NLS-1$
private Map types;
private Map factories;
@@ -46,12 +46,12 @@ public class STextTypesCollector implements IRegistryEventListener {
return result;
}
- public STextProcessor getProcessor(String type) {
+ public STextTypeHandler getHandler(String type) {
if (types == null)
read();
- Object processor = types.get(type);
- if (processor instanceof STextProcessor)
- return (STextProcessor) processor;
+ Object handler = types.get(type);
+ if (handler instanceof STextTypeHandler)
+ return (STextTypeHandler) handler;
return null;
}
@@ -76,14 +76,14 @@ public class STextTypesCollector implements IRegistryEventListener {
if (CE_NAME != confElements[j].getName())
STextActivator.logError("BiDi types: unexpected element name " + confElements[j].getName(), new IllegalArgumentException()); //$NON-NLS-1$
String type = confElements[j].getAttribute(ATTR_TYPE);
- Object processor;
+ Object handler;
try {
- processor = confElements[j].createExecutableExtension(ATTR_PROCESSOR);
+ handler = confElements[j].createExecutableExtension(ATTR_HANDLER);
} catch (CoreException e) {
- STextActivator.logError("BiDi types: unable to create processor for " + type, e); //$NON-NLS-1$
+ STextActivator.logError("BiDi types: unable to create handler for " + type, e); //$NON-NLS-1$
continue;
}
- types.put(type, processor);
+ types.put(type, handler);
factories.put(type, confElements[j]);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java
index 418873f..7aab1f4 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java
@@ -10,15 +10,15 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
- * Processor adapted to processing comma-delimited lists, such as:
+ * Handler adapted to processing comma-delimited lists, such as:
* <pre>
* part1,part2,part3
* </pre>
*/
-public class STextComma extends STextProcessor {
+public class STextComma extends STextTypeHandler {
public STextComma() {
super(","); //$NON-NLS-1$
}
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 940f192..2be4a2b 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
@@ -16,7 +16,7 @@ import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.internal.STextDelimsEsc;
/**
- * Processor adapted to processing e-mail addresses.
+ * Handler adapted to processing e-mail addresses.
*/
public class STextEmail extends STextDelimsEsc {
static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
@@ -59,7 +59,7 @@ public class STextEmail extends STextDelimsEsc {
}
/**
- * @return 2 as number of special cases handled by this processor.
+ * @return 2 as number of special cases handled by this handler.
*/
public int getSpecialsCount(STextEnvironment environment) {
return 2;
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java
index d7185d3..b8f4b10 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java
@@ -10,12 +10,12 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
- * Processor adapted to processing directory and file paths.
+ * Handler adapted to processing directory and file paths.
*/
-public class STextFile extends STextProcessor {
+public class STextFile extends STextTypeHandler {
public STextFile() {
super(":/\\."); //$NON-NLS-1$
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 bb4dff1..5e3d49c 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,13 +10,14 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.custom.*;
import org.eclipse.equinox.bidi.internal.STextActivator;
+import org.eclipse.equinox.bidi.internal.STextImpl;
/**
- * <code>STextJava</code> is a processor for structured text
+ * <code>STextJava</code> is a handler for structured text
* composed of Java statements. Such a structured text may span
* multiple lines.
* <p>
@@ -34,7 +35,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
*
* @author Matitiahu Allouche
*/
-public class STextJava extends STextProcessor {
+public class STextJava extends STextTypeHandler {
private static final byte WS = Character.DIRECTIONALITY_WHITESPACE;
static final String lineSep = STextActivator.getInstance().getProperty("line.separator"); //$NON-NLS-1$
@@ -43,7 +44,7 @@ public class STextJava extends STextProcessor {
}
/**
- * @return 4 as the number of special cases handled by this processor.
+ * @return 4 as the number of special cases handled by this handler.
*/
public int getSpecialsCount(STextEnvironment environment) {
return 4;
@@ -85,7 +86,7 @@ public class STextJava extends STextProcessor {
public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
int location, counter, i;
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
switch (caseNumber) {
case 1 : /* space */
separLocation++;
@@ -114,12 +115,12 @@ public class STextJava extends STextProcessor {
location = separLocation + 2; // skip the opening slash-aster
location = text.indexOf("*/", location); //$NON-NLS-1$
if (location < 0) {
- state[0] = caseNumber;
+ STextImpl.setState(state, caseNumber);
return text.length();
}
// we need to call processSeparator since text may follow the
// end of comment immediately without even a space
- STextProcessor.processSeparator(text, charTypes, offsets, location);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, location);
return location + 2;
case 4 : /* slash-slash comment */
location = text.indexOf(lineSep, separLocation + 2);
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 0aa241d..d15af0b 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
@@ -13,13 +13,13 @@ 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.custom.STextCharTypes;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
- * Processor adapted to processing arithmetic expressions with
+ * Handler adapted to processing arithmetic expressions with
* a possible right-to-left base direction.
*/
-public class STextMath extends STextProcessor {
+public class STextMath extends STextTypeHandler {
static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
static final byte R = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
static final byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java
index 994a80e..a99f12f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java
@@ -13,7 +13,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.internal.STextSingle;
/**
- * Processor adapted to processing property file statements.
+ * Handler adapted to processing property file statements.
* It expects the following string format:
* <pre>
* name=value
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 c5d3bb9..4816d4e 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
@@ -11,12 +11,13 @@
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.ISTextExpert;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.internal.STextImpl;
/**
- * <code>STextRegex</code> is a processor for regular expressions.
+ * <code>STextRegex</code> is a handler for regular expressions.
* Such expressions may span multiple lines.
* <p>
* In applications like an editor where parts of the text might be modified
@@ -33,7 +34,7 @@ import org.eclipse.equinox.bidi.custom.*;
*
* @author Matitiahu Allouche
*/
-public class STextRegex extends STextProcessor {
+public class STextRegex extends STextTypeHandler {
static final String[] startStrings = {"", /* 0 *//* dummy *///$NON-NLS-1$
"(?#", /* 1 *//* comment (?#...) *///$NON-NLS-1$
"(?<", /* 2 *//* named group (?<name> *///$NON-NLS-1$
@@ -65,9 +66,9 @@ public class STextRegex extends STextProcessor {
static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
/**
- * This method retrieves the number of special cases handled by this processor.
+ * This method retrieves the number of special cases handled by this handler.
*
- * @return the number of special cases for this processor.
+ * @return the number of special cases for this handler.
*/
public int getSpecialsCount(STextEnvironment environment) {
return maxSpecial;
@@ -154,13 +155,13 @@ public class STextRegex extends STextProcessor {
// initial state from previous line
location = 0;
} else {
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
// skip the opening "(?#"
location = separLocation + 3;
}
location = text.indexOf(')', location);
if (location < 0) {
- state[0] = caseNumber;
+ STextImpl.setState(state, caseNumber);
return text.length();
}
return location + 1;
@@ -170,7 +171,7 @@ public class STextRegex extends STextProcessor {
case 5 : /* conditional named back reference (?(<name>) */
case 6 : /* conditional named back reference (?('name') */
case 7 : /* named parentheses reference (?&name) */
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
// no need for calling processSeparator() for the following cases
// since the starting string contains a L char
case 8 : /* named group (?P<name> */
@@ -194,20 +195,20 @@ public class STextRegex extends STextProcessor {
// initial state from previous line
location = 0;
} else {
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
// skip the opening "\Q"
location = separLocation + 2;
}
location = text.indexOf("\\E", location); //$NON-NLS-1$
if (location < 0) {
- state[0] = caseNumber;
+ STextImpl.setState(state, caseNumber);
return text.length();
}
// set the charType for the "E" to L (Left to Right character)
charTypes.setBidiTypeAt(location + 1, L);
return location + 2;
case 18 : /* R, AL, AN, EN */
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
return separLocation + 1;
}
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 9fbe5e4..3b74b43 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,13 +10,14 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
import org.eclipse.equinox.bidi.custom.*;
import org.eclipse.equinox.bidi.internal.STextActivator;
+import org.eclipse.equinox.bidi.internal.STextImpl;
/**
- * <code>STextSql</code> is a processor for structured text
+ * <code>STextSql</code> is a handler for structured text
* composed of SQL statements. Such a structured text may span
* multiple lines.
* <p>
@@ -34,7 +35,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
*
* @author Matitiahu Allouche
*/
-public class STextSql extends STextProcessor {
+public class STextSql extends STextTypeHandler {
private static final byte WS = Character.DIRECTIONALITY_WHITESPACE;
static final String lineSep = STextActivator.getInstance().getProperty("line.separator"); //$NON-NLS-1$
@@ -43,7 +44,7 @@ public class STextSql extends STextProcessor {
}
/**
- * @return 5 as the number of special cases handled by this processor.
+ * @return 5 as the number of special cases handled by this handler.
*/
public int getSpecialsCount(STextEnvironment environment) {
return 5;
@@ -89,7 +90,7 @@ public class STextSql extends STextProcessor {
public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
int location;
- STextProcessor.processSeparator(text, charTypes, offsets, separLocation);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
switch (caseNumber) {
case 1 : /* space */
separLocation++;
@@ -103,7 +104,7 @@ public class STextSql extends STextProcessor {
while (true) {
location = text.indexOf('\'', location);
if (location < 0) {
- state[0] = caseNumber;
+ STextImpl.setState(state, caseNumber);
return text.length();
}
if ((location + 1) < text.length() && text.charAt(location + 1) == '\'') {
@@ -132,12 +133,12 @@ public class STextSql extends STextProcessor {
location = separLocation + 2; // skip the opening slash-aster
location = text.indexOf("*/", location); //$NON-NLS-1$
if (location < 0) {
- state[0] = caseNumber;
+ STextImpl.setState(state, caseNumber);
return text.length();
}
// we need to call processSeparator since text may follow the
// end of comment immediately without even a space
- STextProcessor.processSeparator(text, charTypes, offsets, location);
+ STextTypeHandler.processSeparator(text, charTypes, offsets, location);
return location + 2;
case 5 : /* hyphen-hyphen comment */
location = text.indexOf(lineSep, separLocation + 2);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java
index 32b2307..a4241fb 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java
@@ -13,7 +13,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.internal.STextSingle;
/**
- * Processor adapted to processing structured text with the following format:
+ * Handler adapted to processing structured text with the following format:
* <pre>
* system(user)
* </pre>
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java
index 5b2df1a..09794fa 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java
@@ -10,12 +10,12 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
- * Processor adapted to processing URLs.
+ * Handler adapted to processing URLs.
*/
-public class STextURL extends STextProcessor {
+public class STextURL extends STextTypeHandler {
public STextURL() {
super(":?#/@.[]"); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java
index eae11f6..387f39f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java
@@ -10,16 +10,16 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
- * Processor adapted to processing compound names.
+ * Handler adapted to processing compound names.
* This type covers names made of one or more parts, separated by underscores:
* <pre>
* part1_part2_part3
* </pre>
*/
-public class STextUnderscore extends STextProcessor {
+public class STextUnderscore extends STextTypeHandler {
public STextUnderscore() {
super("_"); //$NON-NLS-1$
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 40000ab..637b229 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
@@ -11,11 +11,10 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.advanced.STextEnvironment;
-
import org.eclipse.equinox.bidi.internal.STextDelims;
/**
- * Processor adapted to processing XPath expressions.
+ * Handler adapted to processing XPath expressions.
*/
public class STextXPath extends STextDelims {
@@ -24,7 +23,7 @@ public class STextXPath extends STextDelims {
}
/**
- * @return 2 as the number of special cases handled by this processor.
+ * @return 2 as the number of special cases handled by this handler.
*/
public int getSpecialsCount(STextEnvironment environment) {
return 2;