Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java9
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java108
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java38
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java32
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java241
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java21
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java32
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java118
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextTest.java19
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java20
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/ISTextTypes.java106
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java258
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java39
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java349
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java44
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/ISTextProcessor.java170
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextFeatures.java250
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java392
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextStringProcessor.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/package.html9
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java27
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java12
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java221
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java28
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java11
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java58
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java12
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java27
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java52
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java12
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java58
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java27
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java14
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java13
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java13
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/package.html38
38 files changed, 1413 insertions, 1493 deletions
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
index 033c167bc..e1b291052 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
@@ -12,8 +12,8 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextEngine;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
import org.eclipse.equinox.bidi.custom.STextStringProcessor;
-import org.eclipse.equinox.bidi.custom.ISTextProcessor;
/**
* Tests contribution of BiDi processors.
@@ -28,7 +28,7 @@ public class STextExtensibilityTest extends STextTestBase {
// check one of the types that we know should be there
assertTrue(isTypePresent(types, "regex"));
- ISTextProcessor processor = STextStringProcessor.getProcessor("regex");
+ STextProcessor processor = STextStringProcessor.getProcessor("regex");
assertNotNull(processor);
}
@@ -40,7 +40,7 @@ public class STextExtensibilityTest extends STextTestBase {
// check the type added by the test bundle
assertTrue(isTypePresent(types, "test"));
- ISTextProcessor processor = STextStringProcessor.getProcessor("test");
+ STextProcessor processor = STextStringProcessor.getProcessor("test");
assertNotNull(processor);
processor = STextStringProcessor.getProcessor("badtest");
@@ -49,7 +49,8 @@ public class STextExtensibilityTest extends STextTestBase {
String data, lean, full, model;
data = "ABC.DEF:HOST-COM=HELLO";
lean = toUT16(data);
- full = STextEngine.leanToFullText("test", null, null, lean, null);
+ processor = STextStringProcessor.getProcessor("test");
+ full = STextEngine.leanToFullText(processor, null, lean, null);
model = "ABC@.DEF@:HOST@-COM@=HELLO";
assertEquals("Test 'test' plugin", model, toPseudo(full));
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
index 75166beb3..753361e81 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,9 +11,9 @@
package org.eclipse.equinox.bidi.internal.tests;
+import java.util.Locale;
import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.ISTextTypes;
-import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests all plug-in extensions
@@ -21,47 +21,55 @@ import org.eclipse.equinox.bidi.custom.*;
public class STextExtensionsTest extends STextTestBase {
- ISTextProcessor processor;
- STextFeatures f1, f2;
+ STextProcessor processor;
int[] state = new int[1];
- String type;
private void doTest1(String label, String data, String result) {
String full;
- full = STextEngine.leanToFullText(type, null, null, toUT16(data), state);
+ full = STextEngine.leanToFullText(processor, null, toUT16(data), state);
assertEquals(label + " data = " + data, result, toPseudo(full));
}
private void doTest2(String label, String data, String result) {
String full;
- full = STextEngine.leanToFullText(type, null, null, data, state);
+ full = STextEngine.leanToFullText(processor, null, data, state);
assertEquals(label + " data = " + data, result, toPseudo(full));
}
private void doTest3(String label, String data, String result) {
String full;
- full = STextEngine.leanToFullText(processor, f2, null, toUT16(data), state);
+ full = STextEngine.leanToFullText(processor, null, toUT16(data), state);
assertEquals(label + " data = " + data, result, toPseudo(full));
}
public void testExtensions() {
- type = ISTextTypes.COMMA_DELIMITED;
+ String data;
+ processor = STextEngine.PROC_COMMA_DELIMITED;
state[0] = STextEngine.STATE_INITIAL;
doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
- type = ISTextTypes.EMAIL;
+ processor = STextEngine.PROC_EMAIL;
state[0] = STextEngine.STATE_INITIAL;
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 ");
-
- type = ISTextTypes.FILE;
+ Locale.setDefault(new Locale("ar"));
+ 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&^");
+ Locale.setDefault(new Locale("he"));
+ data = toUT16("peter.pan") + "@" + toUT16("DEF.GHI");
+ doTest2("Email #9", data, "peter.pan@DEF@.GHI");
+
+ processor = STextEngine.PROC_FILE;
state[0] = STextEngine.STATE_INITIAL;
doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
- type = ISTextTypes.JAVA;
+ processor = STextEngine.PROC_JAVA;
state[0] = STextEngine.STATE_INITIAL;
doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
doTest1("Java #2", "A = B + C;", "A@ = B@ + C;");
@@ -74,14 +82,13 @@ 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;");
- type = ISTextTypes.PROPERTY;
+ processor = STextEngine.PROC_PROPERTY;
state[0] = STextEngine.STATE_INITIAL;
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");
- String data;
- type = ISTextTypes.REGEXP;
+ processor = STextEngine.PROC_REGEXP;
state[0] = STextEngine.STATE_INITIAL;
data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
@@ -127,7 +134,45 @@ public class STextExtensionsTest extends STextTestBase {
doTest1("Regex #17.6", "aB*123", "aB*@123");
doTest1("Regex #17.7", "aB*567", "aB*@567");
- type = ISTextTypes.SQL;
+ Locale.setDefault(new Locale("ar"));
+ data = toUT16("#BC(?") + "#" + toUT16("DEF)GHI");
+ doTest2("Regex #0.0", data, "<&#BC(?#DEF)GHI&^");
+ data = toUT16("#BC(?") + "#" + toUT16("DEF");
+ doTest2("Regex #0.1", data, "<&#BC(?#DEF&^");
+ doTest1("Regex #0.2", "#HI)JKL", "<&#HI)JKL&^");
+ data = toUT16("#BC(?") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
+ doTest2("Regex #1", data, "<&#BC(?<DEF>GHI&^");
+ doTest1("Regex #2.0", "#BC(?'DEF'GHI", "<&#BC(?'DEF'GHI&^");
+ doTest1("Regex #2.1", "#BC(?'DEFGHI", "<&#BC(?'DEFGHI&^");
+ data = toUT16("#BC(?(") + "<" + toUT16("DEF") + ">" + toUT16(")GHI");
+ doTest2("Regex #3", data, "<&#BC(?(<DEF>)GHI&^");
+ doTest1("Regex #4", "#BC(?('DEF')GHI", "<&#BC(?('DEF')GHI&^");
+ doTest1("Regex #5", "#BC(?(DEF)GHI", "<&#BC(?(DEF)GHI&^");
+ data = toUT16("#BC(?") + "&" + toUT16("DEF)GHI");
+ doTest2("Regex #6", data, "<&#BC(?&DEF)GHI&^");
+ data = toUT16("#BC(?") + "P<" + toUT16("DEF") + ">" + toUT16("GHI");
+ doTest2("Regex #7", data, "<&#BC(?p<DEF>GHI&^");
+ data = toUT16("#BC\\k") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
+ doTest2("Regex #8", data, "<&#BC\\k<DEF>GHI&^");
+ doTest1("Regex #9", "#BC\\k'DEF'GHI", "<&#BC\\k'DEF'GHI&^");
+ doTest1("Regex #10", "#BC\\k{DEF}GHI", "<&#BC\\k{DEF}GHI&^");
+ data = toUT16("#BC(?") + "P=" + toUT16("DEF)GHI");
+ doTest2("Regex #11", data, "<&#BC(?p=DEF)GHI&^");
+ doTest1("Regex #12", "#BC\\g{DEF}GHI", "<&#BC\\g{DEF}GHI&^");
+ data = toUT16("#BC\\g") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
+ doTest2("Regex #13", data, "<&#BC\\g<DEF>GHI&^");
+ doTest1("Regex #14", "#BC\\g'DEF'GHI", "<&#BC\\g'DEF'GHI&^");
+ data = toUT16("#BC(?(") + "R&" + toUT16("DEF)GHI");
+ doTest2("Regex #15", data, "<&#BC(?(r&DEF)GHI&^");
+ data = toUT16("#BC") + "\\Q" + toUT16("DEF") + "\\E" + toUT16("GHI");
+ doTest2("Regex #16.0", data, "<&#BC\\qDEF\\eGHI&^");
+ data = toUT16("#BC") + "\\Q" + toUT16("DEF");
+ doTest2("Regex #16.1", data, "<&#BC\\qDEF&^");
+ data = toUT16("#HI") + "\\E" + toUT16("JKL");
+ doTest2("Regex #16.2", data, "<&#HI\\eJKL&^");
+ Locale.setDefault(new Locale("he"));
+
+ processor = STextEngine.PROC_SQL;
state[0] = STextEngine.STATE_INITIAL;
doTest1("SQL #0", "abc GHI", "abc GHI");
doTest1("SQL #1", "abc DEF GHI", "abc DEF@ GHI");
@@ -146,37 +191,34 @@ 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");
- type = ISTextTypes.SYSTEM_USER;
+ processor = STextEngine.PROC_SYSTEM_USER;
state[0] = STextEngine.STATE_INITIAL;
doTest1("System #1", "HOST(JACK)", "HOST@(JACK)");
- type = ISTextTypes.UNDERSCORE;
+ processor = STextEngine.PROC_UNDERSCORE;
state[0] = STextEngine.STATE_INITIAL;
doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
- type = ISTextTypes.URL;
+ processor = STextEngine.PROC_URL;
state[0] = STextEngine.STATE_INITIAL;
doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
- type = ISTextTypes.XPATH;
+ processor = STextEngine.PROC_XPATH;
state[0] = STextEngine.STATE_INITIAL;
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 ");
- type = ISTextTypes.EMAIL;
- processor = STextStringProcessor.getProcessor(type);
+ processor = STextEngine.PROC_EMAIL;
state[0] = STextEngine.STATE_INITIAL;
- f1 = processor.getFeatures(null);
- assertEquals("<>.:,;@", f1.getSeparators());
- f2 = new STextFeatures("+-*/", f1.getSpecialsCount(), f1.getDirArabic(), f1.getDirHebrew(), f1.getIgnoreArabic(), f1.getIgnoreHebrew());
- 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 ");
- doTest3("DelimsEsc #4", "DEF-GHI (A*B\\)*C) /JK ", "DEF@-GHI @(A*B\\)*C) @/JK ");
- doTest3("DelimsEsc #5", "DEF-GHI (A\\\\\\)*C) /JK ", "DEF@-GHI @(A\\\\\\)*C) @/JK ");
- doTest3("DelimsEsc #6", "DEF-GHI (A\\\\)*C /JK ", "DEF@-GHI @(A\\\\)@*C @/JK ");
- doTest3("DelimsEsc #7", "DEF-GHI (A\\)*C /JK ", "DEF@-GHI @(A\\)*C /JK ");
+ assertEquals("<>.:,;@", processor.getSeparators(null, "", null));
+ 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 ");
+ doTest3("DelimsEsc #4", "DEF.GHI (A:B\\):C) ;JK ", "DEF@.GHI @(A:B\\):C) @;JK ");
+ doTest3("DelimsEsc #5", "DEF.GHI (A\\\\\\):C) ;JK ", "DEF@.GHI @(A\\\\\\):C) @;JK ");
+ doTest3("DelimsEsc #6", "DEF.GHI (A\\\\):C ;JK ", "DEF@.GHI @(A\\\\)@:C @;JK ");
+ doTest3("DelimsEsc #7", "DEF.GHI (A\\):C ;JK ", "DEF@.GHI @(A\\):C ;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 da97e1616..5c466fc2a 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,9 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
+import org.eclipse.equinox.bidi.STextEngine;
+import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests fullToLean method
@@ -22,32 +24,32 @@ public class STextFullToLeanTest extends STextTestBase {
static final STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
- String type;
+ STextProcessor processor;
private void doTest1(String msg, String data, String leanLTR, String fullLTR, int[] l2fMapLTR, int[] f2lMapLTR, String leanRTL, String fullRTL, int[] l2fMapRTL, int[] f2lMapRTL) {
String text, full, lean, label;
int[] map;
text = toUT16(data);
- lean = STextEngine.fullToLeanText(type, null, envLTR, text, null);
+ lean = STextEngine.fullToLeanText(processor, envLTR, text, null);
assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
- full = STextEngine.leanToFullText(type, null, envLTR, lean, null);
+ full = STextEngine.leanToFullText(processor, envLTR, lean, null);
assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
- map = STextEngine.leanToFullMap(type, null, envLTR, lean, null);
+ map = STextEngine.leanToFullMap(processor, envLTR, lean, null);
label = msg + "leanToFullMap() LTR";
assertEquals(label, array_display(l2fMapLTR), array_display(map));
- map = STextEngine.fullToLeanMap(type, null, envLTR, text, null);
+ map = STextEngine.fullToLeanMap(processor, envLTR, text, null);
label = msg + "fullToLeanMap() LTR";
assertEquals(label, array_display(f2lMapLTR), array_display(map));
- lean = STextEngine.fullToLeanText(type, null, envRTL, text, null);
+ lean = STextEngine.fullToLeanText(processor, envRTL, text, null);
assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
- full = STextEngine.leanToFullText(type, null, envRTL, lean, null);
+ full = STextEngine.leanToFullText(processor, envRTL, lean, null);
assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
- map = STextEngine.leanToFullMap(type, null, envRTL, lean, null);
+ map = STextEngine.leanToFullMap(processor, envRTL, lean, null);
label = msg + "leanToFullMap() RTL";
assertEquals(label, array_display(l2fMapRTL), array_display(map));
- map = STextEngine.fullToLeanMap(type, null, envRTL, text, null);
+ map = STextEngine.fullToLeanMap(processor, envRTL, text, null);
label = msg + "fullToLeanMap() RTL";
assertEquals(label, array_display(f2lMapRTL), array_display(map));
}
@@ -60,41 +62,41 @@ public class STextFullToLeanTest extends STextTestBase {
data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
text = toUT16(data);
state[0] = -1;
- lean = STextEngine.fullToLeanText(type, null, envLTR, text, state);
+ lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
state1 = state[0];
model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
assertEquals(msg + "LTR lean", model, toPseudo(lean));
state[0] = -1;
- full = STextEngine.leanToFullText(type, null, envLTR, lean, state);
+ full = STextEngine.leanToFullText(processor, envLTR, lean, state);
assertEquals(msg + "LTR full", data, toPseudo(full));
assertEquals(msg + "state from leanToFullText", state1, state[0]);
data = "THIS IS A COMMENT LINE";
text = toUT16(data);
state[0] = state1;
- lean = STextEngine.fullToLeanText(type, null, envLTR, text, state);
+ lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
state2 = state[0];
model = "THIS IS A COMMENT LINE";
assertEquals(msg + "LTR lean2", model, toPseudo(lean));
state[0] = state1;
- full = STextEngine.leanToFullText(type, null, envLTR, lean, state);
+ full = STextEngine.leanToFullText(processor, envLTR, lean, state);
assertEquals(msg + "LTR full2", data, toPseudo(full));
assertEquals(msg + "state from leanToFullText2", state2, state[0]);
data = "SOME MORE */ where \"COL3\"@=123";
text = toUT16(data);
state[0] = state2;
- lean = STextEngine.fullToLeanText(type, null, envLTR, text, state);
+ lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
state3 = state[0];
model = "SOME MORE */ where \"COL3\"=123";
assertEquals(msg + "LTR lean3", model, toPseudo(lean));
state[0] = state2;
- full = STextEngine.leanToFullText(type, null, envLTR, lean, state);
+ full = STextEngine.leanToFullText(processor, envLTR, lean, state);
assertEquals(msg + "LTR full3", data, toPseudo(full));
assertEquals(msg + "state from leanToFullText3", state3, state[0]);
}
public void testFullToLean() {
- type = ISTextTypes.COMMA_DELIMITED;
+ processor = STextEngine.PROC_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};
@@ -241,7 +243,7 @@ public class STextFullToLeanTest extends STextTestBase {
doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2);
// test fullToLeanText with initial state
- type = ISTextTypes.SQL;
+ processor = STextEngine.PROC_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 7c20c6ff2..ab836bf36 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,10 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
+import java.util.Locale;
+import org.eclipse.equinox.bidi.STextEngine;
+import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests RTL arithmetic
@@ -21,26 +24,29 @@ public class STextMathTest extends STextTestBase {
static final STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
- String type = ISTextTypes.RTL_ARITHMETIC;
+ STextProcessor processor = STextEngine.PROC_RTL_ARITHMETIC;
private void verifyOneLine(String msg, String data, String resLTR, String resRTL) {
String lean = toUT16(data);
- String fullLTR = STextEngine.leanToFullText(type, null, envLTR, lean, null);
+ String fullLTR = STextEngine.leanToFullText(processor, envLTR, lean, null);
assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
- String fullRTL = STextEngine.leanToFullText(type, null, envRTL, lean, null);
+ String fullRTL = STextEngine.leanToFullText(processor, envRTL, lean, null);
assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
}
public void testRTLarithmetic() {
verifyOneLine("Math #0", "", "", "");
- verifyOneLine("Math #1", "1+abc", "<&1+abc&^", "1+abc");
- verifyOneLine("Math #2", "2+abc-def", "<&2+abc&-def&^", "2+abc&-def");
- verifyOneLine("Math #3", "a+3*bc/def", "<&a&+3*bc&/def&^", "a&+3*bc&/def");
- verifyOneLine("Math #4", "4+abc/def", "<&4+abc&/def&^", "4+abc&/def");
- verifyOneLine("Math #5", "13ABC", "<&13ABC&^", "13ABC");
- verifyOneLine("Math #6", "14ABC-DE", "<&14ABC-DE&^", "14ABC-DE");
- verifyOneLine("Math #7", "15ABC+DE", "<&15ABC+DE&^", "15ABC+DE");
- verifyOneLine("Math #8", "16ABC*DE", "<&16ABC*DE&^", "16ABC*DE");
- verifyOneLine("Math #9", "17ABC/DE", "<&17ABC/DE&^", "17ABC/DE");
+ verifyOneLine("Math #1", "1+ABC", "1+ABC", ">@1+ABC@^");
+ verifyOneLine("Math #2", "2+ABC-DEF", "2+ABC@-DEF", ">@2+ABC@-DEF@^");
+ verifyOneLine("Math #3", "A+3*BC/DEF", "A@+3*BC@/DEF", ">@A@+3*BC@/DEF@^");
+ verifyOneLine("Math #4", "4+ABC/DEF", "4+ABC@/DEF", ">@4+ABC@/DEF@^");
+ Locale.setDefault(new Locale("ar"));
+ verifyOneLine("Math #5", "5#BC", "<&5#BC&^", "5#BC");
+ verifyOneLine("Math #6", "6#BC-DE", "<&6#BC-DE&^", "6#BC-DE");
+ verifyOneLine("Math #7", "7#BC+DE", "<&7#BC+DE&^", "7#BC+DE");
+ verifyOneLine("Math #8", "8#BC*DE", "<&8#BC*DE&^", "8#BC*DE");
+ verifyOneLine("Math #9", "9#BC/DE", "<&9#BC/DE&^", "9#BC/DE");
+ verifyOneLine("Math #10", "10ab+cd-ef", "10ab+cd-ef", ">@10ab+cd-ef@^");
+ Locale.setDefault(new Locale("he"));
}
}
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 d856c7ff6..c6c49ecf0 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
@@ -11,8 +11,9 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.*;
-import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.STextEngine;
+import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests most public methods of BidiComplexEngine
@@ -20,8 +21,8 @@ import org.eclipse.equinox.bidi.custom.*;
public class STextMethodsTest extends STextTestBase {
- final static int LTR = STextFeatures.DIR_LTR;
- final static int RTL = STextFeatures.DIR_RTL;
+ final static int LTR = STextEngine.DIR_LTR;
+ final static int RTL = STextEngine.DIR_RTL;
final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
@@ -29,6 +30,33 @@ public class STextMethodsTest extends STextTestBase {
final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR);
final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL);
final static STextEnvironment envERR = new STextEnvironment(null, false, 9999);
+ final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
+ int dirArabic, dirHebrew;
+
+ class MyComma extends STextProcessor {
+
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return ","; //$NON-NLS-1$
+ }
+
+ public boolean skipProcessing(STextEnvironment environment, String text, byte[] dirProps) {
+ byte dirProp = getDirProp(text, dirProps, 0);
+ if (dirProp == AL)
+ return true;
+ return false;
+ }
+
+ public int getDirection(STextEnvironment environment, String text, byte[] dirProps) {
+ for (int i = 0; i < text.length(); i++) {
+ byte dirProp = getDirProp(text, dirProps, i);
+ if (dirProp == AL)
+ return dirArabic;
+ }
+ return dirHebrew;
+ }
+ }
+
+ STextProcessor processor;
private void doTestTools() {
@@ -49,20 +77,20 @@ public class STextMethodsTest extends STextTestBase {
String data, lean, full, model;
int[] state = new int[1];
state[0] = -1;
- String type = ISTextTypes.JAVA;
+ processor = STextEngine.PROC_JAVA;
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
- full = STextEngine.leanToFullText(type, null, null, lean, state);
+ full = STextEngine.leanToFullText(processor, null, lean, state);
model = "A@=B@+C@;/* D=E+F;";
assertEquals("full1", model, toPseudo(full));
data = "A=B+C; D=E+F;";
lean = toUT16(data);
- full = STextEngine.leanToFullText(type, null, null, lean, state);
+ full = STextEngine.leanToFullText(processor, null, lean, state);
model = "A=B+C; D=E+F;";
assertEquals("full2", model, toPseudo(full));
data = "A=B+C;*/ D=E+F;";
lean = toUT16(data);
- full = STextEngine.leanToFullText(type, null, null, lean, state);
+ full = STextEngine.leanToFullText(processor, null, lean, state);
model = "A=B+C;@*/ D@=E@+F;";
assertEquals("full3", model, toPseudo(full));
}
@@ -82,88 +110,41 @@ public class STextMethodsTest extends STextTestBase {
assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient);
}
- private void doTestOrient(STextFeatures f, String label, String data, String resLTR, String resRTL, String resCon) {
+ private void doTestOrient(String label, String data, String resLTR, String resRTL, String resCon) {
String full, lean;
- String type = ISTextTypes.COMMA_DELIMITED;
lean = toUT16(data);
- full = STextEngine.leanToFullText(type, f, envLTR, lean, null);
+ full = STextEngine.leanToFullText(processor, envLTR, lean, null);
assertEquals(label + "LTR full", resLTR, toPseudo(full));
- full = STextEngine.leanToFullText(type, f, envRTL, lean, null);
+ full = STextEngine.leanToFullText(processor, envRTL, lean, null);
assertEquals("label + RTL full", resRTL, toPseudo(full));
- full = STextEngine.leanToFullText(type, f, envCRL, lean, null);
+ full = STextEngine.leanToFullText(processor, envCRL, lean, null);
assertEquals(label + "CON full", resCon, toPseudo(full));
}
- private void doTestScripts(STextFeatures f1) {
- STextFeatures f2;
- boolean flag;
- flag = f1.getIgnoreArabic();
- assertFalse("Ignores Arabic 1", flag);
- flag = f1.getIgnoreHebrew();
- assertFalse("Ignores Hebrew 1", flag);
-
- f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, true, true);
- flag = f2.getIgnoreArabic();
- assertTrue("Ignores Arabic 2", flag);
- flag = f2.getIgnoreHebrew();
- assertTrue("Ignores Hebrew 2", flag);
- doTestOrient(f2, "Scripts #1 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF");
- f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, false, true);
- flag = f2.getIgnoreArabic();
- assertFalse("Ignores Arabic 3", flag);
- flag = f2.getIgnoreHebrew();
- assertTrue("Ignores Hebrew 3", flag);
- doTestOrient(f2, "Scripts #2 ", "d,EF", "d,EF", ">@d,EF@^", "d,EF");
- doTestOrient(f2, "Scripts #3 ", "#,eF", "#,eF", ">@#,eF@^", "@#,eF");
- doTestOrient(f2, "Scripts #4 ", "#,12", "#@,12", ">@#@,12@^", "@#@,12");
- doTestOrient(f2, "Scripts #5 ", "#,##", "#@,##", ">@#@,##@^", "@#@,##");
- doTestOrient(f2, "Scripts #6 ", "#,89", "#@,89", ">@#@,89@^", "@#@,89");
- doTestOrient(f2, "Scripts #7 ", "#,ef", "#,ef", ">@#,ef@^", "@#,ef");
- doTestOrient(f2, "Scripts #8 ", "#,", "#,", ">@#,@^", "@#,");
- doTestOrient(f2, "Scripts #9 ", "9,ef", "9,ef", ">@9,ef@^", "9,ef");
- doTestOrient(f2, "Scripts #10 ", "9,##", "9@,##", ">@9@,##@^", "9@,##");
- doTestOrient(f2, "Scripts #11 ", "7,89", "7@,89", ">@7@,89@^", "7@,89");
- doTestOrient(f2, "Scripts #12 ", "7,EF", "7,EF", ">@7,EF@^", "@7,EF");
- doTestOrient(f2, "Scripts #13 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF");
-
- f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, true, false);
- flag = f2.getIgnoreArabic();
- assertTrue("Ignores Arabic 4", flag);
- flag = f2.getIgnoreHebrew();
- assertFalse("Ignores Hebrew 4", flag);
- doTestOrient(f2, "Scripts #14 ", "BCd,EF", "BCd,EF", ">@BCd,EF@^", "@BCd,EF");
- doTestOrient(f2, "Scripts #15 ", "BCD,eF", "BCD,eF", ">@BCD,eF@^", "@BCD,eF");
- doTestOrient(f2, "Scripts #16 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
- doTestOrient(f2, "Scripts #17 ", "BCD,12", "BCD@,12", ">@BCD@,12@^", "@BCD@,12");
- doTestOrient(f2, "Scripts #18 ", "BCD,", "BCD,", ">@BCD,@^", "@BCD,");
-
- f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, false, false);
- doTestOrient(f2, "Scripts #19 ", "123,45|67", "123,45|67", ">@123,45|67@^", "@123,45|67");
- doTestOrient(f2, "Scripts #20 ", "5,e", "5,e", ">@5,e@^", "5,e");
- doTestOrient(f2, "Scripts #21 ", "5,#", "5@,#", ">@5@,#@^", "5@,#");
- doTestOrient(f2, "Scripts #22 ", "5,6", "5@,6", ">@5@,6@^", "5@,6");
- doTestOrient(f2, "Scripts #23 ", "5,D", "5@,D", ">@5@,D@^", "5@,D");
- doTestOrient(f2, "Scripts #24 ", "5,--", "5,--", ">@5,--@^", "@5,--");
+ private void doTestSkipProcessing() {
+ processor = new MyComma();
+ doTestOrient("Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient("Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
}
private void doTestLeanOffsets() {
String lean, data, label;
int[] state = new int[1];
- String type = ISTextTypes.JAVA;
+ processor = STextEngine.PROC_JAVA;
int[] offsets;
int[] model;
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
state[0] = -1;
- offsets = STextEngine.leanBidiCharOffsets(type, null, null, lean, state);
+ offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
model = new int[] {1, 3, 5};
label = "leanBidiCharOffsets() #1 ";
assertEquals(label, array_display(model), array_display(offsets));
data = "A=B+C;*/ D=E+F;";
lean = toUT16(data);
- offsets = STextEngine.leanBidiCharOffsets(type, null, null, lean, state);
+ offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
model = new int[] {6, 10, 12};
label = "leanBidiCharOffsets() #2 ";
assertEquals(label, array_display(model), array_display(offsets));
@@ -172,19 +153,19 @@ public class STextMethodsTest extends STextTestBase {
private void doTestFullOffsets(String label, String data, int[] resLTR, int[] resRTL, int[] resCon) {
String full, lean, msg;
int[] offsets;
- String type = ISTextTypes.COMMA_DELIMITED;
+ processor = STextEngine.PROC_COMMA_DELIMITED;
lean = toUT16(data);
- full = STextEngine.leanToFullText(type, null, envLTR, lean, null);
- offsets = STextEngine.fullBidiCharOffsets(type, null, envLTR, full, null);
+ full = STextEngine.leanToFullText(processor, envLTR, lean, null);
+ offsets = STextEngine.fullBidiCharOffsets(processor, envLTR, full, null);
msg = label + "LTR ";
assertEquals(msg, array_display(resLTR), array_display(offsets));
- full = STextEngine.leanToFullText(type, null, envRTL, lean, null);
- offsets = STextEngine.fullBidiCharOffsets(type, null, envRTL, full, null);
+ full = STextEngine.leanToFullText(processor, envRTL, lean, null);
+ offsets = STextEngine.fullBidiCharOffsets(processor, envRTL, full, null);
msg = label + "RTL ";
assertEquals(msg, array_display(resRTL), array_display(offsets));
- full = STextEngine.leanToFullText(type, null, envCLR, lean, null);
- offsets = STextEngine.fullBidiCharOffsets(type, null, envCLR, full, null);
+ full = STextEngine.leanToFullText(processor, envCLR, lean, null);
+ offsets = STextEngine.fullBidiCharOffsets(processor, envCLR, full, null);
msg = label + "CON ";
assertEquals(msg, array_display(resCon), array_display(offsets));
}
@@ -200,79 +181,84 @@ public class STextMethodsTest extends STextTestBase {
private void doTestDirection() {
String data, lean, full, model, msg;
- ISTextProcessor processor = STextStringProcessor.getProcessor(ISTextTypes.COMMA_DELIMITED);
- STextFeatures f1 = processor.getFeatures(null);
+ int dirA, dirH;
+ processor = new MyComma();
+ dirArabic = RTL;
+ dirHebrew = LTR;
msg = "TestDirection #1";
- assertTrue(msg, f1.getDirArabic() == LTR && f1.getDirHebrew() == LTR);
+ dirA = processor.getDirection(null, toUT16("###"), null);
+ dirH = processor.getDirection(null, toUT16("ABC"), null);
+ assertTrue(msg, dirA == RTL && dirH == LTR);
- STextFeatures f2 = new STextFeatures(f1.getSeparators(), 0, RTL, RTL, false, false);
- f1 = f2;
+ dirArabic = RTL;
+ dirHebrew = RTL;
msg = "TestDirection #2";
- assertTrue(msg, f1.getDirArabic() == RTL && f1.getDirHebrew() == RTL);
+ dirA = processor.getDirection(null, toUT16("###"), null);
+ dirH = processor.getDirection(null, toUT16("ABC"), null);
+ assertTrue(msg, dirA == RTL && dirH == RTL);
- STextEnvironment environment = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
- processor = STextStringProcessor.getProcessor(ISTextTypes.EMAIL);
- f1 = processor.getFeatures(environment);
+ dirArabic = dirHebrew = LTR;
msg = "TestDirection #3";
- assertTrue(msg, f1.getDirArabic() == LTR && f1.getDirHebrew() == LTR);
- data = "#ABC.#DEF:HOST.com";
+ data = "ABC,#DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "#ABC@.#DEF@:HOST.com";
+ full = STextEngine.leanToFullText(processor, null, lean, null);
+ model = "ABC@,#DEF@,HOST,com";
assertEquals("TestDirection #9 full", model, toPseudo(full));
- data = "ABC.DEF:HOST.com";
+ data = "ABC,DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "ABC@.DEF@:HOST.com";
+ full = STextEngine.leanToFullText(processor, null, lean, null);
+ model = "ABC@,DEF@,HOST,com";
assertEquals("TestDirection #10 full", model, toPseudo(full));
- environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
- f1 = processor.getFeatures(environment);
+ dirArabic = RTL;
msg = "TestDirection #10.5";
- assertTrue(msg, f1.getDirArabic() == RTL && f1.getDirHebrew() == LTR);
- data = "#ABC.#DEF:HOST.com";
+ dirA = processor.getDirection(null, toUT16("###"), null);
+ dirH = processor.getDirection(null, toUT16("ABC"), null);
+ assertTrue(msg, dirA == RTL && dirH == LTR);
+ STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
+ data = "ABC,#DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "<&#ABC.#DEF:HOST.com&^";
+ full = STextEngine.leanToFullText(processor, environment, lean, null);
+ model = "<&ABC,#DEF,HOST,com&^";
assertEquals("TestDirection #11 full", model, toPseudo(full));
- data = "#ABc.#DEF:HOSt.COM";
+ data = "ABc,#DEF,HOSt,COM";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "<&#ABc.#DEF:HOSt.COM&^";
+ full = STextEngine.leanToFullText(processor, environment, lean, null);
+ model = "<&ABc,#DEF,HOSt,COM&^";
assertEquals("TestDirection #12 full", model, toPseudo(full));
- data = "#ABc.#DEF:HOSt.";
+ data = "ABc,#DEF,HOSt,";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "<&#ABc.#DEF:HOSt.&^";
+ full = STextEngine.leanToFullText(processor, environment, lean, null);
+ model = "<&ABc,#DEF,HOSt,&^";
assertEquals("TestDirection #13 full", model, toPseudo(full));
- data = "ABC.DEF:HOST.com";
+ data = "ABC,DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "ABC@.DEF@:HOST.com";
+ full = STextEngine.leanToFullText(processor, environment, lean, null);
+ model = "ABC@,DEF@,HOST,com";
assertEquals("TestDirection #14 full", model, toPseudo(full));
- data = "--.---:----";
+ data = "--,---,----";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "--.---:----";
+ full = STextEngine.leanToFullText(processor, environment, lean, null);
+ model = "--,---,----";
assertEquals("TestDirection #15 full", model, toPseudo(full));
- data = "ABC.|DEF:HOST.com";
+ data = "ABC,|DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, environment, lean, null);
- model = "ABC.|DEF@:HOST.com";
+ full = STextEngine.leanToFullText(processor, environment, lean, null);
+ model = "ABC,|DEF@,HOST,com";
assertEquals("TestDirection #16 full", model, toPseudo(full));
- data = "#ABc.|#DEF:HOST.com";
+ data = "ABc,|#DEF,HOST,com";
lean = toUT16(data);
- full = STextEngine.leanToFullText(processor, null, envRTLMIR, lean, null);
- model = "#ABc.|#DEF:HOST.com";
+ full = STextEngine.leanToFullText(processor, envRTLMIR, lean, null);
+ model = "ABc,|#DEF,HOST,com";
assertEquals("TestDirection #17 full", model, toPseudo(full));
- assertEquals("Test curDirection", RTL, STextEngine.getCurDirection(processor, null, envRTLMIR, lean));
+ assertEquals("Test curDirection", RTL, STextEngine.getCurDirection(processor, envRTLMIR, lean));
}
public void testMethods() {
@@ -283,19 +269,18 @@ public class STextMethodsTest extends STextTestBase {
doTestOrientation();
- ISTextProcessor processor = STextStringProcessor.getProcessor(ISTextTypes.COMMA_DELIMITED);
- STextFeatures f = processor.getFeatures(null);
- doTestOrient(f, "Methods #1 ", "", "", "", "");
- doTestOrient(f, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
- doTestOrient(f, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
- doTestOrient(f, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
- doTestOrient(f, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
- doTestOrient(f, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
- doTestOrient(f, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
- doTestOrient(f, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
- doTestOrient(f, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
+ processor = STextEngine.PROC_COMMA_DELIMITED;
+ doTestOrient("Methods #1 ", "", "", "", "");
+ doTestOrient("Methods #2 ", "abc", "abc", ">@abc@^", "abc");
+ doTestOrient("Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
+ doTestOrient("Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
+ doTestOrient("Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient("Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
+ doTestOrient("Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
+ doTestOrient("Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
+ doTestOrient("Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
- doTestScripts(f);
+ doTestSkipProcessing();
doTestLeanOffsets();
@@ -305,10 +290,10 @@ public class STextMethodsTest extends STextTestBase {
doTestDirection();
- String type = ISTextTypes.COMMA_DELIMITED;
+ processor = STextEngine.PROC_COMMA_DELIMITED;
String data = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
String lean = toUT16(data);
- String full = STextEngine.leanToFullText(type, null, null, lean, null);
+ String full = STextEngine.leanToFullText(processor, null, lean, null);
String model = "A@,B@,C@,D@,E@,F@,G@,H@,I@,J@,K@,L@,M@,N@,O@,P@,Q@,R@,S@,T@,U@,V@,W@,X@,Y@,Z";
assertEquals("many inserts", model, toPseudo(full));
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
index 7175917a7..00fedc931 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
/**
* Tests RTL arithmetic
@@ -22,26 +21,26 @@ public class STextNullProcessorTest extends STextTestBase {
static final int[] EMPTY_INT_ARRAY = new int[0];
public void testNullProcessor() {
- String full = STextEngine.leanToFullText(null, null, null, "abc", null);
+ 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, null, "abc", state);
+ full = STextEngine.leanToFullText(null, null, "abc", state);
assertEquals("leanToFullText with state", "abc", full);
- int[] offsets = STextEngine.leanBidiCharOffsets(null, null, null, "abc", null);
+ int[] offsets = STextEngine.leanBidiCharOffsets(null, null, "abc", null);
assertEquals("leanBidiCharOffsets", 0, offsets.length);
- offsets = STextEngine.fullBidiCharOffsets(null, null, null, "abc", null);
+ offsets = STextEngine.fullBidiCharOffsets(null, null, "abc", null);
assertEquals("fullBidiCharOffsets", 0, offsets.length);
- String lean = STextEngine.fullToLeanText(null, null, null, "abc", null);
+ String lean = STextEngine.fullToLeanText(null, null, "abc", null);
assertEquals("fullToLeanText", "abc", lean);
- lean = STextEngine.fullToLeanText(null, null, null, "abc", state);
+ lean = STextEngine.fullToLeanText(null, null, "abc", state);
assertEquals("fullToLeanText with state", "abc", lean);
- int[] map = STextEngine.leanToFullMap(null, null, null, "abc", null);
+ 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, null, "abc", null);
+ map = STextEngine.fullToLeanMap(null, null, "abc", null);
assertEquals("fullToLeanMap", array_display(model), array_display(map));
- int direction = STextEngine.getCurDirection(null, null, null, "abc");
- assertEquals("getCurDirection", STextFeatures.DIR_LTR, direction);
+ int direction = STextEngine.getCurDirection(null, null, "abc");
+ assertEquals("getCurDirection", STextEngine.DIR_LTR, direction);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
index dc6e0ca32..cbea79a8e 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
@@ -13,7 +13,7 @@ package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Tests some weird cases
@@ -23,19 +23,18 @@ public class STextSomeMoreTest extends STextTestBase {
final static STextEnvironment env1 = new STextEnvironment("en_US", false, STextEnvironment.ORIENT_LTR);
final static STextEnvironment env2 = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
- final static STextFeatures myFeatures = new STextFeatures(null, 1, -1, -1, false, false);
class Processor1 extends STextProcessor {
- public STextFeatures getFeatures(STextEnvironment env) {
- return myFeatures;
+ public int getSpecialsCount(STextEnvironment env, String text, byte[] dirProps) {
+ return 1;
}
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment env, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
return fromIndex;
}
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment env, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
int len = text.length();
for (int i = len - 1; i >= 0; i--) {
STextProcessor.insertMark(text, dirProps, offsets, i);
@@ -47,19 +46,20 @@ public class STextSomeMoreTest extends STextTestBase {
class Processor2 extends STextProcessor {
- public STextFeatures getFeatures(STextEnvironment env) {
- return myFeatures;
+ public int getSpecialsCount(STextEnvironment env, String text, byte[] dirProps) {
+ return 1;
}
+
}
class Processor3 extends STextProcessor {
- public STextFeatures getFeatures(STextEnvironment env) {
- return myFeatures;
+ public int getSpecialsCount(STextEnvironment env, String text, byte[] dirProps) {
+ return 1;
}
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
- return 0;
+ public int indexOfSpecial(STextEnvironment env, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ return fromIndex;
}
}
@@ -67,14 +67,14 @@ public class STextSomeMoreTest extends STextTestBase {
assertFalse(env1.isBidi());
assertTrue(env2.isBidi());
- ISTextProcessor processor = new Processor1();
- String full = STextEngine.leanToFullText(processor, null, env1, "abcd", null);
+ STextProcessor processor = new Processor1();
+ String full = STextEngine.leanToFullText(processor, env1, "abcd", null);
assertEquals("@a@b@c@d", toPseudo(full));
processor = new Processor2();
boolean catchFlag = false;
try {
- full = STextEngine.leanToFullText(processor, null, env1, "abcd", null);
+ full = STextEngine.leanToFullText(processor, env1, "abcd", null);
} catch (IllegalStateException e) {
catchFlag = true;
}
@@ -83,7 +83,7 @@ public class STextSomeMoreTest extends STextTestBase {
processor = new Processor3();
catchFlag = false;
try {
- full = STextEngine.leanToFullText(processor, null, env1, "abcd", null);
+ full = STextEngine.leanToFullText(processor, env1, "abcd", null);
} catch (IllegalStateException e) {
catchFlag = true;
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java
index bd96f6d3b..253989795 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.STextEngine;
import org.eclipse.equinox.bidi.STextStringRecord;
-import org.eclipse.equinox.bidi.custom.STextStringProcessor;
/**
* Tests the StringRecord class
@@ -21,99 +21,123 @@ public class STextStringRecordTest extends STextTestBase {
public void testStringRecord() {
STextStringRecord sr;
boolean catchFlag;
- short[] badTriplet1 = new short[] {0, 0};
- short[] badTriplet2 = new short[] {0, 0, -1};
- short[] badTriplet3 = new short[] {0, 0, 999};
- short[] goodTriplet = new short[] {0, 3, 2};
- short[] triplets;
- short type;
- String strType;
// check handling of invalid arguments
catchFlag = false;
try {
- sr = new STextStringRecord(null, badTriplet1);
+ sr = STextStringRecord.addRecord(null, 1, STextEngine.PROC_EMAIL, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
assertTrue("Catch null string argument", catchFlag);
catchFlag = false;
try {
- sr = new STextStringRecord("xxx", null);
+ sr = STextStringRecord.addRecord("abc", 1, null, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
- assertTrue("Catch null triplets argument", catchFlag);
+ assertTrue("Catch null processor argument", catchFlag);
catchFlag = false;
try {
- sr = new STextStringRecord("xxx", badTriplet1);
+ sr = STextStringRecord.addRecord("abc", 0, STextEngine.PROC_EMAIL, 0, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
- assertTrue("Catch bad triplet #1 argument", catchFlag);
+ assertTrue("Catch invalid segment count argument", catchFlag);
catchFlag = false;
try {
- sr = new STextStringRecord("xxx", badTriplet2);
+ sr = STextStringRecord.addRecord("abc", 1, STextEngine.PROC_EMAIL, -1, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
- assertTrue("Catch bad triplet #2 argument", catchFlag);
+ assertTrue("Catch invalid start argument", catchFlag);
catchFlag = false;
try {
- sr = new STextStringRecord("xxx", badTriplet3);
+ sr = STextStringRecord.addRecord("abc", 1, STextEngine.PROC_EMAIL, 4, 1);
} catch (IllegalArgumentException e) {
catchFlag = true;
}
- assertTrue("Catch bad triplet #3 argument", catchFlag);
-
- String[] types = STextStringProcessor.getKnownTypes();
- for (int i = 0; i < types.length; i++) {
- type = STextStringRecord.typeStringToShort(types[i]);
- assertFalse(type == -1);
- strType = STextStringRecord.typeShortToString(type);
- assertEquals(types[i], strType);
+ assertTrue("Catch invalid start argument", catchFlag);
+ catchFlag = false;
+ try {
+ sr = STextStringRecord.addRecord("abc", 1, STextEngine.PROC_EMAIL, 0, 0);
+ } catch (IllegalArgumentException e) {
+ catchFlag = true;
+ }
+ assertTrue("Catch invalid limit argument", catchFlag);
+ catchFlag = false;
+ try {
+ sr = STextStringRecord.addRecord("abc", 1, STextEngine.PROC_EMAIL, 0, 5);
+ } catch (IllegalArgumentException e) {
+ catchFlag = true;
}
- type = STextStringRecord.typeStringToShort("dummy");
- assertEquals(-1, type);
- strType = STextStringRecord.typeShortToString((short) 999);
- assertEquals(null, strType);
+ assertTrue("Catch invalid limit argument", catchFlag);
+
int poolSize = STextStringRecord.POOLSIZE;
int lim = poolSize / 2;
- triplets = STextStringRecord.getTriplets("xxx");
- assertEquals(null, triplets);
+ sr = STextStringRecord.getRecord("XXX");
+ assertEquals(null, sr);
for (int i = 0; i < lim; i++) {
String str = Integer.toString(i);
- sr = new STextStringRecord(str, goodTriplet);
- STextStringRecord.add(sr);
+ sr = STextStringRecord.addRecord(str, 1, STextEngine.PROC_EMAIL, 0, 1);
}
- triplets = STextStringRecord.getTriplets(null);
- assertEquals(null, triplets);
- triplets = STextStringRecord.getTriplets("");
- assertEquals(null, triplets);
+ sr = STextStringRecord.getRecord(null);
+ assertEquals(null, sr);
+ sr = STextStringRecord.getRecord("");
+ assertEquals(null, sr);
+
for (int i = 0; i < poolSize; i++) {
String str = Integer.toString(i);
- triplets = STextStringRecord.getTriplets(str);
+ sr = STextStringRecord.getRecord(str);
if (i < lim)
- assertFalse(null == triplets);
+ assertFalse(null == sr);
else
- assertTrue(null == triplets);
+ assertTrue(null == sr);
}
+
for (int i = lim; i <= poolSize; i++) {
String str = Integer.toString(i);
- sr = new STextStringRecord(str, goodTriplet);
- STextStringRecord.add(sr);
+ sr = STextStringRecord.addRecord(str, 1, STextEngine.PROC_EMAIL, 0, 1);
}
for (int i = 1; i <= poolSize; i++) {
String str = Integer.toString(i);
- triplets = STextStringRecord.getTriplets(str);
- assertFalse(null == triplets);
+ sr = STextStringRecord.getRecord(str);
+ assertFalse(null == sr);
+ }
+ sr = STextStringRecord.getRecord("0");
+ assertEquals(null, sr);
+ sr = STextStringRecord.addRecord("thisisalongstring", 3, STextEngine.PROC_EMAIL, 0, 2);
+ sr.addSegment(STextEngine.PROC_JAVA, 4, 5);
+ sr.addSegment(STextEngine.PROC_FILE, 6, 7);
+ catchFlag = false;
+ try {
+ sr.addSegment(STextEngine.PROC_EMAIL, 10, 13);
+ } catch (IllegalStateException e) {
+ catchFlag = true;
}
- triplets = STextStringRecord.getTriplets("0");
- assertEquals(null, triplets);
+ assertTrue("Catch too many segments", catchFlag);
+ assertEquals(3, sr.getSegmentCount());
+ assertEquals(STextEngine.PROC_EMAIL, sr.getProcessor(0));
+ assertEquals(STextEngine.PROC_JAVA, sr.getProcessor(1));
+ assertEquals(STextEngine.PROC_FILE, sr.getProcessor(2));
+ assertEquals(0, sr.getStart(0));
+ assertEquals(4, sr.getStart(1));
+ assertEquals(6, sr.getStart(2));
+ assertEquals(2, sr.getLimit(0));
+ assertEquals(5, sr.getLimit(1));
+ assertEquals(7, sr.getLimit(2));
+ catchFlag = false;
+ try {
+ sr.getLimit(3);
+ } catch (IllegalArgumentException e) {
+ catchFlag = true;
+ }
+ assertTrue("Catch segment number too large", catchFlag);
+
STextStringRecord.clear();
for (int i = 0; i <= poolSize; i++) {
String str = Integer.toString(i);
- triplets = STextStringRecord.getTriplets(str);
- assertEquals(null, triplets);
+ sr = STextStringRecord.getRecord(str);
+ assertEquals(null, sr);
}
}
}
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 1f3e0b8f9..f70828f41 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
@@ -11,23 +11,12 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
-import org.eclipse.equinox.bidi.custom.ISTextProcessor;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
-public class STextTest implements ISTextProcessor {
+public class STextTest extends STextProcessor {
- static final STextFeatures FEATURES = new STextFeatures("-=.:", 0, -1, -1, false, false);
-
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
- }
-
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
- throw new IllegalStateException();
- }
-
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
- throw new IllegalStateException();
+ public String getSeparators(STextEnvironment env, String text, byte[] dirProps) {
+ return "-=.:";
}
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java
index b775f0522..2b4fe770c 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java
@@ -12,8 +12,8 @@
package org.eclipse.equinox.bidi.internal.tests;
import java.util.Locale;
+import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextUtil;
-import org.eclipse.equinox.bidi.ISTextTypes;
/**
* Tests methods in BidiComplexUtil
@@ -83,9 +83,9 @@ public class STextUtilTest extends STextTestBase {
}
private void doTest3(String msg, String data, String result, String resLean) {
- String full = STextUtil.processTyped(toUT16(data), ISTextTypes.COMMA_DELIMITED);
+ String full = STextUtil.processTyped(toUT16(data), STextEngine.PROC_COMMA_DELIMITED);
assertEquals(msg + "full", result, toPseudo(full));
- String lean = STextUtil.deprocess(full, ISTextTypes.COMMA_DELIMITED);
+ String lean = STextUtil.deprocess(full, STextEngine.PROC_COMMA_DELIMITED);
assertEquals(msg + "lean", resLean, toPseudo(lean));
}
@@ -111,20 +111,6 @@ public class STextUtilTest extends STextTestBase {
doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^");
doTest3("Util #3.2 - ", "", "");
doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
- boolean catchFlag = false;
- try {
- STextUtil.deprocess(toUT16("ABC,DE"), "wrong_type");
- } catch (IllegalArgumentException e) {
- catchFlag = true;
- }
- assertTrue("Catch invalid type on deprocess", catchFlag);
- catchFlag = false;
- try {
- STextUtil.processTyped("abc", "wrong_type");
- } catch (IllegalArgumentException e) {
- catchFlag = true;
- }
- assertTrue("Catch invalid type on process", catchFlag);
// 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@^");
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/ISTextTypes.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/ISTextTypes.java
deleted file mode 100644
index 4b17de76c..000000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/ISTextTypes.java
+++ /dev/null
@@ -1,106 +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;
-
-/**
- * Bidirectional processors supplied in this bundle.
- *
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface ISTextTypes {
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing property file statements. It expects the following
- * string format:
- * <pre>
- * name=value
- * </pre>
- */
- public String PROPERTY = "property"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing compound names.
- * This type covers names made of one or more parts separated by underscores:
- * <pre>
- * part1_part2_part3
- * </pre>
- */
- public String UNDERSCORE = "underscore"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing comma-delimited lists, such as:
- * <pre>
- * part1,part2,part3
- * </pre>
- */
- public String COMMA_DELIMITED = "comma"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing strings with the following format:
- * <pre>
- * system(user)
- * </pre>
- */
- public String SYSTEM_USER = "system"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing directory and file paths.
- */
- public String FILE = "file"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing e-mail addresses.
- */
- public String EMAIL = "email"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing URLs.
- */
- public String URL = "url"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing regular expressions, possibly spanning more than one
- * line.
- */
- public String REGEXP = "regex"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing XPath expressions.
- */
- public String XPATH = "xpath"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing Java code, possibly spanning more than one line.
- */
- public String JAVA = "java"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing SQL statements, possibly spanning more than one line.
- */
- public String SQL = "sql"; //$NON-NLS-1$
-
- /**
- * Constant indicating a type of structured text processor adapted
- * to processing arithmetic expressions with a RTL base direction.
- */
- public String RTL_ARITHMETIC = "math"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
index da8649f67..3d05bf8a6 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
@@ -10,8 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.bidi;
-import org.eclipse.equinox.bidi.custom.ISTextProcessor;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.custom.STextStringProcessor;
import org.eclipse.equinox.bidi.internal.STextImpl;
/**
@@ -29,26 +29,17 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
* <h2><a name="processor">How to Specify a Processor</a></h2>
*
* <p>All the methods in this class have a first argument which
- * designates a type of processor.
+ * designates a processor.
*
- * <p>It can be specified as a string (usually one of the
- * literals to be found in {@link ISTextTypes}
- * or as an instance of {@link ISTextProcessor}.
+ * <p>It must be specified as an instance of {@link STextProcessor}.
+ * Pre-defined instances are included in <b>STextEngine</b> for all
+ * the types of structured text supported by this package.
*
- * <p>Such an instance can be obtained using the
+ * <p>For processors supplied by other packages, a processor instance
+ * can be obtained using the
* {@link org.eclipse.equinox.bidi.custom.STextStringProcessor#getProcessor getProcessor}
* method for the registered processors, or by instantiating a private processor.
*
- * <p>When the same processor is used in multiple calls, it may be
- * beneficial to obtain a reference to the processor and to use it
- * in following calls, rather than to specify the processor by its
- * type expressed as a string, which necessitates a registry search
- * for each call.
- *
- * <p>A processor reference is also the only way to examine the
- * features of a processor by calling its
- * {@link ISTextProcessor#getFeatures getFeatures} method.
- *
* <p>Specifying <code>null</code> for the processor as first argument
* of a method causes this method to behave as a no-op.
*
@@ -90,7 +81,7 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
* <pre>
*
* String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext";
- * String fullText = STextEngine.leanToFullText(ISTextTypes.FILE, null, null, leanText, null);
+ * String fullText = STextEngine.leanToFullText(STextEngine.PROC_FILE, null, leanText, null);
* System.out.println("full text = " + fullText);
*
* </pre>
@@ -104,10 +95,10 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
* int[] state = new int[1];
* state[0] = STextEngine.STATE_INITIAL;
* String leanText = "int i = 3; // first Java statement";
- * String fullText = STextEngine.leanToFullText(ISTextTypes.JAVA, null, null, leanText, state);
+ * String fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
* System.out.println("full text = " + fullText);
* leanText = "i += 4; // next Java statement";
- * fullText = STextEngine.leanToFullText(ISTextTypes.JAVA, null, null, leanText, state);
+ * fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
* System.out.println("full text = " + fullText);
*
* </pre>
@@ -123,6 +114,113 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
*/
public class STextEngine {
/**
+ * Constant indicating a type of structured text processor adapted
+ * to processing property file statements. It expects the following
+ * format:
+ * <pre>
+ * name=value
+ * </pre>
+ */
+ public static final STextProcessor PROC_PROPERTY = STextStringProcessor.getProcessor("property"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing compound names.
+ * This type covers names made of one or more parts separated by underscores:
+ * <pre>
+ * part1_part2_part3
+ * </pre>
+ */
+ public static final STextProcessor PROC_UNDERSCORE = STextStringProcessor.getProcessor("underscore"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing comma-delimited lists, such as:
+ * <pre>
+ * part1,part2,part3
+ * </pre>
+ */
+ public static final STextProcessor PROC_COMMA_DELIMITED = STextStringProcessor.getProcessor("comma"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing strings with the following format:
+ * <pre>
+ * system(user)
+ * </pre>
+ */
+ public static final STextProcessor PROC_SYSTEM_USER = STextStringProcessor.getProcessor("system"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing directory and file paths.
+ */
+ public static final STextProcessor PROC_FILE = STextStringProcessor.getProcessor("file"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing e-mail addresses.
+ */
+ public static final STextProcessor PROC_EMAIL = STextStringProcessor.getProcessor("email"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing URLs.
+ */
+ public static final STextProcessor PROC_URL = STextStringProcessor.getProcessor("url"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing regular expressions, possibly spanning more than one
+ * line.
+ */
+ public static final STextProcessor PROC_REGEXP = STextStringProcessor.getProcessor("regex"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing XPath expressions.
+ */
+ public static final STextProcessor PROC_XPATH = STextStringProcessor.getProcessor("xpath"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing Java code, possibly spanning more than one line.
+ */
+ public static final STextProcessor PROC_JAVA = STextStringProcessor.getProcessor("java"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing SQL statements, possibly spanning more than one line.
+ */
+ public static final STextProcessor PROC_SQL = STextStringProcessor.getProcessor("sql"); //$NON-NLS-1$
+
+ /**
+ * Constant indicating a type of structured text processor adapted
+ * to processing arithmetic expressions, possibly with a RTL base direction.
+ */
+ public static final STextProcessor PROC_RTL_ARITHMETIC = STextStringProcessor.getProcessor("math"); //$NON-NLS-1$
+
+ /**
+ * Constant specifying that the base direction of a structured text is LTR.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public static final int DIR_LTR = 0;
+
+ /**
+ * Constant specifying that the base direction of a structured text is RTL.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public static final int DIR_RTL = 1;
+
+ /**
* Constant to use in the first element of the <code>state</code>
* argument when calling most methods of this class
* to indicate that there is no context of previous lines which
@@ -142,22 +240,12 @@ public class STextEngine {
/** Add directional formatting characters to a structured text
* to ensure correct presentation.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
* returns the <code>text</code> string.
*
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
- *
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
* <p>This argument may be specified as <code>null</code>,
@@ -179,32 +267,22 @@ public class STextEngine {
* characters added at proper locations to ensure correct
* presentation.
*/
- public static String leanToFullText(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (processor == null)
return text;
- return STextImpl.leanToFullText(processor, features, environment, text, state);
+ return STextImpl.leanToFullText(processor, environment, text, state);
}
/**
* Given a <i>lean</i> string, compute the positions of each of its
* characters within the corresponding <i>full</i> string.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
* returns an identity map.
*
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
- *
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
* <p>This argument may be specified as <code>null</code>,
@@ -226,14 +304,14 @@ public class STextEngine {
* in the <code>text</code> argument, equal to the offset of the
* corresponding character in the <i>full</i> string.
*/
- public static int[] leanToFullMap(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (processor == null) {
int[] map = new int[text.length()];
for (int i = 0; i < map.length; i++)
map[i] = i;
return map;
}
- return STextImpl.leanToFullMap(processor, features, environment, text, state);
+ return STextImpl.leanToFullMap(processor, environment, text, state);
}
/**
@@ -247,22 +325,12 @@ public class STextEngine {
* depending on the {@link STextEnvironment#getOrientation orientation} of the
* GUI component used for display are not reflected in this method.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
* returns an empty array.
*
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
- *
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
* <p>This argument may be specified as <code>null</code>,
@@ -285,32 +353,22 @@ public class STextEngine {
* added to ensure correct presentation.
* The offsets are sorted in ascending order.
*/
- public static int[] leanBidiCharOffsets(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (processor == null)
return EMPTY_INT_ARRAY;
- return STextImpl.leanBidiCharOffsets(processor, features, environment, text, state);
+ return STextImpl.leanBidiCharOffsets(processor, environment, text, state);
}
/**
* Remove directional formatting characters which were added to a
* structured text string to ensure correct presentation.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
* returns the <code>text</code> string.
*
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
- *
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
* <p>This argument may be specified as <code>null</code>,
@@ -334,32 +392,22 @@ public class STextEngine {
* with {@link #leanToFullText leanToFullText}.
*
*/
- public static String fullToLeanText(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (processor == null)
return text;
- return STextImpl.fullToLeanText(processor, features, environment, text, state);
+ return STextImpl.fullToLeanText(processor, environment, text, state);
}
/**
* Given a <i>full</i> string, compute the positions of each of its
* characters within the corresponding <i>lean</i> string.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
* returns an identity map.
*
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
- *
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
* <p>This argument may be specified as <code>null</code>,
@@ -387,14 +435,14 @@ public class STextEngine {
* added when invoking {@link #leanToFullText leanToFullText}),
* the value returned for this character is -1.
*/
- public static int[] fullToLeanMap(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (processor == null) {
int[] map = new int[text.length()];
for (int i = 0; i < map.length; i++)
map[i] = i;
return map;
}
- return STextImpl.fullToLeanMap(processor, features, environment, text, state);
+ return STextImpl.fullToLeanMap(processor, environment, text, state);
}
/**
@@ -408,22 +456,12 @@ public class STextEngine {
* depending on the {@link STextEnvironment#getOrientation orientation}
* of the GUI component used for display.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
* returns an empty array.
*
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
- *
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
* <p>This argument may be specified as <code>null</code>,
@@ -447,10 +485,10 @@ public class STextEngine {
* added to ensure correct presentation.
* The offsets are sorted in ascending order.
*/
- public static int[] fullBidiCharOffsets(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (processor == null)
return EMPTY_INT_ARRAY;
- return STextImpl.fullBidiCharOffsets(processor, features, environment, text, state);
+ return STextImpl.fullBidiCharOffsets(processor, environment, text, state);
}
/**
@@ -461,21 +499,11 @@ public class STextEngine {
* text determines which is the governing script) and on
* whether the GUI is {@link STextEnvironment#getMirrored mirrored}.
*
- * @param processor designates one of the registered processors.
- * It can be a string containing a keyword according to
- * the processor type, or a processor reference.
+ * @param processor designates a processor instance.
* For more details, see above <a href="#processor">
* How to Specify a Processor</a>.
* <p>If this argument is <code>null</code>, this method
- * returns {@link STextFeatures#DIR_LTR}.
- *
- * @param features specifies features that affect the processor's
- * behavior.
- * <p>This argument may be specified as <code>null</code>,
- * in which case the processor will use its standard features
- * (as returned by the processor
- * {@link ISTextProcessor#getFeatures getFeatures}
- * method).
+ * returns {@link #DIR_LTR}.
*
* @param environment specifies an environment whose characteristics
* may affect the processor's behavior.
@@ -487,11 +515,13 @@ public class STextEngine {
* @param text is the structured text string.
*
* @return the base direction of the structured text.
- * It is one of the values {@link STextFeatures#DIR_LTR}
- * or {@link STextFeatures#DIR_RTL}.
+ * It is one of the values {@link #DIR_LTR}
+ * or {@link #DIR_RTL}.
*/
- public static int getCurDirection(Object processor, STextFeatures features, STextEnvironment environment, String text) {
- return STextImpl.getCurDirection(processor, features, environment, text, null);
+ public static int getCurDirection(STextProcessor processor, STextEnvironment environment, String text) {
+ if (processor == null)
+ return DIR_LTR;
+ return STextImpl.getCurDirection(processor, environment, text, null);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java
index 5108424f1..5a6500c44 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi;
import java.util.Locale;
-import org.eclipse.equinox.bidi.custom.ISTextProcessor;
import org.eclipse.equinox.bidi.internal.STextActivator;
/**
@@ -35,7 +34,6 @@ import org.eclipse.equinox.bidi.internal.STextActivator;
* <p>
* This class also provides a number of convenience methods related to the environment.
* <p>&nbsp;</p>
- * @see ISTextProcessor#getFeatures
*
* @author Matitiahu Allouche
*/
@@ -130,11 +128,6 @@ public class STextEnvironment {
*/
final int orientation;
- static Locale defaultLocale;
- static String defaultLanguage;
- static boolean defaultBidi;
- boolean bidiFlag;
-
/**
* Constructor
*
@@ -162,26 +155,26 @@ public class STextEnvironment {
* @see #getOrientation
*/
public STextEnvironment(String lang, boolean mirrored, int orientation) {
- if (lang == null) {
- language = null;
- } else {
+ if (lang != null) {
if (lang.length() > 2)
language = lang.substring(0, 2);
else
language = lang;
- bidiFlag = isBidiLanguage(language);
- }
+ } else
+ language = null;
this.mirrored = mirrored;
this.orientation = orientation >= ORIENT_LTR && orientation <= ORIENT_IGNORE ? orientation : ORIENT_UNKNOWN;
}
/**
* Return a 2-letters code representing a language as defined by
- * ISO-639. If equal to <code>null</code>, it defaults to the language
- * of the current default locale.
+ * ISO-639. If specified as <code>null</code>, it defaults to the
+ * language of the current default locale.
*/
public String getLanguage() {
- return language;
+ if (language != null)
+ return language;
+ return getDefaultLocale().getLanguage();
}
/**
@@ -260,20 +253,12 @@ public class STextEnvironment {
* @see #getLanguage
*/
public boolean isBidi() {
- if (defaultLanguage != null && defaultLocale.equals(getDefaultLocale()))
- return defaultBidi;
-
- if (language == null) {
- defaultLocale = getDefaultLocale();
- defaultLanguage = defaultLocale.getLanguage();
- defaultBidi = isBidiLanguage(defaultLanguage);
- return defaultBidi;
- }
-
- return bidiFlag;
+ if (language != null)
+ return isBidiLanguage(language);
+ return isBidiLanguage(getDefaultLocale().getLanguage());
}
- static boolean isBidiLanguage(String lang) {
+ boolean isBidiLanguage(String lang) {
return "iw".equals(lang) || "he".equals(lang) || "ar".equals(lang) || "fa".equals(lang) || "ur".equals(lang); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
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 fc50de390..76bd6f853 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java
@@ -11,10 +11,10 @@
package org.eclipse.equinox.bidi;
import java.lang.ref.SoftReference;
-import org.eclipse.equinox.bidi.custom.STextStringProcessor;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
- * This class records strings which are structured text. Several static
+ * This class records strings which contain structured text. Several static
* methods in this class allow to record such strings in a pool, and to find if
* a given string is member of the pool.
* <p>
@@ -22,6 +22,11 @@ import org.eclipse.equinox.bidi.custom.STextStringProcessor;
* <p>
* The pool is managed as a cyclic list. When the pool is full,
* each new element overrides the oldest element in the list.
+ * <p>
+ * 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.
*/
public class STextStringRecord {
/**
@@ -33,160 +38,296 @@ public class STextStringRecord {
private static final int MAXINDEX = POOLSIZE - 1;
// index of the last entered record
- private static int last = MAXINDEX;
+ private static int last = -1;
+
+ // flag indicating that the pool has wrapped around
+ private static boolean wrapAround;
// the pool
- private static STextStringRecord[] records = new STextStringRecord[POOLSIZE];
+ private static SoftReference[] recordRefs = new SoftReference[POOLSIZE];
- // structured text types
- private static final String[] types = STextStringProcessor.getKnownTypes();
+ // hash code of the recorded strings
+ private static int[] hashArray = new int[POOLSIZE];
- // maximum type index allowed
- private static int MAXTYPE = types.length - 1;
+ // total number of segments in the record
+ private int totalSegmentCount;
+
+ // number of used segments in the record
+ private int usedSegmentCount;
// reference to the recorded string
- private SoftReference strRef;
+ private String string;
- // hash code of the recorded string
- private int hash;
+ // reference to the processors of the STT segments in the recorded string
+ private STextProcessor[] processors;
- // reference to the triplets of the recorded string
- private SoftReference triRef;
+ // reference to the boundaries of the STT segments in the recorded string
+ // (entries 0, 2, 4, ... are start offsets; entries 1, 3, 5, ... are
+ // ending offsets)
+ private short[] boundaries;
/**
- * Constructor.
- *
- * @param string the string to record
- *
- * @param triplets
- * array of short integers, the number of elements in the array
- * must be a multiple of 3, so that the array is made of one or
- * more triplets of short integers.
- * <p>
- * The first element in each triplet is the beginning offset of a
- * susbstring of <code>string</code> which is a structured text.
- * <p>
- * The second element in each triplet is the ending offset of a
- * susbstring of <code>string</code> which is a structured text.
- * This offset points to one position beyond the last
- * character of the substring.
- * <p>
- * The third element in each triplet is the numeric type of the
- * structured text.<br>
- * The type of a structured text must be one of the string
- * values listed in {@link ISTextTypes}.<br>
- * The corresponding numeric type must be obtained using the
- * method {@link #typeStringToShort typeStringToShort}.
+ * Constructor
*/
- public STextStringRecord(String string, short[] triplets) {
- if (string == null || triplets == null)
- throw new IllegalArgumentException("The string and triplets argument must not be null!"); //$NON-NLS-1$
- if ((triplets.length % 3) != 0)
- throw new IllegalArgumentException("The number of elements in triplets must be a multiple of 3!"); //$NON-NLS-1$
- for (int i = 2; i < triplets.length; i += 3)
- if (triplets[i] < 0 || triplets[i] > MAXTYPE)
- throw new IllegalArgumentException("Illegal type value in element" + i); //$NON-NLS-1$
- strRef = new SoftReference(string);
- triRef = new SoftReference(triplets);
- hash = string.hashCode();
+ private STextStringRecord() {
+ // inhibit creation of new instances by customers
}
/**
- * Get the numeric type of a structured text given its string type.
+ * Record a string in the pool. The caller must specify the number
+ * of segments in the record (at least 1), and the processor, starting
+ * and ending offsets for the first segment.
*
- * @param type type of structured text as string. It must be one
- * of the strings listed in {@link ISTextTypes}.
+ * @param string the string to record.
*
- * @return a value which is the corresponding numeric type. If
- * <code>type</code> is invalid, the method returns <code>-1</code>.
- */
- public static short typeStringToShort(String type) {
- for (int i = 0; i < types.length; i++)
- if (types[i].equals(type))
- return (short) i;
- return -1;
- }
-
- /**
- * Get the string type of a structured text given its numeric type.
+ * @param segmentCount number of segments allowed in this string.
+ * This number must be >= 1.
*
- * @param shType
- * the numeric type of a structured text. It should be a value
- * obtained using {@link #typeStringToShort typeStringToShort}.
+ * @param processor the processor appropriate to handle the type
+ * of structured text present in the first segment.
+ * It may be one of the pre-defined processor instances
+ * appearing in {@link STextEngine}, or it may be an instance
+ * created by a plug-in or by the application.
*
- * @return the corresponding string type. If <code>shType</code> is invalid,
- * the method returns <code>null</code>.
+ * @param start offset in the string of the starting character of the first
+ * segment. It must be >= 0 and less than the length of the string.
+ *
+ * @param limit offset of the character following the first segment. It
+ * must be greater than the <code>start</code> argument and
+ * not greater than the length of the string.
+ *
+ * @return an instance of STextRecordString which represents this record.
+ * This instance may be used to specify additional segment with
+ * {@link #addSegment addSegment}.
+ *
+ * @throws IllegalArgumentException if <code>string</code> is null or
+ * if <code>segmentCount</code> is less than 1.
+ * @throws also the same exceptions as {@link #addSegment addSegment}.
*/
- public static String typeShortToString(short shType) {
- if (shType < 0 || shType > MAXTYPE)
- return null;
- return types[shType];
+ public static STextStringRecord addRecord(String string, int segmentCount, STextProcessor processor, int start, int limit) {
+ if (string == null)
+ throw new IllegalArgumentException("The string argument must not be null!"); //$NON-NLS-1$
+ if (segmentCount < 1)
+ throw new IllegalArgumentException("The segment count must be at least 1!"); //$NON-NLS-1$
+ synchronized (recordRefs) {
+ if (last < MAXINDEX)
+ last++;
+ else {
+ wrapAround = true;
+ last = 0;
+ }
+ }
+ STextStringRecord record = null;
+ if (recordRefs[last] != null)
+ record = (STextStringRecord) recordRefs[last].get();
+ if (record == null) {
+ record = new STextStringRecord();
+ recordRefs[last] = new SoftReference(record);
+ }
+ hashArray[last] = string.hashCode();
+ for (int i = 0; i < record.usedSegmentCount; i++)
+ record.processors[i] = null;
+ if (segmentCount > record.totalSegmentCount) {
+ record.processors = new STextProcessor[segmentCount];
+ record.boundaries = new short[segmentCount * 2];
+ record.totalSegmentCount = segmentCount;
+ }
+ record.usedSegmentCount = 0;
+ record.string = string;
+ record.addSegment(processor, start, limit);
+ return record;
}
/**
- * Add a record to the pool.
+ * Add a second or further segment to a record.
+ *
+ * @param processor the processor appropriate to handle the type
+ * of structured text present in this segment.
+ * It may be one of the pre-defined processor instances
+ * appearing in {@link STextEngine}, or it may be an instance
+ * created by a plug-in or by the application.
+ *
+ * @param start offset in the string of the starting character of the
+ * segment. It must be >= 0 and less than the length of the string.
*
- * @param record a STextStringRecord instance
+ * @param limit offset of the character following the segment. It must be
+ * greater than the <code>start</code> argument and not greater
+ * than the length of the string.
+ *
+ * @throws IllegalArgumentException if <code>processor</code> is null,
+ * or if <code>start</code> or <code>limit</code> have invalid
+ * values.
+ * @throws IllegalStateException if the current segment exceeds the
+ * number of segments specified by <code>segmentCount</code>
+ * in the call to {@link #addRecord addRecord} which created
+ * the STextStringRecord instance.
*/
- public static synchronized void add(STextStringRecord record) {
- if (last < MAXINDEX)
- last++;
- else
- last = 0;
- records[last] = record;
+ public void addSegment(STextProcessor processor, int start, int limit) {
+ if (processor == null)
+ throw new IllegalArgumentException("The processor argument must not be null!"); //$NON-NLS-1$
+ if (start < 0 || start >= string.length())
+ throw new IllegalArgumentException("The start position must be at least 0 and less than the length of the string!"); //$NON-NLS-1$
+ 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] = processor;
+ boundaries[usedSegmentCount * 2] = (short) start;
+ boundaries[usedSegmentCount * 2 + 1] = (short) limit;
+ usedSegmentCount++;
}
/**
- * Check if a string is recorded and retrieve its triplets.
+ * Check if a string is recorded and retrieve its record.
*
- * @param string the string to check
+ * @param string the string to check.
*
* @return <code>null</code> if the string is not recorded in the pool;
- * otherwise, return the triplets associated with this string.
+ * otherwise, return the STextStringRecord instance which
+ * 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 starting offset can
+ * be retrieved using {@link #getStart getStart},
+ * its ending offset can
+ * be retrieved using {@link #getLimit getLimit},
*/
- public static short[] getTriplets(String string) {
- if (records[0] == null) // no records at all
+ public static STextStringRecord getRecord(String string) {
+ if (last < 0) // no records at all
return null;
if (string == null || string.length() < 1)
return null;
- STextStringRecord rec;
- String str;
- short[] tri;
+ STextStringRecord record;
int myLast = last;
int hash = string.hashCode();
for (int i = myLast; i >= 0; i--) {
- rec = records[i];
- if (hash == rec.hash && (tri = (short[]) rec.triRef.get()) != null && (str = (String) rec.strRef.get()) != null && string.equals(str)) {
- return tri;
- }
+ if (hash != hashArray[i])
+ continue;
+ record = (STextStringRecord) recordRefs[i].get();
+ if (record == null)
+ continue;
+ if (string.equals(record.string))
+ return record;
}
- if (records[MAXINDEX] == null) // never recorded past myLast
+ if (!wrapAround) // never recorded past myLast
return null;
for (int i = MAXINDEX; i > myLast; i--) {
- rec = records[i];
- if (hash == rec.hash && (tri = (short[]) rec.triRef.get()) != null && (str = (String) rec.strRef.get()) != null && string.equals(str)) {
- return tri;
- }
+ if (hash != hashArray[i])
+ continue;
+ record = (STextStringRecord) recordRefs[i].get();
+ if (record == null)
+ continue;
+ if (string.equals(record.string))
+ return record;
}
return null;
}
/**
+ * Retrieve the number of segments in a record.
+ *
+ * @return the number of segments in the current record. This number
+ * is always >= 1.
+ */
+ public int getSegmentCount() {
+ return usedSegmentCount;
+ }
+
+ private void checkSegmentNumber(int segmentNumber) {
+ if (segmentNumber >= usedSegmentCount)
+ throw new IllegalArgumentException("The segment number " + segmentNumber + " is greater than the total number of segments = " + usedSegmentCount + "!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ * Retrieve the processor 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
+ * segments specified by <code>segmentCount</code>
+ * in the call to {@link #addRecord addRecord} which created
+ * the STextStringRecord instance.
+ *
+ * @return the processor to handle the structured text in the segment
+ * specified by <code>segmentNumber</code>.
+ *
+ * @throws IllegalArgumentException if <code>segmentNumber</code>
+ * has an invalid value.
+ *
+ * @see #getSegmentCount getSegmentCount
+ */
+ public STextProcessor getProcessor(int segmentNumber) {
+ checkSegmentNumber(segmentNumber);
+ return processors[segmentNumber];
+ }
+
+ /**
+ * Retrieve the starting offset 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
+ * segments specified by <code>segmentCount</code>
+ * in the call to {@link #addRecord addRecord} which created
+ * the STextStringRecord instance.
+ *
+ * @return the starting offset within the string of the segment
+ * specified by <code>segmentNumber</code>.
+ *
+ * @throws IllegalArgumentException if <code>segmentNumber</code>
+ * has an invalid value.
+ *
+ * @see #getSegmentCount getSegmentCount
+ */
+ public int getStart(int segmentNumber) {
+ checkSegmentNumber(segmentNumber);
+ return boundaries[segmentNumber * 2];
+ }
+
+ /**
+ * Retrieve the ending offset 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
+ * segments specified by <code>segmentCount</code>
+ * in the call to {@link #addRecord addRecord} which created
+ * the STextStringRecord instance.
+ *
+ * @return the offset of the position following the segment
+ * specified by <code>segmentNumber</code>.
+ *
+ * @throws IllegalArgumentException if <code>segmentNumber</code>
+ * has an invalid value.
+ *
+ * @see #getSegmentCount getSegmentCount
+ */
+ public int getLimit(int segmentNumber) {
+ checkSegmentNumber(segmentNumber);
+ return boundaries[segmentNumber * 2 + 1];
+ }
+
+ /**
* Clear the pool. All elements of the pool are erased and any associated
* memory is freed.
*
*/
public static synchronized void clear() {
for (int i = 0; i <= MAXINDEX; i++) {
- STextStringRecord sr = records[i];
- if (sr == null)
- break;
- sr.hash = 0;
- sr.strRef.clear();
- sr.triRef.clear();
- records[i] = null;
+ hashArray[i] = 0;
+ SoftReference softRef = recordRefs[i];
+ if (softRef == null)
+ continue;
+ STextStringRecord record = (STextStringRecord) softRef.get();
+ if (record == null)
+ continue;
+ record.boundaries = null;
+ record.processors = null;
+ record.totalSegmentCount = 0;
+ record.usedSegmentCount = 0;
+ recordRefs[i].clear();
}
- last = MAXINDEX;
+ last = -1;
+ wrapAround = false;
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java
index 329d64d3a..f261833bb 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java
@@ -10,7 +10,6 @@
******************************************************************************/
package org.eclipse.equinox.bidi;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -22,7 +21,19 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
*
* @author Matitiahu Allouche
*/
-final public class STextUtil {
+public final class STextUtil {
+
+ static class MyProcessor extends STextProcessor {
+ String separ;
+
+ MyProcessor(String separators) {
+ separ = separators;
+ }
+
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return separ;
+ }
+ }
/**
* prevent instantiation
@@ -54,8 +65,8 @@ final public class STextUtil {
* This argument may be null if there are no marks to add.
*
* @param direction specifies the base direction of the structured text.
- * It must be one of the values {@link STextFeatures#DIR_LTR} or
- * {@link STextFeatures#DIR_RTL}.
+ * It must be one of the values {@link STextEngine#DIR_LTR} or
+ * {@link STextEngine#DIR_RTL}.
*
* @param affix specifies if a prefix and a suffix should be added to
* the result to make sure that the <code>direction</code>
@@ -75,7 +86,7 @@ final public class STextUtil {
String curPrefix, curSuffix, full;
char curMark, c;
char[] fullChars;
- if (direction == STextFeatures.DIR_LTR) {
+ if (direction == STextEngine.DIR_LTR) {
curMark = LRM;
curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$
curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$
@@ -212,8 +223,8 @@ final public class STextUtil {
// make sure that LRE/PDF are added around the string
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- STextFeatures features = new STextFeatures(separators, 0, -1, -1, false, false);
- return STextEngine.leanToFullText(new STextProcessor(), features, env, str, null);
+ STextProcessor processor = new MyProcessor(separators);
+ return STextEngine.leanToFullText(processor, env, str, null);
}
/**
@@ -237,16 +248,19 @@ final public class STextUtil {
*
* @param str the text to process.
*
- * @param type specifies the type of the structured text. It must
- * be one of the values in {@link ISTextTypes} or a value.
- * added by a plug-in extension.
+ * @param processor specifies a processor instance appropriate for
+ * the type of the structured text. It will usually be
+ * one of the pre-defined processor instances appearing in
+ * {@link STextEngine}, but can be an instance
+ * added by a plug-in extension or an instance of a
+ * processor defined in the application itself.
*
* @return the processed string.
* If <code>str</code> is <code>null</code>,
* or of length 0, or if the current locale is not a bidi one,
* return the original string.
*/
- public static String processTyped(String str, String type) {
+ public static String processTyped(String str, STextProcessor processor) {
if ((str == null) || (str.length() <= 1) || !isProcessingNeeded())
return str;
@@ -257,7 +271,7 @@ final public class STextUtil {
// make sure that LRE/PDF are added around the string
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- return STextEngine.leanToFullText(type, null, env, str, null);
+ return STextEngine.leanToFullText(processor, env, str, null);
}
/**
@@ -296,18 +310,18 @@ final public class STextUtil {
*
* @param str string with directional characters to remove.
*
- * @param type type of the structured text as specified when
+ * @param processor to handle the structured text as specified when
* calling {@link #processTyped processTyped}.
*
* @return string with no directional formatting characters.
*/
- public static String deprocess(String str, String type) {
+ public static String deprocess(String str, STextProcessor processor) {
if ((str == null) || (str.length() <= 1) || !isProcessingNeeded())
return str;
// make sure that LRE/PDF are added around the string
STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN);
- return STextEngine.fullToLeanText(type, null, env, str, null);
+ return STextEngine.fullToLeanText(processor, env, str, null);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/ISTextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/ISTextProcessor.java
deleted file mode 100644
index 8177c2b74..000000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/ISTextProcessor.java
+++ /dev/null
@@ -1,170 +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.custom;
-
-import org.eclipse.equinox.bidi.STextEngine;
-import org.eclipse.equinox.bidi.STextEnvironment;
-
-/**
- * Interface for all structured text processors.
- * For guidelines about implementation, see
- * {@link STextProcessor}.
- *
- * @author Matitiahu Allouche
- */
-public interface ISTextProcessor {
-
- /**
- * return the
- * {@link STextFeatures} characterizing the processor.
- *
- * @param env 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 features in use for this processor.
- */
- public abstract STextFeatures getFeatures(STextEnvironment env);
-
- /**
- * Locate occurrences of special strings within a structured text
- * and return their indexes one after the other in successive calls.
- * <p>
- * This method is called repeatedly from the code implementing
- * {@link STextEngine#leanToFullText leanToFullText} if the
- * number of special cases appearing in the associated <code>features</code>
- * parameter is greater than zero.
- * <p>
- * The code implementing this method may use the following methods
- * in {@link STextProcessor}:
- * <ul>
- * <li>{@link STextProcessor#getDirProp getDirProp}</li>
- * <li>{@link STextProcessor#setDirProp setDirProp}</li>
- * <li>{@link STextProcessor#insertMark insertMark}</li>
- * <li>{@link STextProcessor#processSeparator processSeparator}</li>
- * </ul>
- *
- * @param features is the {@link STextFeatures} instance
- * currently associated with this processor.
- *
- * @param text is the structured text string before
- * addition of any directional formatting characters.
- *
- * @param dirProps 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
- * in the features associated with 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 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.
- */
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex);
-
- /**
- * This method handles special cases specific to this processor.
- * It is called by {@link STextEngine#leanToFullText leanToFullText}
- * when a special case occurrence is located by
- * {@link #indexOfSpecial indexOfSpecial}.
- * <p>
- * The code implementing this method may use the following methods
- * in {@link STextProcessor}:
- * <ul>
- * <li>{@link STextProcessor#getDirProp getDirProp}</li>
- * <li>{@link STextProcessor#setDirProp setDirProp}</li>
- * <li>{@link STextProcessor#insertMark insertMark}</li>
- * <li>{@link STextProcessor#processSeparator processSeparator}</li>
- * </ul>
- * <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 to
- * {@link STextEngine#leanToFullText leanToFullText}
- * specifying that state value, <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.
- *
- * @param features is the {@link STextFeatures} instance
- * currently associated with this processor.
- *
- * @param text is the structured text string before
- * addition of any directional formatting characters.
- *
- * @param dirProps 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 value must be a number between 1 and the number of
- * special cases appearing in the features associated with
- * 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 STextEngine#leanToFullText leanToFullText} and other
- * methods of {@link STextEngine} 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.
- */
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation);
-
-}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextFeatures.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextFeatures.java
deleted file mode 100644
index 9d7c1a13e..000000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextFeatures.java
+++ /dev/null
@@ -1,250 +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.custom;
-
-import org.eclipse.equinox.bidi.STextEnvironment;
-
-/**
- * This class defines features of a structured text processor.
- * <p>
- * All public fields in this class are <code>final</code>, i.e. cannot be
- * changed after creating an instance.
- *
- * <h2>Code Sample</h2>
- * <p>Example 1 (set all features)
- * <pre>
- *
- * STextFeatures f1 = new STextFeatures("+-=", 0, -1, -1, false, false);
- *
- * </pre>
- * <p>Example 2 (change only the separators)
- * <pre>
- *
- * STextFeatures f2 = new STextFeatures("[]|()", f1.getSpecialsCount(),
- * f1.getDirArabic(), f1.getDirHebrew(),
- * f1.getIgnoreArabic(), f1.getIgnoreHebrew());
- *
- * </pre>
- *
- * @see ISTextProcessor#getFeatures
- *
- * @author Matitiahu Allouche
- */
-public class STextFeatures {
-
- /**
- * Constant specifying that the base direction of a structured text is LTR.
- * The base direction may depend on whether the GUI is
- * {@link STextEnvironment#getMirrored mirrored} and may
- * may be different for Arabic and for Hebrew.
- * This constant can appear as <code>dirArabic</code>
- * or <code>dirHebrew</code> argument for the
- * {@link STextFeatures#STextFeatures STextFeatures constructor}
- * and as value returned by {@link #getDirArabic} or {@link #getDirHebrew}
- * methods.
- */
- public static final int DIR_LTR = 0;
-
- /**
- * Constant specifying that the base direction of a structured text is RTL.
- * The base direction may depend on whether the GUI is
- * {@link STextEnvironment#getMirrored mirrored} and may
- * may be different for Arabic and for Hebrew.
- * This constant can appear as <code>dirArabic</code>
- * or <code>dirHebrew</code> argument for the
- * {@link STextFeatures#STextFeatures STextFeatures constructor}
- * and as value returned by {@link #getDirArabic} or {@link #getDirHebrew}
- * methods.
- */
- public static final int DIR_RTL = 1;
-
- /**
- * Pre-defined <code>STextFeatures</code> instance with values for no
- * separators, no special processing, all directions LTR
- * and support for neither Arabic nor Hebrew.<br>
- * Since there are no separators and no special processing, a structured text
- * processor with such features would do nothing.<br>
- * It is more efficient to do nothing with a <code>null</code> processor.
- */
- public static final STextFeatures DEFAULT = new STextFeatures(null, 0, -1, -1, true, true);
-
- /**
- * String grouping one-character separators which
- * separate the structured text into tokens.
- */
- final String separators;
-
- /**
- * 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 ISTextProcessor#indexOfSpecial indexOfSpecial} and
- * {@link ISTextProcessor#processSpecial processSpecial}.
- * Examples of special cases are comments, literals, or anything which
- * is not identified by a one-character separator.
- */
- final int specialsCount;
-
- /**
- * Base direction of the structured text for Arabic.
- * If a structured text contains both Arabic and
- * Hebrew words, the first Arabic or Hebrew letter in the
- * text determines which is the governing script).<br>
- * The value of this field must be one of
- * {@link #DIR_LTR} or {@link #DIR_RTL}.
- *
- * @see #dirHebrew
- */
- final int dirArabic;
-
- /**
- * Base direction of the structured text for Hebrew.
- * If a structured text contains both Arabic and
- * Hebrew words, the first Arabic or Hebrew letter in the
- * text determines which is the governing script).<br>
- * The value of this field must be one of
- * {@link #DIR_LTR} or {@link #DIR_RTL}.
- *
- * @see #dirArabic
- */
- final int dirHebrew;
-
- /**
- * Flag indicating that Arabic letters will not be considered for
- * processing structured text. If both this flag and
- * ignoreHebrew are set to <code>true</code>, the
- * processor will do nothing (but some overhead can be expected).
- */
- final boolean ignoreArabic;
-
- /**
- * Flag indicating that Hebrew letters will not be considered for
- * processing structured text. If both this flag and
- * ignoreArabic are set to <code>true</code>, the
- * processor will do nothing (but some overhead can be expected).
- */
- final boolean ignoreHebrew;
-
- /**
- * Constructor
- *
- * @param separators is a string where each character is a separator
- * which separates the structured text into tokens.
- * @see #getSeparators
- *
- * @param specialsCount specifies the number of special cases handled
- * by the processor. This value must be identical to the
- * number of special cases handled by the processor with which
- * this <code>STextFeatures</code> instance is associated.
- * @see #getSpecialsCount
- *
- * @param dirArabic specifies the base direction of the structured text
- * for Arabic. It must be {@link #DIR_LTR} or {@link #DIR_RTL}.
- * If it is not (for instance if it is a negative value), it
- * defaults to <code>DIR_LTR</code>.
- * @see #getDirArabic
- *
- * @param dirHebrew specifies the base direction of the structured text
- * for Hebrew. It must be {@link #DIR_LTR} or {@link #DIR_RTL}.
- * If it is not (for instance if it is a negative value), it
- * defaults to <code>DIR_LTR</code>.
- * @see #getDirHebrew
- *
- * @param ignoreArabic indicates that Arabic letters will not be
- * considered for processing structured text.
- * If both this flag and <code>ignoreHebrew</code>
- * are set to <code>true</code>, the processor will do
- * nothing (but some overhead can be expected).
- * @see #getIgnoreArabic
- *
- * @param ignoreHebrew indicates that Hebrew letters will not be
- * considered for processing structured text.
- * If both this flag and <code>ignoreArabic</code>
- * are set to <code>true</code>, the processor will do
- * nothing (but some overhead can be expected).
- * @see #getIgnoreHebrew
- */
- public STextFeatures(String separators, int specialsCount, int dirArabic, int dirHebrew, boolean ignoreArabic, boolean ignoreHebrew) {
-
- this.separators = separators == null ? "" : separators; //$NON-NLS-1$
- this.specialsCount = specialsCount;
- this.dirArabic = dirArabic == DIR_LTR || dirArabic == DIR_RTL ? dirArabic : DIR_LTR;
- this.dirHebrew = dirHebrew == DIR_LTR || dirHebrew == DIR_RTL ? dirHebrew : DIR_LTR;
- this.ignoreArabic = ignoreArabic;
- this.ignoreHebrew = ignoreHebrew;
- }
-
- /**
- * @return a string grouping one-character separators which separate
- * the structured text into tokens.
- */
- public String getSeparators() {
- return separators;
- }
-
- /**
- * @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 ISTextProcessor#indexOfSpecial indexOfSpecial} and
- * {@link ISTextProcessor#processSpecial processSpecial}.
- * Examples of special cases are comments, literals, or
- * anything which is not identified by a one-character separator.
- */
- public int getSpecialsCount() {
- return specialsCount;
- }
-
- /**
- * @return the base direction of the structured text for Arabic.
- * If a structured text contains both Arabic and
- * Hebrew words, the first Arabic or Hebrew letter in the
- * text determines which is the governing script.<br>
- * The value of this field is one of
- * {@link #DIR_LTR} or {@link #DIR_RTL}.
- *
- * @see #getDirHebrew
- */
- public int getDirArabic() {
- return dirArabic;
- }
-
- /**
- * @return the base direction of the structured text for Hebrew.
- * If a structured text contains both Arabic and
- * Hebrew words, the first Arabic or Hebrew letter in the
- * text determines which is the governing script.<br>
- * The value of this field is one of
- * {@link #DIR_LTR} or {@link #DIR_RTL}.
- *
- * @see #getDirArabic
- */
- public int getDirHebrew() {
- return dirHebrew;
- }
-
- /**
- * @return a flag indicating that Arabic letters will not be considered
- * for processing structured text.
- */
- public boolean getIgnoreArabic() {
- return ignoreArabic;
- }
-
- /**
- * Flag indicating that Hebrew letters will not be considered for
- * processing structured text.
- */
- public boolean getIgnoreHebrew() {
- return ignoreHebrew;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
index f552dbc22..8401d9c97 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
@@ -15,7 +15,7 @@ import org.eclipse.equinox.bidi.STextEnvironment;
import org.eclipse.equinox.bidi.internal.STextImpl;
/**
- * Generic processor which can be used as superclass (base class)
+ * 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
@@ -23,89 +23,220 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
* <ul>
* <li>Processor instances may be accessed simultaneously by
* several threads. They should have no instance variables.</li>
- * <li>Each use of a processor is associated with a set of
- * {@link STextFeatures features}.
- * All processors must have a default set of features which may be
- * queried with the {@link #getFeatures getFeatures} method.
- * These default features may be overridden by specifying a
- * <code>features</code> argument when calling a method.
- * See for instance
- * {@link STextEngine#leanToFullText leanToFullText}.
- * <li>The behavior of a processor is governed by 3 factors, all included
- * in associated {@link STextFeatures features} data.
+ * <li>All the user methods in {@link STextEngine} implement a logic
+ * common to all processors, located in {@link STextImpl}.
+ * These methods all have a first argument which is a processor
+ * instance.
+ * The common logic uses processor methods to query the
+ * characteristics of the specific processor:
* <ul>
- * <li>The separators specified in its
- * {@link STextFeatures features} determine how submitted
- * structured text is split into tokens.</li>
- * <li>The tokens are displayed one after the other according
- * to the appropriate direction, which can be different for
- * Arabic and for Hebrew.</li>
- * <li>The number of special cases which need to be handled by
- * code specific to that processor.</li>
+ * <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>
*
- * @see STextFeatures#getSeparators
- * @see STextFeatures#getDirArabic
- * @see STextFeatures#getDirHebrew
- * @see STextFeatures#getSpecialsCount
- *
* @author Matitiahu Allouche
*/
-public class STextProcessor implements ISTextProcessor {
+public abstract class STextProcessor {
/**
- * In <code>STextProcessor</code> this method returns a
- * {@link STextFeatures#DEFAULT DEFAULT} value which
- * directs the processor to do nothing.
+ * Locate occurrences of special strings within a structured text
+ * and return their indexes one after the other in successive calls.
+ * <p>
+ * This method is called repeatedly from the code implementing
+ * {@link STextEngine#leanToFullText leanToFullText} if the
+ * number of special cases returned by {@link #getSpecialsCount getSpecialsCount}
+ * is greater than zero.
+ * <p>
+ * The code implementing this method may use the following methods:
+ * <ul>
+ * <li>{@link #getDirProp getDirProp}</li>
+ * <li>{@link #setDirProp setDirProp}</li>
+ * <li>{@link #insertMark insertMark}</li>
+ * <li>{@link #processSeparator processSeparator}</li>
+ * <li>{@link #getDirection getDirection}</li>
+ * <li>{@link #getSeparators getSeparators}</li>
+ * <li>{@link #getSpecialsCount getSpecialsCount}</li>
+ * </ul>
*
- * <p>A processor which extends this class must override this method
- * and return a STextFeatures instance representing its specific
- * features.
+ * @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.
*
- * @see ISTextProcessor#getFeatures the corresponding interface method
- */
- public STextFeatures getFeatures(STextEnvironment environment) {
- throw new IllegalStateException("A processor must have a getFeatures() method."); //$NON-NLS-1$
- }
-
- /**
- * In <code>STextProcessor</code> this method throws an
+ * @param text is the structured text string before
+ * addition of any directional formatting characters.
+ *
+ * @param dirProps 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
+ *
+ * <p>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.
*
* <p>A processor handling special cases must override this method.
- *
- * @see ISTextProcessor#indexOfSpecial the corresponding interface method
*/
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
// This method must be overridden by all subclasses with special cases.
- throw new IllegalStateException("A processor must have an indexOfSpecial() method."); //$NON-NLS-1$
+ throw new IllegalStateException("A processor with specialsCount > 0 must have an indexOfSpecial() method."); //$NON-NLS-1$
}
/**
- * In <code>STextProcessor</code> this method throws an
+ * This method handles special cases specific to this processor.
+ * It is called by {@link STextEngine#leanToFullText leanToFullText}
+ * when a special case occurrence is located by
+ * {@link #indexOfSpecial indexOfSpecial}.
+ * <p>
+ * The code implementing this method may use the following methods:
+ * <ul>
+ * <li>{@link #getDirProp getDirProp}</li>
+ * <li>{@link #setDirProp setDirProp}</li>
+ * <li>{@link #insertMark insertMark}</li>
+ * <li>{@link #processSeparator processSeparator}</li>
+ * <li>{@link #getDirection getDirection}</li>
+ * <li>{@link #getSeparators getSeparators}</li>
+ * <li>{@link #getSpecialsCount getSpecialsCount}</li>
+ * </ul>
+ * <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 to
+ * {@link STextEngine#leanToFullText leanToFullText}
+ * specifying that state value, <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.
+ *
+ * @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 dirProps 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 STextEngine#leanToFullText leanToFullText} and other
+ * methods of {@link STextEngine} 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
+ *
+ * <p>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.
*
- * <p>A processor handling special cases must override this method.
- *
- * @see ISTextProcessor#processSpecial the corresponding interface method
+ * <p>A processor handling special cases (with a number of
+ * special cases greater than zero) must override this method.
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
// This method must be overridden by all subclasses with any special case.
- throw new IllegalStateException("A processor must have a processSpecial() method."); //$NON-NLS-1$
+ throw new IllegalStateException("A processor with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$
}
/**
* This method can be called from within
- * {@link ISTextProcessor#indexOfSpecial indexOfSpecial} or
- * {@link ISTextProcessor#processSpecial processSpecial} in
- * implementations of {@link ISTextProcessor} to retrieve the
+ * {@link #indexOfSpecial indexOfSpecial} or
+ * {@link #processSpecial processSpecial} in extensions of
+ * <code>STextProcessor</code> to retrieve the
* bidirectional class of characters in the <i>lean</i> text.
*
* @param text is the structured text string received as
@@ -130,15 +261,15 @@ public class STextProcessor implements ISTextProcessor {
* properties and so can be more efficient than calling the
* java.lang.Character method.
*/
- public static byte getDirProp(String text, byte[] dirProps, int index) {
+ public static final byte getDirProp(String text, byte[] dirProps, int index) {
return STextImpl.getDirProp(text, dirProps, index);
}
/**
* This method can be called from within
- * {@link ISTextProcessor#indexOfSpecial indexOfSpecial} or
- * {@link ISTextProcessor#processSpecial processSpecial} in
- * implementations of {@link ISTextProcessor} to set or
+ * {@link #indexOfSpecial indexOfSpecial} or
+ * {@link #processSpecial processSpecial} in extensions of
+ * <code>STextProcessor</code> to set or
* override the bidirectional class of characters in the <i>lean</i> text.
*
* @param dirProps is a parameter received by <code>indexOfSpecial</code>
@@ -150,19 +281,19 @@ public class STextProcessor implements ISTextProcessor {
* It must be a non-negative number smaller than the length
* of the <i>lean</i> text.
*
- * @param dirProp bidirectional class of the character. It is one of the
- * values which can be returned by
+ * @param dirProp bidirectional class of the character. It must be
+ * one of the values which can be returned by
* <code>java.lang.Character.getDirectionality</code>.
*/
- public static void setDirProp(byte[] dirProps, int index, byte dirProp) {
+ public static final void setDirProp(byte[] dirProps, int index, byte dirProp) {
STextImpl.setDirProp(dirProps, index, dirProp);
}
/**
* This method can be called from within
- * {@link ISTextProcessor#indexOfSpecial indexOfSpecial} or
- * {@link ISTextProcessor#processSpecial processSpecial} in
- * implementations of {@link ISTextProcessor}
+ * {@link #indexOfSpecial indexOfSpecial} or
+ * {@link #processSpecial 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
@@ -191,24 +322,25 @@ public class STextProcessor implements ISTextProcessor {
* For the benefit of efficiency, it is better to insert
* multiple marks in ascending order of the offsets.
*/
- public static void insertMark(String text, byte[] dirProps, int[] offsets, int offset) {
+ public static final void insertMark(String text, byte[] dirProps, int[] offsets, int offset) {
STextImpl.insertMark(text, dirProps, offsets, offset);
}
/**
* This method can be called from within
- * {@link ISTextProcessor#indexOfSpecial indexOfSpecial} or
- * {@link ISTextProcessor#processSpecial processSpecial} in
- * implementations of {@link ISTextProcessor} to add a
- * directional mark before a
+ * {@link #indexOfSpecial indexOfSpecial} or
+ * {@link #processSpecial 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.
*
- * @param features is the {@link STextFeatures} instance
- * received as parameter to <code>indexOfSpecial</code> or
- * <code>processSpecial</code>.
+ * <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.
*
* @param text is the structured text string received as
* parameter to <code>indexOfSpecial</code> or
@@ -228,8 +360,124 @@ public class STextProcessor implements ISTextProcessor {
* It must be a non-negative number smaller than the length
* of the <i>lean</i> text.
*/
- public static void processSeparator(STextFeatures features, String text, byte[] dirProps, int[] offsets, int separLocation) {
- STextImpl.processSeparator(features, text, dirProps, offsets, separLocation);
+ public static final void processSeparator(String text, byte[] dirProps, int[] offsets, int separLocation) {
+ STextImpl.processSeparator(text, dirProps, offsets, separLocation);
+ }
+
+ /**
+ * Indicate the separators to use for the current processor.
+ * This methode is invoked before starting the processing.
+ *
+ * @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 dirProps is a parameter received uniquely to be used as argument
+ * for calls to <code>getDirProp</code> and other methods used
+ * by processors.
+ *
+ * @return a string grouping one-character separators which separate
+ * the structured text into tokens.
+ *
+ * <p>If not overridden, this method returns an empty string;
+ */
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Indicate the base text direction appropriate for an instance
+ * of structured text.
+ * This methode is invoked before starting the processing.
+ *
+ * @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 dirProps is a parameter received uniquely to be used as argument
+ * for calls to <code>getDirProp</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 STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}.
+ *
+ * <p>If not overridden, this method returns <code>DIR_LTR</code>.
+ */
+ public int getDirection(STextEnvironment environment, String text, byte[] dirProps) {
+ return STextEngine.DIR_LTR;
+ }
+
+ /**
+ * Indicate the number of special cases handled by the current processor.
+ * This methode is invoked before starting the processing.
+ * If the number returned is zero,
+ * {@link #indexOfSpecial indexOfSpecial} and
+ * {@link #processSpecial processSpecial} will not be invoked.
+ *
+ * @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 dirProps is a parameter received uniquely to be used as argument
+ * for calls to <code>getDirProp</code> and other methods used
+ * by processors.
+ *
+ * @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 indexOfSpecial} and
+ * {@link STextProcessor#processSpecial processSpecial}.
+ * Examples of special cases are comments, literals, or
+ * anything which is not identified by a one-character separator.
+ *
+ * <p>If not overridden, this method returns <code>zero</code>.
+ */
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ return 0;
+ }
+
+ /**
+ * Check if there is a need for processing structured text.
+ * This methode 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.
+ *
+ * @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 dirProps is a parameter received uniquely to be used as argument
+ * for calls to <code>getDirProp</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.
+ *
+ * <p>If not overridden, this method returns <code>false</code>.
+ */
+ public boolean skipProcessing(STextEnvironment environment, String text, byte[] dirProps) {
+ return false;
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextStringProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextStringProcessor.java
index dc87dc7f7..04e9479be 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextStringProcessor.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextStringProcessor.java
@@ -34,7 +34,7 @@ public class STextStringProcessor {
* @return a reference to an instance of a processor of the
* required type. If the type is unknown, return <code>null</code>.
*/
- static public ISTextProcessor getProcessor(String type) {
+ static public STextProcessor getProcessor(String type) {
return STextTypesCollector.getInstance().getProcessor(type);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/package.html b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/package.html
index 9bbe97828..382a50212 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/package.html
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/package.html
@@ -5,18 +5,13 @@
</head>
<body bgcolor="white">
-This package provides an interface and classes for
+This package provides classes for
developing structured text processors.
<ul>
- <li>{@link <a href="ISTextProcessor.html">ISTextProcessor</a>}
- is an interface specifying which methods a processor must provide.</li>
<li>{@link <a href="STextProcessor.html">STextProcessor</a>}
- is a generic processor which can be used as superclass for specific
+ is a generic processor to be used as superclass for specific
processors.</li>
- <li>{@link <a href="STextFeatures.html">STextFeatures</a>}
- allows managing some factors which affect
- a structured text processor's behavior</li>
<li>{@link <a href="STextStringProcessor.html">STextStringProcessor</a>}
is a class which allows retrieval of the defined processor types and of the
corresponding processors.</li>
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 3d516b852..5bbe0156d 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
@@ -10,7 +10,7 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
+import org.eclipse.equinox.bidi.STextEnvironment;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -19,23 +19,40 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
* may include delimited parts within which separators are treated like
* regular characters.
*
+ * <p>A delimited part is bounded by a start delimiter and an end delimiter.
+ *
* @author Matitiahu Allouche
*/
public abstract class STextDelims extends STextProcessor {
/**
* This method locates occurrences of start delimiters.
+ *
+ * @return the position starting from offset <code>fromIndex</code>
+ * in <code>text</code> of the first occurrence of the
+ * start delimiter corresponding to <code>caseNumber</code>
+ * (first start delimiter if <code>caseNumber</code> equals 1,
+ * second delimiter if <code>caseNumber</code> equals 2, etc...).
+ *
+ * @see #getDelimiters
*/
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
char delim = getDelimiters().charAt((caseNumber - 1) * 2);
return text.indexOf(delim, fromIndex);
}
/**
- * This method skips until after the matching end delimiter.
+ * This method handles the text between start and end delimiters
+ * as a token.
+ * It inserts a directional mark if needed at position
+ * <code>separLocation</code> which corresponds to a start delimiter,
+ * and skips until after the matching end delimiter.
+ *
+ * @return the position after the matching end delimiter, or the length
+ * of <code>text</code> if no end delimiter is found.
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ STextProcessor.processSeparator(text, dirProps, 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 e3b10e4ac..67f944d04 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
@@ -10,7 +10,7 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
+import org.eclipse.equinox.bidi.STextEnvironment;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -32,11 +32,15 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
public abstract class STextDelimsEsc extends STextDelims {
/**
- * This method skips until after the matching end delimiter,
+ * This method handles the text between start and end delimiters
+ * as a token.
+ * It inserts a directional mark if needed at position
+ * <code>separLocation</code> which corresponds to a start delimiter,
+ * and skips until after the matching end delimiter,
* ignoring possibly escaped end delimiters.
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ STextProcessor.processSeparator(text, dirProps, 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/STextImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
index 70c13c2b4..d7ddb750d 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* <code>STextImpl</code> provides the code which implements the API in
@@ -54,16 +54,10 @@ public class STextImpl {
// nothing to do
}
- /*
- // keep private copy of specialsCount to avoid later modification
- specialsCount = features.getSpecialsCount();
- locations = new int[features.getSeparators().length() + specialsCount];
- }
- */
- static long computeNextLocation(ISTextProcessor processor, STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] locations, int[] state, int curPos) {
- String separators = features.getSeparators();
+ static long computeNextLocation(STextProcessor processor, STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] locations, int[] state, int curPos) {
+ String separators = processor.getSeparators(environment, text, dirProps);
int separCount = separators.length();
- int specialsCount = features.getSpecialsCount();
+ int specialsCount = processor.getSpecialsCount(environment, text, dirProps);
int len = text.length();
int nextLocation = len;
int idxLocation = 0;
@@ -73,7 +67,7 @@ public class STextImpl {
int location = locations[separCount + i];
if (location < curPos) {
offsets = ensureRoomInOffsets(offsets);
- location = processor.indexOfSpecial(features, text, dirProps, offsets, i + 1, curPos);
+ location = processor.indexOfSpecial(environment, text, dirProps, offsets, i + 1, curPos);
if (location < 0)
location = len;
locations[separCount + i] = location;
@@ -137,57 +131,15 @@ public class STextImpl {
/**
* @see STextEngine#getCurDirection STextEngine.getCurDirection
*/
- public static int getCurDirection(Object _processor, STextFeatures features, STextEnvironment environment, String text, byte[] dirProps) {
- if (environment == null)
- environment = STextEnvironment.DEFAULT;
- if (features == null) {
- if (_processor == null)
- return STextFeatures.DIR_LTR;
- ISTextProcessor processor;
- if (_processor instanceof java.lang.String) {
- processor = STextStringProcessor.getProcessor((String) _processor);
- if (processor == null)
- throw new IllegalArgumentException("Invalid processor type!"); //$NON-NLS-1$
- } else if (_processor instanceof ISTextProcessor)
- processor = (ISTextProcessor) _processor;
- else
- throw new IllegalArgumentException("Invalid processor argument!"); //$NON-NLS-1$
- features = processor.getFeatures(environment);
- }
- int dirArabic = features.getDirArabic();
- int dirHebrew = features.getDirHebrew();
- // same direction for Arabic and Hebrew?
- if (dirArabic == dirHebrew)
- return dirArabic;
- // check if Arabic or Hebrew letter comes first
- int len = text.length();
- if (dirProps == null)
- dirProps = new byte[len + 1];
- byte dirProp;
- for (int i = 0; i < len; i++) {
- // In the following lines, R and AL represent bidi categories
- // as defined in the Unicode Bidirectional Algorithm
- // ( http://www.unicode.org/reports/tr9/ ).
- // R represents the category Right to Left character.
- // AL represents the category Arabic Letter.
- byte saveOrient = dirProps[len];
- dirProps[len] = -1; // make getDirProp return B
- dirProp = getDirProp(text, dirProps, i);
- dirProps[len] = saveOrient;
- if (dirProp == AL)
- return dirArabic;
- if (dirProp == R)
- return dirHebrew;
- }
- // found no Arabic or Hebrew character
- return STextFeatures.DIR_LTR;
+ public static int getCurDirection(STextProcessor processor, STextEnvironment environment, String text, byte[] dirProps) {
+ return processor.getDirection(environment, text, dirProps);
}
/**
* @see STextProcessor#getDirProp STextProcessor.getDirProp
*/
public static byte getDirProp(String text, byte[] dirProps, int index) {
- byte dirProp = dirProps[index];
+ byte dirProp = dirProps == null ? 0 : dirProps[index];
if (dirProp == 0) {
// In the following lines, B, L and R represent bidi categories
// as defined in the Unicode Bidirectional Algorithm
@@ -196,14 +148,15 @@ public class STextImpl {
// L represents the category Left to Right character.
// R represents the category Right to Left character.
dirProp = Character.getDirectionality(text.charAt(index));
- if (dirProp == B) {
+ if (dirProp == B && dirProps != null) {
// the last entry of dirProps contains the current component orientation
byte orient = dirProps[dirProps.length - 1];
if (orient == -1)
return B;
dirProp = orient == STextEnvironment.ORIENT_RTL ? R : L;
}
- dirProps[index] = (byte) (dirProp + DIRPROPS_ADD);
+ if (dirProps != null)
+ dirProps[index] = (byte) (dirProp + DIRPROPS_ADD);
return dirProp;
}
return (byte) (dirProp - DIRPROPS_ADD);
@@ -219,7 +172,7 @@ public class STextImpl {
/**
* @see STextProcessor#processSeparator STextProcessor.processSeparator
*/
- public static void processSeparator(STextFeatures features, String text, byte[] dirProps, int[] offsets, int separLocation) {
+ public static void processSeparator(String text, byte[] dirProps, int[] offsets, int separLocation) {
// In this method, L, R, AL, AN and EN represent bidi categories
// as defined in the Unicode Bidirectional Algorithm
// ( http://www.unicode.org/reports/tr9/ ).
@@ -230,7 +183,7 @@ public class STextImpl {
// EN represents the category European Number.
int len = text.length();
// offsets[2] contains the structured text direction
- if (offsets[2] == STextFeatures.DIR_RTL) {
+ if (offsets[2] == STextEngine.DIR_RTL) {
// the structured text base direction is RTL
for (int i = separLocation - 1; i >= 0; i--) {
byte dirProp = getDirProp(text, dirProps, i);
@@ -254,44 +207,28 @@ public class STextImpl {
// the structured text base direction is LTR
boolean doneAN = false;
- boolean ignoreArabic = features.getIgnoreArabic();
- boolean ignoreHebrew = features.getIgnoreHebrew();
- if (ignoreArabic && ignoreHebrew)
- return;
- byte _R, _AL, _AN;
- if (ignoreArabic) {
- _AL = Byte.MIN_VALUE; // not a real value
- _AN = Byte.MIN_VALUE;
- } else {
- _AL = AL;
- _AN = AN;
- }
- if (ignoreHebrew)
- _R = Byte.MIN_VALUE;
- else
- _R = R;
for (int i = separLocation - 1; i >= 0; i--) {
byte dirProp = getDirProp(text, dirProps, i);
if (dirProp == L)
return;
- if (dirProp == _R || dirProp == _AL) {
+ if (dirProp == R || dirProp == AL) {
for (int j = separLocation; j < len; j++) {
dirProp = getDirProp(text, dirProps, j);
if (dirProp == L)
return;
- if (dirProp == _R || dirProp == EN || dirProp == _AL || dirProp == _AN) {
+ if (dirProp == R || dirProp == EN || dirProp == AL || dirProp == AN) {
insertMark(text, dirProps, offsets, separLocation);
return;
}
}
return;
}
- if (dirProp == _AN && !doneAN) {
+ if (dirProp == AN && !doneAN) {
for (int j = separLocation; j < len; j++) {
dirProp = getDirProp(text, dirProps, j);
if (dirProp == L)
return;
- if (dirProp == _AL || dirProp == _AN || dirProp == _R) {
+ if (dirProp == AL || dirProp == AN || dirProp == R) {
insertMark(text, dirProps, offsets, separLocation);
return;
}
@@ -304,12 +241,12 @@ public class STextImpl {
/**
* @see STextEngine#leanToFullText STextEngine.leanToFullText
*/
- public static String leanToFullText(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
return text;
byte[] dirProps = new byte[len + 1];
- int[] offsets = leanToFullCommon(processor, features, environment, text, state, dirProps);
+ int[] offsets = leanToFullCommon(processor, environment, text, state, dirProps);
int prefixLength = offsets[1];
int count = offsets[0] - OFFSETS_SHIFT;
if (count == 0 && prefixLength == 0)
@@ -355,12 +292,12 @@ public class STextImpl {
/**
* @see STextEngine#leanToFullMap STextEngine.leanToFullMap
*/
- public static int[] leanToFullMap(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
byte[] dirProps = new byte[len + 1];
- int[] offsets = leanToFullCommon(processor, features, environment, text, state, dirProps);
+ int[] offsets = leanToFullCommon(processor, environment, text, state, dirProps);
int prefixLength = offsets[1];
int[] map = new int[len];
int count = offsets[0]; // number of used entries
@@ -378,12 +315,12 @@ public class STextImpl {
/**
* @see STextEngine#leanBidiCharOffsets STextEngine.leanBidiCharOffsets
*/
- public static int[] leanBidiCharOffsets(Object processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
byte[] dirProps = new byte[len + 1];
- int[] offsets = leanToFullCommon(processor, features, environment, text, state, dirProps);
+ int[] offsets = leanToFullCommon(processor, environment, text, state, dirProps);
// offsets[0] contains the number of used entries
int count = offsets[0] - OFFSETS_SHIFT;
int[] result = new int[count];
@@ -391,20 +328,9 @@ public class STextImpl {
return result;
}
- static int[] leanToFullCommon(Object _processor, STextFeatures features, STextEnvironment environment, String text, int[] state, byte[] dirProps) {
- ISTextProcessor processor;
- if (_processor instanceof java.lang.String) {
- processor = STextStringProcessor.getProcessor((String) _processor);
- if (processor == null)
- throw new IllegalArgumentException("Invalid processor type!"); //$NON-NLS-1$
- } else if (_processor instanceof ISTextProcessor)
- processor = (ISTextProcessor) _processor;
- else
- throw new IllegalArgumentException("Invalid processor argument!"); //$NON-NLS-1$
+ static int[] leanToFullCommon(STextProcessor processor, STextEnvironment environment, String text, int[] state, byte[] dirProps) {
if (environment == null)
environment = STextEnvironment.DEFAULT;
- if (features == null)
- features = processor.getFeatures(environment);
if (state == null) {
state = new int[1];
state[0] = STextEngine.STATE_INITIAL;
@@ -413,47 +339,51 @@ public class STextImpl {
// dirProps: 1 byte for each char in text, + 1 byte = current orientation
int orient = getCurOrient(environment, text, dirProps);
dirProps[len] = (byte) orient;
- int separCount = features.getSeparators().length();
- int direction = getCurDirection(processor, features, environment, text, dirProps);
- // current position
- int curPos = 0;
+ int direction = processor.getDirection(environment, text, dirProps);
// offsets of marks to add. Entry 0 is the number of used slots;
// entry 1 is reserved to pass prefixLength.
// entry 2 is reserved to pass direction..
int[] offsets = new int[20];
offsets[0] = OFFSETS_SHIFT;
offsets[2] = direction;
- // initialize locations
- int[] locations = new int[separCount + features.getSpecialsCount()];
- for (int i = 0, k = locations.length; i < k; i++) {
- locations[i] = -1;
- }
- if (state[0] > STextEngine.STATE_INITIAL) {
- offsets = ensureRoomInOffsets(offsets);
- int initState = state[0];
- state[0] = STextEngine.STATE_INITIAL;
- curPos = processor.processSpecial(features, text, dirProps, 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, features, text, dirProps, offsets, locations, state, curPos);
- nextLocation = (int) (res & 0x00000000FFFFFFFF); /* low word */
- if (nextLocation >= len)
- break;
- idxLocation = (int) (res >> 32); /* high word */
- if (idxLocation < separCount) {
- offsets = ensureRoomInOffsets(offsets);
- processSeparator(features, text, dirProps, offsets, nextLocation);
- curPos = nextLocation + 1;
- } else {
+ if (!processor.skipProcessing(environment, text, dirProps)) {
+ // initialize locations
+ int separCount = processor.getSeparators(environment, text, dirProps).length();
+ int[] locations = new int[separCount + processor.getSpecialsCount(environment, text, dirProps)];
+ for (int i = 0, k = locations.length; i < k; i++) {
+ locations[i] = -1;
+ }
+ // current position
+ int curPos = 0;
+ if (state[0] > STextEngine.STATE_INITIAL) {
offsets = ensureRoomInOffsets(offsets);
- idxLocation -= (separCount - 1); // because caseNumber starts from 1
- curPos = processor.processSpecial(features, text, dirProps, offsets, state, idxLocation, nextLocation);
+ int initState = state[0];
+ state[0] = STextEngine.STATE_INITIAL;
+ curPos = processor.processSpecial(environment, text, dirProps, 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, dirProps, offsets, locations, state, curPos);
+ nextLocation = (int) (res & 0x00000000FFFFFFFF); /* low word */
+ if (nextLocation >= len)
+ break;
+ idxLocation = (int) (res >> 32); /* high word */
+ if (idxLocation < separCount) {
+ offsets = ensureRoomInOffsets(offsets);
+ processSeparator(text, dirProps, offsets, nextLocation);
+ curPos = nextLocation + 1;
+ } else {
+ offsets = ensureRoomInOffsets(offsets);
+ idxLocation -= (separCount - 1); // because caseNumber starts from 1
+ curPos = processor.processSpecial(environment, text, dirProps, offsets, state, idxLocation, nextLocation);
+ }
+ if (curPos >= len)
+ break;
+ } // end while
+ } // end if (!processor.skipProcessing())
if (orient == STextEnvironment.ORIENT_IGNORE)
offsets[1] = 0;
else {
@@ -473,27 +403,16 @@ public class STextImpl {
/**
* @see STextEngine#fullToLeanText STextEngine.fullToLeanText
*/
- public static String fullToLeanText(Object _processor, STextFeatures features, STextEnvironment environment, String text, int[] state) {
+ public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) {
if (text.length() == 0)
return text;
- ISTextProcessor processor;
- if (_processor instanceof java.lang.String) {
- processor = STextStringProcessor.getProcessor((String) _processor);
- if (processor == null)
- throw new IllegalArgumentException("Invalid processor type!"); //$NON-NLS-1$
- } else if (_processor instanceof ISTextProcessor)
- processor = (ISTextProcessor) _processor;
- else
- throw new IllegalArgumentException("Invalid processor argument!"); //$NON-NLS-1$
if (environment == null)
environment = STextEnvironment.DEFAULT;
- if (features == null)
- features = processor.getFeatures(environment);
if (state == null) {
state = new int[1];
state[0] = STextEngine.STATE_INITIAL;
}
- int dir = getCurDirection(processor, features, environment, text, null);
+ int dir = processor.getDirection(environment, text, null);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
int i; // used as loop index
@@ -531,7 +450,7 @@ public class STextImpl {
chars[i - cnt] = c;
}
String lean = new String(chars, 0, lenText - cnt);
- String full = leanToFullText(processor, features, IGNORE_ENVIRONMENT, lean, state);
+ String full = leanToFullText(processor, IGNORE_ENVIRONMENT, lean, state);
if (full.equals(text))
return lean;
@@ -569,7 +488,7 @@ public class STextImpl {
throw new IllegalStateException("Internal error: extra character not a Mark."); //$NON-NLS-1$
}
if (idxText < lenText) /* full ended before text - this should never happen since
- we removed all marks and PDFs at the end of text */
+ we removed all marks and PDFs at the end of text */
throw new IllegalStateException("Internal error: unexpected EOL."); //$NON-NLS-1$
lean = new String(newChars, 0, newCharsPos);
@@ -579,13 +498,13 @@ public class STextImpl {
/**
* @see STextEngine#fullToLeanMap STextEngine.fullToLeanMap
*/
- public static int[] fullToLeanMap(Object processor, STextFeatures features, STextEnvironment environment, String full, int[] state) {
+ public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String full, int[] state) {
int lenFull = full.length();
if (lenFull == 0)
return EMPTY_INT_ARRAY;
- String lean = fullToLeanText(processor, features, environment, full, state);
+ String lean = fullToLeanText(processor, environment, full, state);
int lenLean = lean.length();
- int dir = getCurDirection(processor, features, environment, lean, null);
+ int dir = processor.getDirection(environment, lean, null);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
int[] map = new int[lenFull];
@@ -613,11 +532,11 @@ public class STextImpl {
/**
* @see STextEngine#fullBidiCharOffsets STextEngine.fullBidiCharOffsets
*/
- public static int[] fullBidiCharOffsets(Object processor, STextFeatures features, STextEnvironment environment, String full, int[] state) {
+ public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String full, int[] state) {
int lenFull = full.length();
if (lenFull == 0)
return EMPTY_INT_ARRAY;
- String lean = fullToLeanText(processor, features, environment, full, state);
+ String lean = fullToLeanText(processor, environment, full, state);
int[] offsets = new int[20];
offsets[0] = OFFSETS_SHIFT;
int lenLean = lean.length();
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 7dfcd2bfa..ec8ec0ab0 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
@@ -10,7 +10,7 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
+import org.eclipse.equinox.bidi.STextEnvironment;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -24,9 +24,8 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
* <pre>
* part1=part2
* </pre>
- * The {@link STextFeatures#getSeparators separators}
- * field in the {@link STextFeatures features}
- * of this processor should contain exactly one character.
+ * The string returned by {@link STextProcessor#getSeparators getSeparators}
+ * for this processor should contain exactly one character.
* Additional characters will be ignored.
*
* @author Matitiahu Allouche
@@ -35,18 +34,31 @@ public abstract class STextSingle extends STextProcessor {
/**
* This method locates occurrences of the separator.
+ *
+ * @see #getSeparators getSeparators
*/
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
- return text.indexOf(features.getSeparators().charAt(0), fromIndex);
+ public int indexOfSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ return text.indexOf(this.getSeparators(environment, text, dirProps).charAt(0), fromIndex);
}
/**
* This method inserts a mark before the separator if needed and
* skips to the end of the source string.
+ *
+ * @return the length of <code>text</code>.
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
return text.length();
}
+ /**
+ * This method returns 1 as number of special cases handled by this processor.
+ *
+ * @return 1.
+ */
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ 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 0d06e3c31..bbcf564e0 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.ISTextProcessor;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
public class STextTypesCollector implements IRegistryEventListener {
@@ -46,12 +46,12 @@ public class STextTypesCollector implements IRegistryEventListener {
return result;
}
- public ISTextProcessor getProcessor(String type) {
+ public STextProcessor getProcessor(String type) {
if (types == null)
read();
Object processor = types.get(type);
- if (processor instanceof ISTextProcessor)
- return (ISTextProcessor) processor;
+ if (processor instanceof STextProcessor)
+ return (STextProcessor) processor;
return null;
}
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 a3493d0e8..dc29ad2b5 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
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -21,16 +20,12 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
* </pre>
*/
public class STextComma extends STextProcessor {
- static final STextFeatures FEATURES = new STextFeatures(",", 0, -1, -1, false, false); //$NON-NLS-1$
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with one separator (comma), no special cases,
- * LTR direction for Arabic and Hebrew, and support for both.
+ * @return one separator (comma).
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return ","; //$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 88ccdc0dc..05bfaba2b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
@@ -10,32 +10,58 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
+import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
import org.eclipse.equinox.bidi.internal.STextDelimsEsc;
/**
* Processor adapted to processing e-mail addresses.
*/
public class STextEmail extends STextDelimsEsc {
- static final int LTR = STextFeatures.DIR_LTR;
- static final int RTL = STextFeatures.DIR_RTL;
- static final STextFeatures MIRRORED = new STextFeatures("<>.:,;@", 2, RTL, LTR, false, false); //$NON-NLS-1$
- static final STextFeatures NOT_MIRRORED = new STextFeatures("<>.:,;@", 2, LTR, LTR, false, false); //$NON-NLS-1$
+ 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;
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators "<>.:,;@", 2 special cases,
- * LTR direction for Arabic when the GUI is not mirrored,
- * RTL direction for Arabic when the GUI is mirrored,
- * LTR direction for Hebrew in all cases,
- * and support for both Arabic and Hebrew.
+ * @return separators "<>.:,;@".
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- if (env == null)
- env = STextEnvironment.DEFAULT;
- return env.getMirrored() ? MIRRORED : NOT_MIRRORED;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "<>.:,;@"; //$NON-NLS-1$
+ }
+
+ /**
+ * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
+ * conditions are satisfied:
+ * <ul>
+ * <li>The current locale (as expressed by the environment
+ * language) is Arabic.</li>
+ * <li>The domain part of the email address contains
+ * at least one RTL character.</li>
+ * </ul>
+ * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
+ */
+ public int getDirection(STextEnvironment environment, String text, byte[] dirProps) {
+ String language = environment.getLanguage();
+ if (!language.equals("ar")) //$NON-NLS-1$
+ return STextEngine.DIR_LTR;
+ int domainStart;
+ domainStart = text.indexOf('@');
+ if (domainStart < 0)
+ domainStart = 0;
+ for (int i = domainStart; i < text.length(); i++) {
+ byte dirProp = STextProcessor.getDirProp(text, dirProps, i);
+ if (dirProp == AL || dirProp == R)
+ return STextEngine.DIR_RTL;
+ }
+ return STextEngine.DIR_LTR;
+ }
+
+ /**
+ * @return 2 as number of special cases handled by this processor.
+ */
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ 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 64dfe2801..cc7b2fda4 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
@@ -11,23 +11,17 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Processor adapted to processing directory and file paths.
*/
public class STextFile extends STextProcessor {
- static final STextFeatures FEATURES = new STextFeatures(":/\\.", 0, -1, -1, false, false); //$NON-NLS-1$
-
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators ":/\.", no special cases,
- * LTR direction for Arabic and Hebrew, and support for both.
+ * @return separators ":/\.".
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return ":/\\."; //$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 b079748ca..4b717c1d6 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
@@ -12,7 +12,6 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -36,18 +35,20 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
*/
public class STextJava extends STextProcessor {
private static final byte WS = Character.DIRECTIONALITY_WHITESPACE;
- static final STextFeatures FEATURES = new STextFeatures("[](){}.+-<>=~!&*/%^|?:,;\t", 4, -1, -1, false, false); //$NON-NLS-1$
static final String lineSep = STextEnvironment.getLineSep();
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators "[](){}.+-<>=~!&/*%^|?:,;\t",
- * 4 special cases, LTR direction for Arabic and Hebrew,
- * and support for both.
+ * @return the separators for Java syntax
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "[](){}.+-<>=~!&*/%^|?:,;\t"; //$NON-NLS-1$
+ }
+
+ /**
+ * @return 4 as the number of special cases handled by this processor.
+ */
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ return 4;
}
/**
@@ -59,7 +60,7 @@ public class STextJava extends STextProcessor {
* <li>comments starting with slash-slash</li>
* </ol>
*/
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
switch (caseNumber) {
case 1 : /* space */
return text.indexOf(' ', fromIndex);
@@ -83,10 +84,10 @@ public class STextJava extends STextProcessor {
* <li>skip until after a line separator</li>
* </ol>
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
int location, counter, i;
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
switch (caseNumber) {
case 1 : /* space */
separLocation++;
@@ -120,7 +121,7 @@ public class STextJava extends STextProcessor {
}
// we need to call processSeparator since text may follow the
// end of comment immediately without even a space
- STextProcessor.processSeparator(features, text, dirProps, offsets, location);
+ STextProcessor.processSeparator(text, dirProps, 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 2a2be972f..8bafbb118 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
@@ -10,26 +10,56 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
+import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
- * Processor adapted to processing arithmetic expressions with right-to-left
- * base direction.
+ * Processor adapted to processing arithmetic expressions with
+ * a possible right-to-left base direction.
*/
public class STextMath extends STextProcessor {
- static final int RTL = STextFeatures.DIR_RTL;
- static final STextFeatures FEATURES = new STextFeatures("+-/*()=", 0, RTL, RTL, false, false); //$NON-NLS-1$
+ 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;
+ static final byte AN = Character.DIRECTIONALITY_ARABIC_NUMBER;
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators "+-/*()=", no special cases,
- * RTL direction for Arabic and Hebrew, and support for both.
+ * @return "+-/*()=" as separators specific to this processor.
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "+-/*()="; //$NON-NLS-1$
+ }
+
+ /**
+ * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
+ * conditions are satisfied:
+ * <ul>
+ * <li>The current locale (as expressed by the environment
+ * language) is Arabic.</li>
+ * <li>The first strong character is an Arabic letter.</li>
+ * <li>If there is no strong character in the text, there is
+ * at least one Arabic-Indic digit in the text.</li>
+ * </ul>
+ * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
+ */
+ public int getDirection(STextEnvironment environment, String text, byte[] dirProps) {
+ String language = environment.getLanguage();
+ if (!language.equals("ar")) //$NON-NLS-1$
+ return STextEngine.DIR_LTR;
+ boolean flagAN = false;
+ for (int i = 0; i < text.length(); i++) {
+ byte dirProp = getDirProp(text, dirProps, i);
+ if (dirProp == AL)
+ return STextEngine.DIR_RTL;
+ if (dirProp == L || dirProp == R)
+ return STextEngine.DIR_LTR;
+ if (dirProp == AN)
+ flagAN = true;
+ }
+ if (flagAN)
+ return STextEngine.DIR_RTL;
+ return STextEngine.DIR_LTR;
}
}
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 78d41c195..1cd1b0e39 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
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.internal.STextSingle;
/**
@@ -22,16 +21,11 @@ import org.eclipse.equinox.bidi.internal.STextSingle;
* </pre>
*/
public class STextProperty extends STextSingle {
- static final STextFeatures FEATURES = new STextFeatures("=", 1, -1, -1, false, false); //$NON-NLS-1$
-
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with one separator (equal sign), 1 special case,
- * LTR direction for Arabic and Hebrew, and support for both.
+ * @return one separator (equal sign).
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "="; //$NON-NLS-1$
}
}
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 93c663d02..2dfdf6662 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.*;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* <code>STextRegex</code> is a processor for regular expressions.
@@ -57,7 +57,6 @@ public class STextRegex extends STextProcessor {
'.', ')', '>', '\'', ')', ')', ')', ')', '>', '>', '\'', '}', ')', '}', '>', '\'', ')'};
static final int numberOfStrings = startStrings.length; /* 18 */
static final int maxSpecial = numberOfStrings;
- static final STextFeatures FEATURES = new STextFeatures(null, maxSpecial, -1, -1, false, false);
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;
@@ -65,23 +64,19 @@ public class STextRegex extends STextProcessor {
static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
/**
- * This method retrieves the features specific to this processor.
- *
- * @see ISTextProcessor#getFeatures
- *
- * @return features with no separators , special cases for each kind of
- * regular expression syntactic string,
- * LTR direction for Arabic and Hebrew, and support for both.
+ * This method retrieves the number of special cases handled by this processor.
+ *
+ * @return the number of special cases for this processor.
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ return maxSpecial;
}
/**
* This method locates occurrences of the syntactic strings and of
* R, AL, EN, AN characters.
*/
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
// In this method, L, R, AL, AN and EN represent bidi categories
// as defined in the Unicode Bidirectional Algorithm
// ( http://www.unicode.org/reports/tr9/ ).
@@ -149,7 +144,7 @@ public class STextRegex extends STextProcessor {
/**
* This method process the special cases.
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
int location;
switch (caseNumber) {
@@ -158,7 +153,7 @@ public class STextRegex extends STextProcessor {
// initial state from previous line
location = 0;
} else {
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
// skip the opening "(?#"
location = separLocation + 3;
}
@@ -174,7 +169,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(features, text, dirProps, offsets, separLocation);
+ STextProcessor.processSeparator(text, dirProps, 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> */
@@ -198,7 +193,7 @@ public class STextRegex extends STextProcessor {
// initial state from previous line
location = 0;
} else {
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
// skip the opening "\Q"
location = separLocation + 2;
}
@@ -211,11 +206,40 @@ public class STextRegex extends STextProcessor {
STextProcessor.setDirProp(dirProps, location + 1, L);
return location + 2;
case 18 : /* R, AL, AN, EN */
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
return separLocation + 1;
}
// we should never get here
return text.length();
}
+
+ /**
+ * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
+ * conditions are satisfied:
+ * <ul>
+ * <li>The current locale (as expressed by the environment
+ * language) is Arabic.</li>
+ * <li>The first strong character has an RTL direction.</li>
+ * <li>If there is no strong character in the text, the
+ * GUI is mirrored.
+ * </ul>
+ * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
+ */
+ public int getDirection(STextEnvironment environment, String text, byte[] dirProps) {
+ String language = environment.getLanguage();
+ if (!language.equals("ar")) //$NON-NLS-1$
+ return STextEngine.DIR_LTR;
+ for (int i = 0; i < text.length(); i++) {
+ byte dirProp = getDirProp(text, dirProps, i);
+ if (dirProp == AL || dirProp == R)
+ return STextEngine.DIR_RTL;
+ if (dirProp == L)
+ return STextEngine.DIR_LTR;
+ }
+ if (environment.getMirrored())
+ return STextEngine.DIR_RTL;
+ return STextEngine.DIR_LTR;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
index baa6aafdf..9c0965cb3 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
@@ -12,7 +12,6 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -36,18 +35,20 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
*/
public class STextSql extends STextProcessor {
private static final byte WS = Character.DIRECTIONALITY_WHITESPACE;
- static final String separators = "\t!#%&()*+,-./:;<=>?|[]{}"; //$NON-NLS-1$
- static final STextFeatures FEATURES = new STextFeatures(separators, 5, -1, -1, false, false);
static final String lineSep = STextEnvironment.getLineSep();
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators "\t!#%&()*+,-./:;<=>?|[]{}", 5 special cases,
- * LTR direction for Arabic and Hebrew, and support for both.
+ * @return separators "\t!#%&()*+,-./:;<=>?|[]{}".
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "\t!#%&()*+,-./:;<=>?|[]{}"; //$NON-NLS-1$
+ }
+
+ /**
+ * @return 5 as the number of special cases handled by this processor.
+ */
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ return 5;
}
/**
@@ -60,7 +61,7 @@ public class STextSql extends STextProcessor {
* <li>comments starting with hyphen-hyphen</li>
* </ol>
*/
- public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) {
switch (caseNumber) {
case 1 : /* space */
return text.indexOf(" ", fromIndex); //$NON-NLS-1$
@@ -87,10 +88,10 @@ public class STextSql extends STextProcessor {
* <li>skip until after a line separator</li>
* </ol>
*/
- public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
int location;
- STextProcessor.processSeparator(features, text, dirProps, offsets, separLocation);
+ STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
switch (caseNumber) {
case 1 : /* space */
separLocation++;
@@ -138,7 +139,7 @@ public class STextSql extends STextProcessor {
}
// we need to call processSeparator since text may follow the
// end of comment immediately without even a space
- STextProcessor.processSeparator(features, text, dirProps, offsets, location);
+ STextProcessor.processSeparator(text, dirProps, 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 5e270389e..d31d4da58 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
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.internal.STextSingle;
/**
@@ -21,16 +20,11 @@ import org.eclipse.equinox.bidi.internal.STextSingle;
* </pre>
*/
public class STextSystem extends STextSingle {
- static final STextFeatures FEATURES = new STextFeatures("(", 0, -1, -1, false, false); //$NON-NLS-1$
-
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with one separator (opening parenthesis),
- * no special cases, LTR direction for Arabic and Hebrew,
- * and support for both.
+ * @return "(" for the separators specific to this processor.
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "("; //$NON-NLS-1$
}
+
}
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 ad2acff34..956f9b274 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
@@ -11,24 +11,17 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
* Processor adapted to processing URLs.
*/
public class STextURL extends STextProcessor {
- static final STextFeatures FEATURES = new STextFeatures(":?#/@.[]", 0, -1, -1, false, false); //$NON-NLS-1$
-
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators ":?#/@.[]",
- * no special cases, LTR direction for Arabic and Hebrew,
- * and support for both.
+ * @return ":?#/@.[]" as the separators specific to this processor.
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return ":?#/@.[]"; //$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 22ea1655e..cefe9abb3 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
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -22,17 +21,11 @@ import org.eclipse.equinox.bidi.custom.STextProcessor;
* </pre>
*/
public class STextUnderscore extends STextProcessor {
- static final STextFeatures FEATURES = new STextFeatures("_", 0, -1, -1, false, false); //$NON-NLS-1$
-
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with one separator (underscore),
- * no special cases, LTR direction for Arabic and Hebrew,
- * and support for both.
+ * @return "_" as the separators specific to this processor.
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return "_"; //$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 9544003a0..e115b89e1 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,24 +11,24 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextFeatures;
import org.eclipse.equinox.bidi.internal.STextDelims;
/**
* Processor adapted to processing XPath expressions.
*/
public class STextXPath extends STextDelims {
- static final STextFeatures FEATURES = new STextFeatures(" /[]<>=!:@.|()+-*", 2, -1, -1, false, false); //$NON-NLS-1$
+ /**
+ * @return " /[]<>=!:@.|()+-*" as the separators specific to this processor.
+ */
+ public String getSeparators(STextEnvironment environment, String text, byte[] dirProps) {
+ return " /[]<>=!:@.|()+-*"; //$NON-NLS-1$
+ }
/**
- * This method retrieves the features specific to this processor.
- *
- * @return features with separators " /[]<>=!:@.|()+-*",
- * 2 special cases, LTR direction for Arabic and Hebrew,
- * and support for both.
+ * @return 2 as the number of special cases handled by this processor.
*/
- public STextFeatures getFeatures(STextEnvironment env) {
- return FEATURES;
+ public int getSpecialsCount(STextEnvironment environment, String text, byte[] dirProps) {
+ return 2;
}
/**
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/package.html b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/package.html
index 3a5c9d8bc..611dee125 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/package.html
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/package.html
@@ -5,9 +5,14 @@
</head>
<body bgcolor="white">
-This package provides interfaces and classes for
+This package provides classes for
processing structured text.
-
+<p>
+There are various types of structured text. Each type should
+be handled by a specific <i>processor</i>. A number of standard
+processors are supplied in the associated package
+{@link <a href="internal\consumable\package-summary.html">
+org.eclipse.equinox.bidi.internal.consumable</a>}.
<h2>Introduction to Structured Text</h2>
<p>
@@ -44,7 +49,7 @@ The class {@link
is the main tool for processing structured text. It facilitates
handling several types of structured text, each type being handled
by a specific
-{@link <a href="custom\ISTextProcessor.html"><b><i>processor</i></b></a>} :</p>
+{@link <a href="custom\STextProcessor.html"><b><i>processor</i></b></a>} :</p>
<ul>
<li>property (name=value)</li>
<li>compound name (xxx_yy_zzzz)</li>
@@ -60,28 +65,30 @@ by a specific
<li>RTL arithmetic expressions</li>
</ul>
<p>
-Other classes and one interface in this package may be used to
+For each of these types, a static instance is defined in <b>STextEngine</b>.
+These pre-defined instances can be used as argument in the methods of
+<b>STextEngine</b>.
+</p><p>
+Other classes in this package may be used to
complement and facilitate the action of
{@link <a href="STextEngine.html">STextEngine</a>}:
<ul>
<li>{@link <a href="STextEnvironment.html">STextEnvironment</a>}
- regroups details about the environment</li>
+ regroups details about the environment</li>.
<li>{@link <a href="STextUtil.html">STextUtil</a>}
provides a number of convenience methods to process some common types of
structured text. When using methods in this class, there is no need
to use other classes of this package. However, the other classes allow
more precise control and possibly better performance.</li>
- <li>{@link <a href="ISTextTypes.html">ISTextTypes</a>}
- is an interface which contains only literals identifying the various types
- of structured text currently supported.</li>
<li>{@link <a href="STextStringRecord.html">STextStringRecord</a>}
- allows to record strings which are structured text with their
- type, so that another module can check if a given string has been recorded
- as a structured text string and retrieve its type.</li>
+ allows to record strings which are structured text with the
+ type of the appropriate processor,
+ so that another module can check if a given string has been recorded
+ as a structured text string and run its processor.</li>
</ul>
<p>
{@link <a href="STextEngine.html">STextEngine</a>} and the
-other classes and interface mentioned above are intended for users who
+other classes mentioned above are intended for users who
need to process structured text for which there already exist
processors.
<p>
@@ -90,14 +97,9 @@ not currently supported can use the following components of the
package {@link <a href="custom\package-summary.html">
org.eclipse.equinox.bidi.custom</a>}:
<ul>
- <li>{@link <a href="custom\ISTextProcessor.html">ISTextProcessor</a>}
- is an interface specifying which methods a processor must provide.</li>
<li>{@link <a href="custom\STextProcessor.html">STextProcessor</a>}
- is a generic processor which can be used as superclass for specific
+ is a generic processor to be used as superclass for specific
processors.</li>
- <li>{@link <a href="custom\STextFeatures.html">STextFeatures</a>}
- allows managing some factors which affect
- a structured text processor's behavior.</li>
<li>{@link <a href="custom\STextStringProcessor.html">STextStringProcessor</a>}
allows retrieval of the defined processor types and of the
corresponding processors.</li>

Back to the top