Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 201465 Details for
Bug 183164
[Implementation for] Display of Complex Expressions Containing Bidirectional Text
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Tests after renaming and merging
patch_bidi_20110814.txt (text/plain), 187.29 KB, created by
Matitiahu Allouche
on 2011-08-13 20:10:04 EDT
(
hide
)
Description:
Tests after renaming and merging
Filename:
MIME Type:
Creator:
Matitiahu Allouche
Created:
2011-08-13 20:10:04 EDT
Size:
187.29 KB
patch
obsolete
>diff --git plugin.xml plugin.xml >index dcd6a39..3e80188 100644 >--- plugin.xml >+++ plugin.xml >@@ -10,32 +10,32 @@ > type="test"> > </typeDescription> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.TestHandler1" >- description="Test Handler 1" >- type="test.Handler1"> >+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessor1" >+ description="Test processor 1" >+ type="test.Processor1"> > </typeDescription> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.TestHandler2" >- description="Test Handler 2" >- type="test.Handler2"> >+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessor2" >+ description="Test processor 2" >+ type="test.Processor2"> > </typeDescription> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.TestHandler3" >- description="Test Handler 3" >- type="test.Handler3"> >+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessor3" >+ description="Test processor 3" >+ type="test.Processor3"> > </typeDescription> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRL" >+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaRL" > description="Test my comma RL" > type="test.MyCommaRL"> > </typeDescription> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRR" >+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaRR" > description="Test my comma RR" > type="test.MyCommaRR"> > </typeDescription> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaLL" >+ class="org.eclipse.equinox.bidi.internal.tests.TestProcessorMyCommaLL" > description="Test my comma LL" > type="test.MyCommaLL"> > </typeDescription> >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java >index 0e76dac..a412afc 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java >@@ -11,46 +11,46 @@ > > package org.eclipse.equinox.bidi.internal.tests; > >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >+import org.eclipse.equinox.bidi.STextProcessorFactory; >+import org.eclipse.equinox.bidi.advanced.STextExpertFactory; > import org.eclipse.equinox.bidi.advanced.ISTextExpert; >-import org.eclipse.equinox.bidi.advanced.STextExpertFactory; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > /** >- * Tests contribution of BiDi handlers. >+ * Tests contribution of BiDi processors. > */ > public class STextExtensibilityTest extends STextTestBase { > > public void testBaseContributions() { >- String[] types = STextTypeHandlerFactory.getAllHandlerIDs(); >+ String[] types = STextProcessorFactory.getAllProcessorIDs(); > assertNotNull(types); > assertTrue(types.length > 0); > > // check one of the types that we know should be there > assertTrue(isTypePresent(types, "regex")); > >- STextTypeHandler handler = STextTypeHandlerFactory.getHandler("regex"); >- assertNotNull(handler); >+ STextProcessor processor = STextProcessorFactory.getProcessor("regex"); >+ assertNotNull(processor); > } > > public void testOtherContributions() { >- String[] types = STextTypeHandlerFactory.getAllHandlerIDs(); >+ String[] types = STextProcessorFactory.getAllProcessorIDs(); > assertNotNull(types); > assertTrue(types.length > 0); > > // check the type added by the test bundle > assertTrue(isTypePresent(types, "test")); > >- STextTypeHandler handler = STextTypeHandlerFactory.getHandler("test"); >- assertNotNull(handler); >+ STextProcessor processor = STextProcessorFactory.getProcessor("test"); >+ assertNotNull(processor); > >- handler = STextTypeHandlerFactory.getHandler("badtest"); >- assertNull(handler); >+ processor = STextProcessorFactory.getProcessor("badtest"); >+ assertNull(processor); > > String data, lean, full, model; > data = "ABC.DEF:HOST-COM=HELLO"; > lean = toUT16(data); >- handler = STextTypeHandlerFactory.getHandler("test"); >+ processor = STextProcessorFactory.getProcessor("test"); > > ISTextExpert expert = STextExpertFactory.getExpert("test"); > full = expert.leanToFullText(lean); >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java >index a01e7a6..9d36b87 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java >@@ -11,7 +11,7 @@ > > package org.eclipse.equinox.bidi.internal.tests; > >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >+import org.eclipse.equinox.bidi.STextProcessorFactory; > import org.eclipse.equinox.bidi.advanced.*; > > /** >@@ -43,30 +43,30 @@ > public void testExtensions() { > String data; > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, env); > doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.EMAIL, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env); > doTest1("Email #1", "abc.DEF:GHI", "abc.DEF@:GHI"); > doTest1("Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK "); > doTest1("Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK "); > doTest1("Email #4", "DEF.GHI (A.B :JK ", "DEF@.GHI @(A.B :JK "); > env = envArabic; >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.EMAIL, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env); > doTest1("Email #5", "#EF.GHI \"A.B\":JK ", "<&#EF.GHI \"A.B\":JK &^"); > doTest1("Email #6", "#EF,GHI (A,B);JK ", "<&#EF,GHI (A,B);JK &^"); > doTest1("Email #7", "#EF.GHI (A.B :JK ", "<&#EF.GHI (A.B :JK &^"); > data = toUT16("peter.pan") + "@" + toUT16("#EF.GHI"); > doTest2("Email #8", data, "<&peter&.pan@#EF.GHI&^"); > env = envHebrew; >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.EMAIL, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env); > data = toUT16("peter.pan") + "@" + toUT16("DEF.GHI"); > doTest2("Email #9", data, "peter.pan@DEF@.GHI"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.FILE, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.FILE, env); > doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT"); > >- expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.JAVA, env); > doTest1("Java #1", "A = B + C;", "A@ = B@ + C;"); > doTest1("Java #2", "A = B + C;", "A@ = B@ + C;"); > doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;"); >@@ -78,12 +78,12 @@ > doTest1("Java #9", "A = //B+C* D;", "A@ = //B+C* D;"); > doTest1("Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.PROPERTY, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.PROPERTY, env); > doTest1("Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2"); > doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2"); > doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3"); > >- expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.REGEXP, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.REGEXP, env); > data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI"); > doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I"); > data = toUT16("ABC(?") + "#" + toUT16("DEF"); >@@ -129,7 +129,7 @@ > doTest1("Regex #17.7", "aB*567", "aB*@567"); > > env = envArabic; >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.REGEXP, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.REGEXP, env); > data = toUT16("#BC(?") + "#" + toUT16("DEF)GHI"); > doTest2("Regex #0.0", data, "<&#BC(?#DEF)GHI&^"); > data = toUT16("#BC(?") + "#" + toUT16("DEF"); >@@ -167,7 +167,7 @@ > doTest2("Regex #16.2", data, "<&#HI\\eJKL&^"); > env = envHebrew; > >- expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.SQL, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.SQL, env); > doTest1("SQL #0", "abc GHI", "abc GHI"); > doTest1("SQL #1", "abc DEF GHI", "abc DEF@ GHI"); > doTest1("SQL #2", "ABC, DEF, GHI", "ABC@, DEF@, GHI"); >@@ -185,22 +185,22 @@ > doTest1("SQL #12", "ABC\"DEF \"\" G I\" JKL,MN", "ABC@\"DEF \"\" G I\"@ JKL@,MN"); > doTest1("SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.SYSTEM_USER, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.SYSTEM_USER, env); > doTest1("System #1", "HOST(JACK)", "HOST@(JACK)"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.UNDERSCORE, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.UNDERSCORE, env); > doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.URL, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.URL, env); > doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4"); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.XPATH, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.XPATH, env); > doTest1("Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI"); > doTest1("Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK "); > doTest1("Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK "); > doTest1("Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK "); > >- expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.EMAIL, env); >+ expert = STextExpertFactory.getExpert(STextProcessorFactory.EMAIL, env); > doTest3("DelimsEsc #1", "abc.DEF.GHI", "abc.DEF@.GHI"); > doTest3("DelimsEsc #2", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK "); > doTest3("DelimsEsc #3", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK "); >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java >index d6f1987..30e8789 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java >@@ -11,7 +11,7 @@ > > package org.eclipse.equinox.bidi.internal.tests; > >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >+import org.eclipse.equinox.bidi.STextProcessorFactory; > import org.eclipse.equinox.bidi.advanced.*; > > /** >@@ -110,7 +110,7 @@ > } > > public void testFullToLean() { >- type = STextTypeHandlerFactory.COMMA_DELIMITED; >+ type = STextProcessorFactory.COMMA_DELIMITED; > doTest1("testFullToLean #1 - ", "", "", "", new int[0], new int[0], "", "", new int[0], new int[0]); > int[] map1 = new int[] {0, 1, 2, 3, 4}; > int[] map2 = new int[] {2, 3, 4, 5, 6}; >@@ -257,7 +257,7 @@ > doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2); > > // test fullToLeanText with initial state >- type = STextTypeHandlerFactory.SQL; >+ type = STextProcessorFactory.SQL; > doTest2("testFullToLean #38 - "); > } > } >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java >index 3ebef2d..56e45b4 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java >@@ -11,7 +11,7 @@ > > package org.eclipse.equinox.bidi.internal.tests; > >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >+import org.eclipse.equinox.bidi.STextProcessorFactory; > import org.eclipse.equinox.bidi.advanced.*; > > /** >@@ -22,8 +22,8 @@ > private STextEnvironment envLTR = new STextEnvironment("ar", false, STextEnvironment.ORIENT_LTR); > private STextEnvironment envRTL = new STextEnvironment("ar", false, STextEnvironment.ORIENT_RTL); > >- private ISTextExpert expertLTR = STextExpertFactory.getExpert(STextTypeHandlerFactory.RTL_ARITHMETIC, envLTR); >- private ISTextExpert expertRTL = STextExpertFactory.getExpert(STextTypeHandlerFactory.RTL_ARITHMETIC, envRTL); >+ private ISTextExpert expertLTR = STextExpertFactory.getExpert(STextProcessorFactory.RTL_ARITHMETIC, envLTR); >+ private ISTextExpert expertRTL = STextExpertFactory.getExpert(STextProcessorFactory.RTL_ARITHMETIC, envRTL); > > private void verifyOneLine(String msg, String data, String resLTR, String resRTL) { > String lean = toUT16(data); >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java >index 3429077..e78a98b 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java >@@ -12,7 +12,7 @@ > package org.eclipse.equinox.bidi.internal.tests; > > import org.eclipse.equinox.bidi.STextDirection; >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >+import org.eclipse.equinox.bidi.STextProcessorFactory; > import org.eclipse.equinox.bidi.advanced.*; > > /** >@@ -47,31 +47,26 @@ > > private void doTestState() { > String data, lean, full, model; >- ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA); >+ ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextProcessorFactory.JAVA); > > data = "A=B+C;/* D=E+F;"; > lean = toUT16(data); > full = expert.leanToFullText(lean); >+ > model = "A@=B@+C@;/* D=E+F;"; > assertEquals("full1", model, toPseudo(full)); >- > data = "A=B+C; D=E+F;"; > lean = toUT16(data); > full = expert.leanToFullText(lean); >- model = data; >+ >+ model = "A=B+C; D=E+F;"; > assertEquals("full2", model, toPseudo(full)); >- >- data = "SOME MORE COMMENTS"; >- lean = toUT16(data); >- full = expert.leanToFullText(lean); >- model = data; >- assertEquals("full3", model, toPseudo(full)); >- > data = "A=B+C;*/ D=E+F;"; > lean = toUT16(data); > full = expert.leanToFullText(lean); >+ > model = "A=B+C;@*/ D@=E@+F;"; >- assertEquals("full4", model, toPseudo(full)); >+ assertEquals("full3", model, toPseudo(full)); > } > > private void doTestOrientation() { >@@ -88,12 +83,12 @@ > assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient); > } > >- private void doTestOrient(String handlerDefID, String label, String data, String resLTR, String resRTL, String resCon) { >+ private void doTestOrient(String processorDefID, String label, String data, String resLTR, String resRTL, String resCon) { > String full, lean; > >- ISTextExpert expertLTR = STextExpertFactory.getExpert(handlerDefID, envLTR); >- ISTextExpert expertRTL = STextExpertFactory.getExpert(handlerDefID, envRTL); >- ISTextExpert expertCRL = STextExpertFactory.getExpert(handlerDefID, envCRL); >+ ISTextExpert expertLTR = STextExpertFactory.getExpert(processorDefID, envLTR); >+ ISTextExpert expertRTL = STextExpertFactory.getExpert(processorDefID, envRTL); >+ ISTextExpert expertCRL = STextExpertFactory.getExpert(processorDefID, envCRL); > > lean = toUT16(data); > full = expertLTR.leanToFullText(lean); >@@ -111,7 +106,7 @@ > > private void doTestLeanOffsets() { > String lean, data, label; >- ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA); >+ ISTextExpert expert = STextExpertFactory.getExpert(STextProcessorFactory.JAVA); > > int[] offsets; > int[] model; >@@ -133,9 +128,9 @@ > private void doTestFullOffsets(String label, String data, int[] resLTR, int[] resRTL, int[] resCon) { > String full, lean, msg; > int[] offsets; >- ISTextExpert expertLTR = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, envLTR); >- ISTextExpert expertRTL = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, envRTL); >- ISTextExpert expertCLR = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED, envCLR); >+ ISTextExpert expertLTR = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envLTR); >+ ISTextExpert expertRTL = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envRTL); >+ ISTextExpert expertCLR = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED, envCLR); > > lean = toUT16(data); > full = expertLTR.leanToFullText(lean); >@@ -243,15 +238,15 @@ > > doTestOrientation(); > >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #1 ", "", "", "", ""); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #2 ", "abc", "abc", ">@abc@^", "abc"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH"); >- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #1 ", "", "", "", ""); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #2 ", "abc", "abc", ">@abc@^", "abc"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH"); >+ doTestOrient(STextProcessorFactory.COMMA_DELIMITED, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh"); > > doTestSkipProcessing(); > >@@ -263,7 +258,7 @@ > > doTestDirection(); > >- ISTextExpert expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.COMMA_DELIMITED); >+ ISTextExpert expert = STextExpertFactory.getExpert(STextProcessorFactory.COMMA_DELIMITED); > String data = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; > String lean = toUT16(data); > String full = expert.leanToFullText(lean); >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java >new file mode 0 >index 0000000..9ebb2d0 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+ >+/** >+ * Tests null processor >+ */ >+public class STextNullProcessorTest extends STextTestBase { >+ >+ static final int[] EMPTY_INT_ARRAY = new int[0]; >+ >+ public void testNullProcessor() { >+ /* not needed >+ String full = STextEngine.leanToFullText(null, null, "abc", null); >+ assertEquals("leanToFullText", "abc", full); >+ int[] state = new int[1]; >+ state[0] = 3; >+ full = STextEngine.leanToFullText(null, null, "abc", state); >+ assertEquals("leanToFullText with state", "abc", full); >+ int[] offsets = STextEngine.leanBidiCharOffsets(null, null, "abc", null); >+ assertEquals("leanBidiCharOffsets", 0, offsets.length); >+ offsets = STextEngine.fullBidiCharOffsets(null, null, "abc", null); >+ assertEquals("fullBidiCharOffsets", 0, offsets.length); >+ String lean = STextEngine.fullToLeanText(null, null, "abc", null); >+ assertEquals("fullToLeanText", "abc", lean); >+ lean = STextEngine.fullToLeanText(null, null, "abc", state); >+ assertEquals("fullToLeanText with state", "abc", lean); >+ int[] map = STextEngine.leanToFullMap(null, null, "abc", null); >+ int[] model = {0, 1, 2}; >+ assertEquals("leanToFullMap", array_display(model), array_display(map)); >+ map = STextEngine.fullToLeanMap(null, null, "abc", null); >+ assertEquals("fullToLeanMap", array_display(model), array_display(map)); >+ int direction = STextEngine.getCurDirection(null, null, "abc"); >+ assertEquals("getCurDirection", STextEngine.DIR_LTR, direction); >+ */ >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java >deleted file mode 100644 >index 5a60c2b..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java >+++ /dev/null >@@ -1,126 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import java.util.Locale; >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >-import org.eclipse.equinox.bidi.STextProcessor; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >- >-/** >- * Tests methods in BidiComplexUtil >- */ >- >-public class STextProcessorTest extends STextTestBase { >- >- private static final String HEBREW = "iw"; >- >- private static final String HEBREW2 = "he"; >- >- private static final String ARABIC = "ar"; >- >- private static final String FARSI = "fa"; >- >- private static final String URDU = "ur"; >- >- private Locale locale; >- >- protected void setUp() throws Exception { >- super.setUp(); >- locale = Locale.getDefault(); >- } >- >- protected void tearDown() { >- Locale.setDefault(locale); >- } >- >- private void doTest1(String data, String result) { >- Locale.setDefault(Locale.ENGLISH); >- String full = STextProcessor.process(toUT16(data)); >- assertEquals("Util #1 full EN - ", data, toPseudo(full)); >- Locale.setDefault(new Locale(HEBREW2)); >- full = STextProcessor.process(toUT16(data)); >- assertEquals("Util #1 full HE - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(ARABIC)); >- full = STextProcessor.process(toUT16(data)); >- assertEquals("Util #1 full AR - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(FARSI)); >- full = STextProcessor.process(toUT16(data)); >- assertEquals("Util #1 full FA - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(URDU)); >- full = STextProcessor.process(toUT16(data)); >- assertEquals("Util #1 full UR - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(HEBREW)); >- full = STextProcessor.process(toUT16(data)); >- String ful2 = STextProcessor.process(toUT16(data), (String) null); >- assertEquals("Util #1 full - ", result, toPseudo(full)); >- assertEquals("Util #1 ful2 - ", result, toPseudo(ful2)); >- String lean = STextProcessor.deprocess(full); >- assertEquals("Util #1 lean - ", data, toPseudo(lean)); >- } >- >- private void doTest2(String msg, String data, String result) { >- doTest2(msg, data, result, data); >- } >- >- private void doTest2(String msg, String data, String result, String resLean) { >- String full = STextProcessor.process(toUT16(data), "*"); >- assertEquals(msg + "full", result, toPseudo(full)); >- String lean = STextProcessor.deprocess(full); >- assertEquals(msg + "lean", resLean, toPseudo(lean)); >- } >- >- private void doTest3(String msg, String data, String result) { >- doTest3(msg, data, result, data); >- } >- >- private void doTest3(String msg, String data, String result, String resLean) { >- STextTypeHandler handler = STextTypeHandlerFactory.getHandler(STextTypeHandlerFactory.COMMA_DELIMITED); >- String full = STextProcessor.process(toUT16(data), handler); >- assertEquals(msg + "full", result, toPseudo(full)); >- String lean = STextProcessor.deprocess(full, handler); >- assertEquals(msg + "lean", resLean, toPseudo(lean)); >- } >- >- private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) { >- String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix; >- String lean = toUT16(data); >- String full = STextProcessor.insertMarks(lean, offsets, direction, affix); >- assertEquals(txt, result, toPseudo(full)); >- } >- >- public void testBidiComplexUtil() { >- >- // Test process() and deprocess() with default delimiters >- doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^"); >- // Test process() and deprocess() with specified delimiters >- doTest2("Util #2.1 - ", "", ""); >- doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC"); >- doTest2("Util #2.3 - ", "abc", "abc"); >- doTest2("Util #2.4 - ", "!abc", ">@!abc@^"); >- doTest2("Util #2.5 - ", "abc!", ">@abc!@^"); >- doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^"); >- // Test process() and deprocess() with specified expression type >- doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^"); >- doTest3("Util #3.2 - ", "", ""); >- doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF"); >- // Test insertMarks() >- doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G"); >- doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^"); >- doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G"); >- doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^"); >- doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, ""); >- doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, ""); >- doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG"); >- doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^"); >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java >index 0166a2d..1cb83a8 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java >@@ -25,11 +25,11 @@ > assertFalse(env1.isProcessingNeeded()); > assertTrue(env2.isProcessingNeeded()); > >- ISTextExpert expert1 = STextExpertFactory.getExpert("test.Handler1", env1); >+ ISTextExpert expert1 = STextExpertFactory.getExpert("test.Processor1", env1); > String full = expert1.leanToFullText("abcd"); > assertEquals("@a@b@c@d", toPseudo(full)); > >- ISTextExpert expert2 = STextExpertFactory.getExpert("test.Handler2", env1); >+ ISTextExpert expert2 = STextExpertFactory.getExpert("test.Processor2", env1); > boolean catchFlag = false; > try { > full = expert2.leanToFullText("abcd"); >@@ -39,7 +39,7 @@ > assertTrue("Catch missing indexOfSpecial", catchFlag); > > catchFlag = false; >- ISTextExpert expert3 = STextExpertFactory.getExpert("test.Handler3", env1); >+ ISTextExpert expert3 = STextExpertFactory.getExpert("test.Processor3", env1); > try { > full = expert3.leanToFullText("abcd"); > } catch (IllegalStateException e) { >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java >index c62cbee..b720803 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java >@@ -11,8 +11,8 @@ > > package org.eclipse.equinox.bidi.internal.tests; > >+import org.eclipse.equinox.bidi.STextProcessorFactory; > import org.eclipse.equinox.bidi.STextStringRecord; >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; > > /** > * Tests the StringRecord class >@@ -24,7 +24,7 @@ > // check handling of invalid arguments > catchFlag = false; > try { >- sr = STextStringRecord.addRecord(null, 1, STextTypeHandlerFactory.EMAIL, 0, 1); >+ sr = STextStringRecord.addRecord(null, 1, STextProcessorFactory.EMAIL, 0, 1); > } catch (IllegalArgumentException e) { > catchFlag = true; > } >@@ -35,38 +35,38 @@ > } catch (IllegalArgumentException e) { > catchFlag = true; > } >- assertTrue("Catch null handler argument", catchFlag); >+ assertTrue("Catch null processor argument", catchFlag); > catchFlag = false; > try { >- sr = STextStringRecord.addRecord("abc", 0, STextTypeHandlerFactory.EMAIL, 0, 1); >+ sr = STextStringRecord.addRecord("abc", 0, STextProcessorFactory.EMAIL, 0, 1); > } catch (IllegalArgumentException e) { > catchFlag = true; > } > assertTrue("Catch invalid segment count argument", catchFlag); > catchFlag = false; > try { >- sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, -1, 1); >+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, -1, 1); > } catch (IllegalArgumentException e) { > catchFlag = true; > } > assertTrue("Catch invalid start argument", catchFlag); > catchFlag = false; > try { >- sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, 4, 1); >+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 4, 1); > } catch (IllegalArgumentException e) { > catchFlag = true; > } > assertTrue("Catch invalid start argument", catchFlag); > catchFlag = false; > try { >- sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, 0, 0); >+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 0, 0); > } catch (IllegalArgumentException e) { > catchFlag = true; > } > assertTrue("Catch invalid limit argument", catchFlag); > catchFlag = false; > try { >- sr = STextStringRecord.addRecord("abc", 1, STextTypeHandlerFactory.EMAIL, 0, 5); >+ sr = STextStringRecord.addRecord("abc", 1, STextProcessorFactory.EMAIL, 0, 5); > } catch (IllegalArgumentException e) { > catchFlag = true; > } >@@ -78,7 +78,7 @@ > assertEquals(null, sr); > for (int i = 0; i < lim; i++) { > String str = Integer.toString(i); >- sr = STextStringRecord.addRecord(str, 1, STextTypeHandlerFactory.EMAIL, 0, 1); >+ sr = STextStringRecord.addRecord(str, 1, STextProcessorFactory.EMAIL, 0, 1); > } > sr = STextStringRecord.getRecord(null); > assertEquals(null, sr); >@@ -96,7 +96,7 @@ > > for (int i = lim; i <= poolSize; i++) { > String str = Integer.toString(i); >- sr = STextStringRecord.addRecord(str, 1, STextTypeHandlerFactory.EMAIL, 0, 1); >+ sr = STextStringRecord.addRecord(str, 1, STextProcessorFactory.EMAIL, 0, 1); > } > for (int i = 1; i <= poolSize; i++) { > String str = Integer.toString(i); >@@ -105,20 +105,20 @@ > } > sr = STextStringRecord.getRecord("0"); > assertEquals(null, sr); >- sr = STextStringRecord.addRecord("thisisalongstring", 3, STextTypeHandlerFactory.EMAIL, 0, 2); >- sr.addSegment(STextTypeHandlerFactory.JAVA, 4, 5); >- sr.addSegment(STextTypeHandlerFactory.FILE, 6, 7); >+ sr = STextStringRecord.addRecord("thisisalongstring", 3, STextProcessorFactory.EMAIL, 0, 2); >+ sr.addSegment(STextProcessorFactory.JAVA, 4, 5); >+ sr.addSegment(STextProcessorFactory.FILE, 6, 7); > catchFlag = false; > try { >- sr.addSegment(STextTypeHandlerFactory.EMAIL, 10, 13); >+ sr.addSegment(STextProcessorFactory.EMAIL, 10, 13); > } catch (IllegalStateException e) { > catchFlag = true; > } > assertTrue("Catch too many segments", catchFlag); > assertEquals(3, sr.getSegmentCount()); >- assertEquals(STextTypeHandlerFactory.EMAIL, sr.getHandler(0)); >- assertEquals(STextTypeHandlerFactory.JAVA, sr.getHandler(1)); >- assertEquals(STextTypeHandlerFactory.FILE, sr.getHandler(2)); >+ assertEquals(STextProcessorFactory.EMAIL, sr.getProcessor(0)); >+ assertEquals(STextProcessorFactory.JAVA, sr.getProcessor(1)); >+ assertEquals(STextProcessorFactory.FILE, sr.getProcessor(2)); > assertEquals(0, sr.getStart(0)); > assertEquals(4, sr.getStart(1)); > assertEquals(6, sr.getStart(2)); >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextTest.java src/org/eclipse/equinox/bidi/internal/tests/STextTest.java >index 2292c0d..6d8149a 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextTest.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextTest.java >@@ -10,9 +10,9 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.tests; > >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > >-public class STextTest extends STextTypeHandler { >+public class STextTest extends STextProcessor { > > public STextTest() { > super("-=.:"); >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java >index ae2bd7e..294d98f 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java >+++ src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java >@@ -14,7 +14,7 @@ > import junit.framework.TestCase; > > /** >- * Base functionality for the handler tests. >+ * Base functionality for the processor tests. > */ > public class STextTestBase extends TestCase { > >diff --git src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java >new file mode 0 >index 0000000..89c437b 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java >@@ -0,0 +1,126 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import java.util.Locale; >+import org.eclipse.equinox.bidi.STextProcessorFactory; >+import org.eclipse.equinox.bidi.STextUtil; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+ >+/** >+ * Tests methods in BidiComplexUtil >+ */ >+ >+public class STextUtilTest extends STextTestBase { >+ >+ private static final String HEBREW = "iw"; >+ >+ private static final String HEBREW2 = "he"; >+ >+ private static final String ARABIC = "ar"; >+ >+ private static final String FARSI = "fa"; >+ >+ private static final String URDU = "ur"; >+ >+ private Locale locale; >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ locale = Locale.getDefault(); >+ } >+ >+ protected void tearDown() { >+ Locale.setDefault(locale); >+ } >+ >+ private void doTest1(String data, String result) { >+ Locale.setDefault(Locale.ENGLISH); >+ String full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full EN - ", data, toPseudo(full)); >+ Locale.setDefault(new Locale(HEBREW2)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full HE - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(ARABIC)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full AR - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(FARSI)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full FA - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(URDU)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full UR - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(HEBREW)); >+ full = STextUtil.process(toUT16(data)); >+ String ful2 = STextUtil.process(toUT16(data), (String) null); >+ assertEquals("Util #1 full - ", result, toPseudo(full)); >+ assertEquals("Util #1 ful2 - ", result, toPseudo(ful2)); >+ String lean = STextUtil.deprocess(full); >+ assertEquals("Util #1 lean - ", data, toPseudo(lean)); >+ } >+ >+ private void doTest2(String msg, String data, String result) { >+ doTest2(msg, data, result, data); >+ } >+ >+ private void doTest2(String msg, String data, String result, String resLean) { >+ String full = STextUtil.process(toUT16(data), "*"); >+ assertEquals(msg + "full", result, toPseudo(full)); >+ String lean = STextUtil.deprocess(full); >+ assertEquals(msg + "lean", resLean, toPseudo(lean)); >+ } >+ >+ private void doTest3(String msg, String data, String result) { >+ doTest3(msg, data, result, data); >+ } >+ >+ private void doTest3(String msg, String data, String result, String resLean) { >+ STextProcessor descriptor = STextProcessorFactory.getProcessor(STextProcessorFactory.COMMA_DELIMITED); >+ String full = STextUtil.process(toUT16(data), descriptor); >+ assertEquals(msg + "full", result, toPseudo(full)); >+ String lean = STextUtil.deprocess(full, descriptor); >+ assertEquals(msg + "lean", resLean, toPseudo(lean)); >+ } >+ >+ private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) { >+ String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix; >+ String lean = toUT16(data); >+ String full = STextUtil.insertMarks(lean, offsets, direction, affix); >+ assertEquals(txt, result, toPseudo(full)); >+ } >+ >+ public void testBidiComplexUtil() { >+ >+ // Test process() and deprocess() with default delimiters >+ doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^"); >+ // Test process() and deprocess() with specified delimiters >+ doTest2("Util #2.1 - ", "", ""); >+ doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC"); >+ doTest2("Util #2.3 - ", "abc", "abc"); >+ doTest2("Util #2.4 - ", "!abc", ">@!abc@^"); >+ doTest2("Util #2.5 - ", "abc!", ">@abc!@^"); >+ doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^"); >+ // Test process() and deprocess() with specified expression type >+ doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^"); >+ doTest3("Util #3.2 - ", "", ""); >+ doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF"); >+ // Test insertMarks() >+ doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G"); >+ doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^"); >+ doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G"); >+ doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^"); >+ doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, ""); >+ doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, ""); >+ doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG"); >+ doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^"); >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java >deleted file mode 100644 >index 3974caa..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java >+++ /dev/null >@@ -1,34 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; >-import org.eclipse.equinox.bidi.custom.*; >- >-public class TestHandler1 extends STextTypeHandler { >- >- public int getSpecialsCount(STextEnvironment env) { >- return 1; >- } >- >- public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) { >- return fromIndex; >- } >- >- public int processSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >- int len = text.length(); >- for (int i = len - 1; i >= 0; i--) { >- STextTypeHandler.insertMark(text, charTypes, offsets, i); >- STextTypeHandler.insertMark(text, charTypes, offsets, i); >- } >- return len; >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java >deleted file mode 100644 >index acf1f8a..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java >+++ /dev/null >@@ -1,22 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >- >-public class TestHandler2 extends STextTypeHandler { >- >- public int getSpecialsCount(STextEnvironment env) { >- return 1; >- } >- >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java >deleted file mode 100644 >index 354a8c9..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java >+++ /dev/null >@@ -1,25 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; >-import org.eclipse.equinox.bidi.custom.*; >- >-public class TestHandler3 extends STextTypeHandler { >- >- public int getSpecialsCount(STextEnvironment env) { >- return 1; >- } >- >- public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) { >- return fromIndex; >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java >deleted file mode 100644 >index 89688a0..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java >+++ /dev/null >@@ -1,55 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.STextDirection; >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; >-import org.eclipse.equinox.bidi.custom.STextCharTypes; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >- >-public class TestHandlerMyComma extends STextTypeHandler { >- >- private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; >- protected final static int LTR = STextDirection.DIR_LTR; >- protected final static int RTL = STextDirection.DIR_RTL; >- >- final int dirArabic; >- final int dirHebrew; >- >- public TestHandlerMyComma(int dirArabic, int dirHebrew) { >- this.dirArabic = dirArabic; >- this.dirHebrew = dirHebrew; >- } >- >- public String getSeparators(STextEnvironment environment) { >- return ","; //$NON-NLS-1$ >- } >- >- public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) { >- byte charType = charTypes.getBidiTypeAt(0); >- if (charType == AL) >- return true; >- return false; >- } >- >- public int getDirection(STextEnvironment environment, String text) { >- return getDirection(environment, text, new STextCharTypes(this, environment, text)); >- } >- >- public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { >- for (int i = 0; i < text.length(); i++) { >- byte charType = charTypes.getBidiTypeAt(i); >- if (charType == AL) >- return dirArabic; >- } >- return dirHebrew; >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java >deleted file mode 100644 >index c901c86..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java >+++ /dev/null >@@ -1,18 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-public class TestHandlerMyCommaLL extends TestHandlerMyComma { >- >- public TestHandlerMyCommaLL() { >- super(LTR, LTR); >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java >deleted file mode 100644 >index 99d51e8..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java >+++ /dev/null >@@ -1,18 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-public class TestHandlerMyCommaRL extends TestHandlerMyComma { >- >- public TestHandlerMyCommaRL() { >- super(RTL, LTR); >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java >deleted file mode 100644 >index aa92a01..0000000 100644 >--- src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java >+++ /dev/null >@@ -1,18 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-public class TestHandlerMyCommaRR extends TestHandlerMyComma { >- >- public TestHandlerMyCommaRR() { >- super(RTL, RTL); >- } >-} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java >new file mode 0 >index 0000000..2d3f4de 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessor1.java >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.custom.*; >+ >+public class TestProcessor1 extends STextProcessor { >+ >+ public int getSpecialsCount(STextEnvironment env) { >+ return 1; >+ } >+ >+ public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) { >+ return fromIndex; >+ } >+ >+ public int processSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >+ int len = text.length(); >+ for (int i = len - 1; i >= 0; i--) { >+ STextProcessor.insertMark(text, charTypes, offsets, i); >+ STextProcessor.insertMark(text, charTypes, offsets, i); >+ } >+ return len; >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java >new file mode 0 >index 0000000..fd75890 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessor2.java >@@ -0,0 +1,22 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+ >+public class TestProcessor2 extends STextProcessor { >+ >+ public int getSpecialsCount(STextEnvironment env) { >+ return 1; >+ } >+ >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java >new file mode 0 >index 0000000..4a1f77d 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessor3.java >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.custom.*; >+ >+public class TestProcessor3 extends STextProcessor { >+ >+ public int getSpecialsCount(STextEnvironment env) { >+ return 1; >+ } >+ >+ public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) { >+ return fromIndex; >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java >new file mode 0 >index 0000000..e295661 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyComma.java >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextDirection; >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.custom.STextCharTypes; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+ >+public class TestProcessorMyComma extends STextProcessor { >+ >+ private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; >+ protected final static int LTR = STextDirection.DIR_LTR; >+ protected final static int RTL = STextDirection.DIR_RTL; >+ >+ final int dirArabic; >+ final int dirHebrew; >+ >+ public TestProcessorMyComma(int dirArabic, int dirHebrew) { >+ this.dirArabic = dirArabic; >+ this.dirHebrew = dirHebrew; >+ } >+ >+ public String getSeparators(STextEnvironment environment) { >+ return ","; //$NON-NLS-1$ >+ } >+ >+ public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) { >+ byte charType = charTypes.getBidiTypeAt(0); >+ if (charType == AL) >+ return true; >+ return false; >+ } >+ >+ public int getDirection(STextEnvironment environment, String text) { >+ return getDirection(environment, text, new STextCharTypes(this, environment, text)); >+ } >+ >+ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { >+ for (int i = 0; i < text.length(); i++) { >+ byte charType = charTypes.getBidiTypeAt(i); >+ if (charType == AL) >+ return dirArabic; >+ } >+ return dirHebrew; >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java >new file mode 0 >index 0000000..1755396 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaLL.java >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+public class TestProcessorMyCommaLL extends TestProcessorMyComma { >+ >+ public TestProcessorMyCommaLL() { >+ super(LTR, LTR); >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java >new file mode 0 >index 0000000..6917def 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRL.java >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+public class TestProcessorMyCommaRL extends TestProcessorMyComma { >+ >+ public TestProcessorMyCommaRL() { >+ super(RTL, LTR); >+ } >+} >diff --git src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java >new file mode 0 >index 0000000..1501704 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/tests/TestProcessorMyCommaRR.java >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+public class TestProcessorMyCommaRR extends TestProcessorMyComma { >+ >+ public TestProcessorMyCommaRR() { >+ super(RTL, RTL); >+ } >+} >diff --git src/org/eclipse/equinox/bidi/tests/STextTestSuite.java src/org/eclipse/equinox/bidi/tests/STextTestSuite.java >index 1224705..7b3f48c 100644 >--- src/org/eclipse/equinox/bidi/tests/STextTestSuite.java >+++ src/org/eclipse/equinox/bidi/tests/STextTestSuite.java >@@ -23,11 +23,12 @@ > public STextTestSuite() { > addTestSuite(STextExtensibilityTest.class); > addTestSuite(STextMethodsTest.class); >+ addTestSuite(STextNullProcessorTest.class); > addTestSuite(STextFullToLeanTest.class); > addTestSuite(STextExtensionsTest.class); > addTestSuite(STextMathTest.class); > addTestSuite(STextSomeMoreTest.class); >- addTestSuite(STextProcessorTest.class); >+ addTestSuite(STextUtilTest.class); > addTestSuite(STextStringRecordTest.class); > } > } >\ No newline at end of file >diff --git src/org/eclipse/equinox/bidi/STextDirection.java src/org/eclipse/equinox/bidi/STextDirection.java >index 9cb0156..e43b4f2 100644 >--- src/org/eclipse/equinox/bidi/STextDirection.java >+++ src/org/eclipse/equinox/bidi/STextDirection.java >@@ -12,7 +12,7 @@ > > import org.eclipse.equinox.bidi.advanced.STextEnvironment; > >-// TBD combine with STextProcessor; remove duplicates of those two constants >+// TBD combine with STextUtil; remove duplicates of those two constants > public interface STextDirection { > > /** >diff --git src/org/eclipse/equinox/bidi/STextProcessor.java src/org/eclipse/equinox/bidi/STextProcessor.java >deleted file mode 100644 >index 87d9f28..0000000 100644 >--- src/org/eclipse/equinox/bidi/STextProcessor.java >+++ /dev/null >@@ -1,269 +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; >- >-import org.eclipse.equinox.bidi.advanced.*; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >- >-/** >- * This class provides a number of convenience functions facilitating the >- * processing of structured text. >- * >- * @noextend This class is not intended to be subclassed by clients. >- * @noinstantiate This class is not intended to be instantiated by clients. >- * >- * @author Matitiahu Allouche >- */ >-public final class STextProcessor { >- >- /** >- * The default set of separators used to segment a string: dot, colon, slash, backslash. >- */ >- public static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$ >- >- // left to right mark >- private static final char LRM = '\u200e'; >- >- // left to right mark >- private static final char RLM = '\u200f'; >- >- // left to right embedding >- private static final char LRE = '\u202a'; >- >- // right to left embedding >- private static final char RLE = '\u202b'; >- >- // pop directional format >- private static final char PDF = '\u202c'; >- >- /** >- * Prevents instantiation. >- */ >- private STextProcessor() { >- // empty >- } >- >- /** >- * This method adds directional marks to the given text before the characters >- * specified in the given array of offsets. It can be used to add a prefix and/or >- * a suffix of directional formatting characters. >- * <p> >- * The directional marks will be LRMs for structured text strings with LTR base >- * direction and RLMs for strings with RTL base direction. >- * </p><p> >- * If necessary, leading and trailing directional markers (LRE, RLE and PDF) can >- * be added depending on the value of the <code>affix</code> argument. >- * </p> >- * @see ISTextExpert#leanBidiCharOffsets(String) >- * >- * @param text the structured text string >- * @param offsets an array of offsets to characters in <code>text</code> >- * before which an LRM or RLM will be inserted. >- * The array must be sorted in ascending order without duplicates. >- * This argument may be <code>null</code> if there are no marks to add. >- * @param direction the base direction of the structured text. >- * It must be one of the values {@link STextDirection#DIR_LTR}, or >- * {@link STextDirection#DIR_RTL}. >- * @param affix specifies if a prefix and a suffix should be added to >- * the result >- * @return a string corresponding to the source <code>text</code> with >- * directional marks (LRMs or RLMs) added at the specified offsets, >- * and directional formatting characters (LRE, RLE, PDF) added >- * as prefix and suffix if so required. >- */ >- public static String insertMarks(String text, int[] offsets, int direction, boolean affix) { >- int textLen = text.length(); >- if (textLen == 0) >- return ""; //$NON-NLS-1$ >- >- String curPrefix, curSuffix, full; >- char curMark, c; >- char[] fullChars; >- if (direction == STextDirection.DIR_LTR) { >- curMark = LRM; >- curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$ >- curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$ >- } else { >- curMark = RLM; >- curPrefix = "\u202b\u200f"; /* RLE+RLM *///$NON-NLS-1$ >- curSuffix = "\u200f\u202c"; /* RLM+PDF *///$NON-NLS-1$ >- } >- // add marks at offsets >- if ((offsets != null) && (offsets.length > 0)) { >- int offLen = offsets.length; >- fullChars = new char[textLen + offLen]; >- int added = 0; >- for (int i = 0, j = 0; i < textLen; i++) { >- c = text.charAt(i); >- if ((j < offLen) && (i == offsets[j])) { >- fullChars[i + added] = curMark; >- added++; >- j++; >- } >- fullChars[i + added] = c; >- } >- full = new String(fullChars); >- } else { >- full = text; >- } >- if (affix) >- return curPrefix + full + curSuffix; >- return full; >- } >- >- /** >- * Process the given text and return a string with appropriate >- * directional formatting characters. This is equivalent to calling >- * {@link #process(String str, String separators)} with the default >- * set of separators. >- * <p> >- * The processing adds directional formatting characters so that presentation >- * using the Unicode Bidirectional Algorithm will provide the expected result. >- * The text is segmented according to the provided separators. >- * Each segment has the Unicode Bidi Algorithm applied to it, >- * but as a whole, the string is oriented left to right. >- * </p><p> >- * For example, a file path such as <tt>d:\myfolder\FOLDER\MYFILE.java</tt> >- * (where capital letters indicate RTL text) should render as >- * <tt>d:\myfolder\REDLOF\ELIFYM.java</tt>. >- * </p> >- * @param str the text to be processed >- * @return the processed string >- */ >- public static String process(String str) { >- return process(str, defaultSeparators); >- } >- >- /** >- * Process a string that has a particular semantic meaning to render >- * it correctly on bidi locales. >- * @see #process(String) >- * @param str the text to process >- * @param separators separators by which the string will be segmented >- * @return the processed string >- */ >- public static String process(String str, String separators) { >- if ((str == null) || (str.length() <= 1)) >- return str; >- >- // do not process a string that has already been processed. >- if (str.charAt(0) == LRE && str.charAt(str.length() - 1) == PDF) >- return str; >- >- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >- if (!env.isProcessingNeeded()) >- return str; >- // do not process a string if all the following conditions are true: >- // a) it has no RTL characters >- // b) it starts with a LTR character >- // c) it ends with a LTR character or a digit >- boolean isStringBidi = false; >- int strLength = str.length(); >- char c; >- for (int i = 0; i < strLength; i++) { >- c = str.charAt(i); >- if (((c >= 0x05d0) && (c <= 0x07b1)) || ((c >= 0xfb1d) && (c <= 0xfefc))) { >- isStringBidi = true; >- break; >- } >- } >- while (!isStringBidi) { >- if (!Character.isLetter(str.charAt(0))) >- break; >- c = str.charAt(strLength - 1); >- if (!Character.isDigit(c) && !Character.isLetter(c)) >- break; >- return str; >- } >- >- if (separators == null) >- separators = defaultSeparators; >- >- // make sure that LRE/PDF are added around the string >- STextTypeHandler handler = new STextTypeHandler(separators); >- ISTextExpert expert = STextExpertFactory.getExpert(handler, env); >- return expert.leanToFullText(str); >- } >- >- /** >- * Processes a string that has a particular semantic meaning to render >- * it correctly on bidi locales. >- * @see #process(String) >- * @param str the text to process >- * @param handler a handler instance appropriate for the type of the structured text >- * @return the processed string >- */ >- public static String process(String str, STextTypeHandler handler) { >- if ((str == null) || (str.length() <= 1)) >- return str; >- >- // do not process a string that has already been processed. >- char c = str.charAt(0); >- if (((c == LRE) || (c == RLE)) && str.charAt(str.length() - 1) == PDF) >- return str; >- >- // make sure that LRE/PDF are added around the string >- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >- if (!env.isProcessingNeeded()) >- return str; >- ISTextExpert expert = STextExpertFactory.getExpert(handler, env); >- return expert.leanToFullText(str); >- } >- >- /** >- * Removes directional formatting characters in the given string. >- * @param str string with directional characters to remove >- * @return string without directional formatting characters >- */ >- public static String deprocess(String str) { >- if ((str == null) || (str.length() <= 1)) >- return str; >- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >- if (!env.isProcessingNeeded()) >- return str; >- >- StringBuffer buf = new StringBuffer(); >- int strLen = str.length(); >- for (int i = 0; i < strLen; i++) { >- char c = str.charAt(i); >- switch (c) { >- case LRM : >- continue; >- case LRE : >- continue; >- case PDF : >- continue; >- default : >- buf.append(c); >- } >- } >- return buf.toString(); >- } >- >- /** >- * Removes directional formatting characters in the given string. >- * @param str string with directional characters to remove >- * @param handler appropriate for the structured text >- * @return string without directional formatting characters >- */ >- public static String deprocess(String str, STextTypeHandler handler) { >- if ((str == null) || (str.length() <= 1)) >- return str; >- >- // make sure that LRE/PDF are added around the string >- STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >- if (!env.isProcessingNeeded()) >- return str; >- ISTextExpert expert = STextExpertFactory.getExpert(handler, env); >- return expert.fullToLeanText(str); >- } >- >-} >diff --git src/org/eclipse/equinox/bidi/STextProcessorFactory.java src/org/eclipse/equinox/bidi/STextProcessorFactory.java >new file mode 0 >index 0000000..1887b08 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/STextProcessorFactory.java >@@ -0,0 +1,120 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi; >+ >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+import org.eclipse.equinox.bidi.internal.STextTypesCollector; >+ >+/** >+ * This class provides access to registered structured text processors. >+ * >+ * @noinstantiate This class is not intended to be instantiated by clients. >+ */ >+final public class STextProcessorFactory { >+ >+ /** >+ * Structured text processor for property file statements. It expects the following format: >+ * <pre> >+ * name=value >+ * </pre> >+ */ >+ public static final String PROPERTY = "property"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for compound names. It expects text to be made of one or more >+ * parts separated by underscores: >+ * <pre> >+ * part1_part2_part3 >+ * </pre> >+ */ >+ public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for comma-delimited lists, such as: >+ * <pre> >+ * part1,part2,part3 >+ * </pre> >+ */ >+ public static final String COMMA_DELIMITED = "comma"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for strings with the following format: >+ * <pre> >+ * system(user) >+ * </pre> >+ */ >+ public static final String SYSTEM_USER = "system"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for directory and file paths. >+ */ >+ public static final String FILE = "file"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for e-mail addresses. >+ */ >+ public static final String EMAIL = "email"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for URLs. >+ */ >+ public static final String URL = "url"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for regular expressions, possibly spanning multiple lines. >+ */ >+ public static final String REGEXP = "regex"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for XPath expressions. >+ */ >+ public static final String XPATH = "xpath"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for Java code, possibly spanning multiple lines. >+ */ >+ public static final String JAVA = "java"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for SQL statements, possibly spanning multiple lines. >+ */ >+ public static final String SQL = "sql"; //$NON-NLS-1$ >+ >+ /** >+ * Structured text processor for arithmetic expressions, possibly with a RTL base direction. >+ */ >+ public static final String RTL_ARITHMETIC = "math"; //$NON-NLS-1$ >+ >+ /** >+ * Prevents instantiation >+ */ >+ private STextProcessorFactory() { >+ // placeholder >+ } >+ >+ /** >+ * Retrieve all IDs of registered structured text processors. >+ * @return an array of text processor IDs. >+ */ >+ static public String[] getAllProcessorIDs() { >+ return STextTypesCollector.getInstance().getTypes(); >+ } >+ >+ /** >+ * Obtain a structured text processor of a given type. >+ * @param id string identifying processor >+ * @return a processor of the required type, or <code>null</code> if the type is unknown >+ */ >+ static public STextProcessor getProcessor(String id) { >+ return STextTypesCollector.getInstance().getProcessor(id); >+ } >+ >+} >diff --git src/org/eclipse/equinox/bidi/STextStringRecord.java src/org/eclipse/equinox/bidi/STextStringRecord.java >index 60d48d8..f28bd6b 100644 >--- src/org/eclipse/equinox/bidi/STextStringRecord.java >+++ src/org/eclipse/equinox/bidi/STextStringRecord.java >@@ -25,7 +25,7 @@ > * 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 handler which is appropriate to handle it. >+ * string, and by the processor which is appropriate to handle it. > */ > public class STextStringRecord { > /** >@@ -57,8 +57,8 @@ > // reference to the recorded string > private String string; > >- // reference to the handlers of the STT segments in the recorded string >- private String[] handlers; >+ // reference to the processors of the STT segments in the recorded string >+ private String[] processors; > > // reference to the boundaries of the STT segments in the recorded string > // (entries 0, 2, 4, ... are start offsets; entries 1, 3, 5, ... are >@@ -74,7 +74,7 @@ > > /** > * Record a string in the pool. The caller must specify the number >- * of segments in the record (at least 1), and the handler, starting >+ * of segments in the record (at least 1), and the processor, starting > * and ending offsets for the first segment. > * > * @param string the string to record. >@@ -82,9 +82,9 @@ > * @param segmentCount number of segments allowed in this string. > * This number must be >= 1. > * >- * @param handler the handler appropriate to handle the type >+ * @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 handler instances, or it may be an instance >+ * It may be one of the pre-defined processor instances, or it may be an instance > * created by a plug-in or by the application. > * > * @param start offset in the string of the starting character of the first >@@ -102,7 +102,7 @@ > * if <code>segmentCount</code> is less than 1. > * @throws also the same exceptions as {@link #addSegment addSegment}. > */ >- public static STextStringRecord addRecord(String string, int segmentCount, String handlerID, int start, int limit) { >+ public static STextStringRecord addRecord(String string, int segmentCount, String processorID, int start, int limit) { > if (string == null) > throw new IllegalArgumentException("The string argument must not be null!"); //$NON-NLS-1$ > if (segmentCount < 1) >@@ -124,24 +124,24 @@ > } > hashArray[last] = string.hashCode(); > for (int i = 0; i < record.usedSegmentCount; i++) >- record.handlers[i] = null; >+ record.processors[i] = null; > if (segmentCount > record.totalSegmentCount) { >- record.handlers = new String[segmentCount]; >+ record.processors = new String[segmentCount]; > record.boundaries = new short[segmentCount * 2]; > record.totalSegmentCount = segmentCount; > } > record.usedSegmentCount = 0; > record.string = string; >- record.addSegment(handlerID, start, limit); >+ record.addSegment(processorID, start, limit); > return record; > } > > /** > * Add a second or further segment to a record. > * >- * @param handler the handler appropriate to handle the type >+ * @param processor the processor appropriate to handle the type > * of structured text present in this segment. >- * It may be one of the pre-defined handler instances, or it may be an instance >+ * It may be one of the pre-defined processor instances, or it may be an instance > * created by a plug-in or by the application. > * > * @param start offset in the string of the starting character of the >@@ -151,7 +151,7 @@ > * greater than the <code>start</code> argument and not greater > * than the length of the string. > * >- * @throws IllegalArgumentException if <code>handler</code> is null, >+ * @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 >@@ -159,16 +159,16 @@ > * in the call to {@link #addRecord addRecord} which created > * the STextStringRecord instance. > */ >- public void addSegment(String handlerID, int start, int limit) { >- if (handlerID == null) >- throw new IllegalArgumentException("The handler argument must not be null!"); //$NON-NLS-1$ >+ public void addSegment(String processorID, int start, int limit) { >+ if (processorID == null) >+ throw new IllegalArgumentException("The processor argument must not be null!"); //$NON-NLS-1$ > if (start < 0 || start >= string.length()) > throw new IllegalArgumentException("The start position must be at least 0 and less than the length of the string!"); //$NON-NLS-1$ > 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$ >- handlers[usedSegmentCount] = handlerID; >+ processors[usedSegmentCount] = processorID; > boundaries[usedSegmentCount * 2] = (short) start; > boundaries[usedSegmentCount * 2 + 1] = (short) limit; > usedSegmentCount++; >@@ -184,8 +184,8 @@ > * records this string.<br> > * Once a record has been found, the number of its segments can > * be retrieved using {@link #getSegmentCount getSegmentCount}, >- * its handler can >- * be retrieved using {@link #getHandler getHandler}, >+ * its processor can >+ * be retrieved using {@link #getProcessor getProcessor}, > * its starting offset can > * be retrieved using {@link #getStart getStart}, > * its ending offset can >@@ -236,7 +236,7 @@ > } > > /** >- * Retrieve the handler of a given segment. >+ * 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 >@@ -244,7 +244,7 @@ > * in the call to {@link #addRecord addRecord} which created > * the STextStringRecord instance. > * >- * @return the handler to handle the structured text in the segment >+ * @return the processor to handle the structured text in the segment > * specified by <code>segmentNumber</code>. > * > * @throws IllegalArgumentException if <code>segmentNumber</code> >@@ -252,9 +252,9 @@ > * > * @see #getSegmentCount > */ >- public String getHandler(int segmentNumber) { >+ public String getProcessor(int segmentNumber) { > checkSegmentNumber(segmentNumber); >- return handlers[segmentNumber]; >+ return processors[segmentNumber]; > } > > /** >@@ -315,7 +315,7 @@ > if (record == null) > continue; > record.boundaries = null; >- record.handlers = null; >+ record.processors = null; > record.totalSegmentCount = 0; > record.usedSegmentCount = 0; > recordRefs[i].clear(); >diff --git src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java >deleted file mode 100644 >index 8525b9b..0000000 100644 >--- src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java >+++ /dev/null >@@ -1,120 +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; >- >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >-import org.eclipse.equinox.bidi.internal.STextTypesCollector; >- >-/** >- * This class provides access to registered structured text handlers. >- * >- * @noinstantiate This class is not intended to be instantiated by clients. >- */ >-final public class STextTypeHandlerFactory { >- >- /** >- * Structured text handler for property file statements. It expects the following format: >- * <pre> >- * name=value >- * </pre> >- */ >- public static final String PROPERTY = "property"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for compound names. It expects text to be made of one or more >- * parts separated by underscores: >- * <pre> >- * part1_part2_part3 >- * </pre> >- */ >- public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for comma-delimited lists, such as: >- * <pre> >- * part1,part2,part3 >- * </pre> >- */ >- public static final String COMMA_DELIMITED = "comma"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for strings with the following format: >- * <pre> >- * system(user) >- * </pre> >- */ >- public static final String SYSTEM_USER = "system"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for directory and file paths. >- */ >- public static final String FILE = "file"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for e-mail addresses. >- */ >- public static final String EMAIL = "email"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for URLs. >- */ >- public static final String URL = "url"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for regular expressions, possibly spanning multiple lines. >- */ >- public static final String REGEXP = "regex"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for XPath expressions. >- */ >- public static final String XPATH = "xpath"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for Java code, possibly spanning multiple lines. >- */ >- public static final String JAVA = "java"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for SQL statements, possibly spanning multiple lines. >- */ >- public static final String SQL = "sql"; //$NON-NLS-1$ >- >- /** >- * Structured text handler for arithmetic expressions, possibly with a RTL base direction. >- */ >- public static final String RTL_ARITHMETIC = "math"; //$NON-NLS-1$ >- >- /** >- * Prevents instantiation >- */ >- private STextTypeHandlerFactory() { >- // placeholder >- } >- >- /** >- * Retrieve all IDs of registered structured text handlers. >- * @return an array of text handler IDs. >- */ >- static public String[] getAllHandlerIDs() { >- return STextTypesCollector.getInstance().getTypes(); >- } >- >- /** >- * Obtain a structured text handler of a given type. >- * @param id string identifying handler >- * @return a handler of the required type, or <code>null</code> if the type is unknown >- */ >- static public STextTypeHandler getHandler(String id) { >- return STextTypesCollector.getInstance().getHandler(id); >- } >- >-} >diff --git src/org/eclipse/equinox/bidi/STextUtil.java src/org/eclipse/equinox/bidi/STextUtil.java >new file mode 0 >index 0000000..a98e8e9 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/STextUtil.java >@@ -0,0 +1,269 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi; >+ >+import org.eclipse.equinox.bidi.advanced.*; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+ >+/** >+ * This class provides a number of convenience functions facilitating the >+ * processing of structured text. >+ * >+ * @noextend This class is not intended to be subclassed by clients. >+ * @noinstantiate This class is not intended to be instantiated by clients. >+ * >+ * @author Matitiahu Allouche >+ */ >+public final class STextUtil { >+ >+ /** >+ * The default set of separators used to segment a string: dot, colon, slash, backslash. >+ */ >+ public static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$ >+ >+ // left to right mark >+ private static final char LRM = '\u200e'; >+ >+ // left to right mark >+ private static final char RLM = '\u200f'; >+ >+ // left to right embedding >+ private static final char LRE = '\u202a'; >+ >+ // right to left embedding >+ private static final char RLE = '\u202b'; >+ >+ // pop directional format >+ private static final char PDF = '\u202c'; >+ >+ /** >+ * Prevents instantiation. >+ */ >+ private STextUtil() { >+ // empty >+ } >+ >+ /** >+ * This method adds directional marks to the given text before the characters >+ * specified in the given array of offsets. It can be used to add a prefix and/or >+ * a suffix of directional formatting characters. >+ * <p> >+ * The directional marks will be LRMs for structured text strings with LTR base >+ * direction and RLMs for strings with RTL base direction. >+ * </p><p> >+ * If necessary, leading and trailing directional markers (LRE, RLE and PDF) can >+ * be added depending on the value of the <code>affix</code> argument. >+ * </p> >+ * @see ISTextExpert#leanBidiCharOffsets(String) >+ * >+ * @param text the structured text string >+ * @param offsets an array of offsets to characters in <code>text</code> >+ * before which an LRM or RLM will be inserted. >+ * The array must be sorted in ascending order without duplicates. >+ * This argument may be <code>null</code> if there are no marks to add. >+ * @param direction the base direction of the structured text. >+ * It must be one of the values {@link STextDirection#DIR_LTR}, or >+ * {@link STextDirection#DIR_RTL}. >+ * @param affix specifies if a prefix and a suffix should be added to >+ * the result >+ * @return a string corresponding to the source <code>text</code> with >+ * directional marks (LRMs or RLMs) added at the specified offsets, >+ * and directional formatting characters (LRE, RLE, PDF) added >+ * as prefix and suffix if so required. >+ */ >+ public static String insertMarks(String text, int[] offsets, int direction, boolean affix) { >+ int textLen = text.length(); >+ if (textLen == 0) >+ return ""; //$NON-NLS-1$ >+ >+ String curPrefix, curSuffix, full; >+ char curMark, c; >+ char[] fullChars; >+ if (direction == STextDirection.DIR_LTR) { >+ curMark = LRM; >+ curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$ >+ curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$ >+ } else { >+ curMark = RLM; >+ curPrefix = "\u202b\u200f"; /* RLE+RLM *///$NON-NLS-1$ >+ curSuffix = "\u200f\u202c"; /* RLM+PDF *///$NON-NLS-1$ >+ } >+ // add marks at offsets >+ if ((offsets != null) && (offsets.length > 0)) { >+ int offLen = offsets.length; >+ fullChars = new char[textLen + offLen]; >+ int added = 0; >+ for (int i = 0, j = 0; i < textLen; i++) { >+ c = text.charAt(i); >+ if ((j < offLen) && (i == offsets[j])) { >+ fullChars[i + added] = curMark; >+ added++; >+ j++; >+ } >+ fullChars[i + added] = c; >+ } >+ full = new String(fullChars); >+ } else { >+ full = text; >+ } >+ if (affix) >+ return curPrefix + full + curSuffix; >+ return full; >+ } >+ >+ /** >+ * Process the given text and return a string with appropriate >+ * directional formatting characters. This is equivalent to calling >+ * {@link #process(String str, String separators)} with the default >+ * set of separators. >+ * <p> >+ * The processing adds directional formatting characters so that presentation >+ * using the Unicode Bidirectional Algorithm will provide the expected result. >+ * The text is segmented according to the provided separators. >+ * Each segment has the Unicode Bidi Algorithm applied to it, >+ * but as a whole, the string is oriented left to right. >+ * </p><p> >+ * For example, a file path such as <tt>d:\myfolder\FOLDER\MYFILE.java</tt> >+ * (where capital letters indicate RTL text) should render as >+ * <tt>d:\myfolder\REDLOF\ELIFYM.java</tt>. >+ * </p> >+ * @param str the text to be processed >+ * @return the processed string >+ */ >+ public static String process(String str) { >+ return process(str, defaultSeparators); >+ } >+ >+ /** >+ * Process a string that has a particular semantic meaning to render >+ * it correctly on bidi locales. >+ * @see #process(String) >+ * @param str the text to process >+ * @param separators separators by which the string will be segmented >+ * @return the processed string >+ */ >+ public static String process(String str, String separators) { >+ if ((str == null) || (str.length() <= 1)) >+ return str; >+ >+ // do not process a string that has already been processed. >+ if (str.charAt(0) == LRE && str.charAt(str.length() - 1) == PDF) >+ return str; >+ >+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >+ if (!env.isProcessingNeeded()) >+ return str; >+ // do not process a string if all the following conditions are true: >+ // a) it has no RTL characters >+ // b) it starts with a LTR character >+ // c) it ends with a LTR character or a digit >+ boolean isStringBidi = false; >+ int strLength = str.length(); >+ char c; >+ for (int i = 0; i < strLength; i++) { >+ c = str.charAt(i); >+ if (((c >= 0x05d0) && (c <= 0x07b1)) || ((c >= 0xfb1d) && (c <= 0xfefc))) { >+ isStringBidi = true; >+ break; >+ } >+ } >+ while (!isStringBidi) { >+ if (!Character.isLetter(str.charAt(0))) >+ break; >+ c = str.charAt(strLength - 1); >+ if (!Character.isDigit(c) && !Character.isLetter(c)) >+ break; >+ return str; >+ } >+ >+ if (separators == null) >+ separators = defaultSeparators; >+ >+ // make sure that LRE/PDF are added around the string >+ STextProcessor processor = new STextProcessor(separators); >+ ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env); >+ return processorNew.leanToFullText(str); >+ } >+ >+ /** >+ * Processes a string that has a particular semantic meaning to render >+ * it correctly on bidi locales. >+ * @see #process(String) >+ * @param str the text to process >+ * @param processor a processor instance appropriate for the type of the structured text >+ * @return the processed string >+ */ >+ public static String process(String str, STextProcessor processor) { >+ if ((str == null) || (str.length() <= 1)) >+ return str; >+ >+ // do not process a string that has already been processed. >+ char c = str.charAt(0); >+ if (((c == LRE) || (c == RLE)) && str.charAt(str.length() - 1) == PDF) >+ return str; >+ >+ // make sure that LRE/PDF are added around the string >+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >+ if (!env.isProcessingNeeded()) >+ return str; >+ ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env); >+ return processorNew.leanToFullText(str); >+ } >+ >+ /** >+ * Removes directional formatting characters in the given string. >+ * @param str string with directional characters to remove >+ * @return string without directional formatting characters >+ */ >+ public static String deprocess(String str) { >+ if ((str == null) || (str.length() <= 1)) >+ return str; >+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >+ if (!env.isProcessingNeeded()) >+ return str; >+ >+ StringBuffer buf = new StringBuffer(); >+ int strLen = str.length(); >+ for (int i = 0; i < strLen; i++) { >+ char c = str.charAt(i); >+ switch (c) { >+ case LRM : >+ continue; >+ case LRE : >+ continue; >+ case PDF : >+ continue; >+ default : >+ buf.append(c); >+ } >+ } >+ return buf.toString(); >+ } >+ >+ /** >+ * Removes directional formatting characters in the given string. >+ * @param str string with directional characters to remove >+ * @param processor appropriate for the structured text >+ * @return string without directional formatting characters >+ */ >+ public static String deprocess(String str, STextProcessor processor) { >+ if ((str == null) || (str.length() <= 1)) >+ return str; >+ >+ // make sure that LRE/PDF are added around the string >+ STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); >+ if (!env.isProcessingNeeded()) >+ return str; >+ ISTextExpert processorNew = STextExpertFactory.getExpert(processor, env); >+ return processorNew.fullToLeanText(str); >+ } >+ >+} >diff --git src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java >index e1b986f..996be6e 100644 >--- src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java >+++ src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java >@@ -14,10 +14,10 @@ > * For a general introduction to structured text, see > * {@link <a href="package-summary.html"> the package documentation</a>}. > * <p> >- * Several common handlers are included in <b>STextEngine</b>. For handlers >- * supplied by other packages, a handler instance can be obtained using the >- * {@link org.eclipse.equinox.bidi.STextTypeHandlerFactory#getHandler} >- * method for the registered handlers, or by instantiating a private handler. >+ * Several common processors are included in <b>STextEngine</b>. For processors >+ * supplied by other packages, a processor instance can be obtained using the >+ * {@link org.eclipse.equinox.bidi.STextProcessorFactory#getProcessor} >+ * method for the registered processors, or by instantiating a private processor. > * </p><p> > * Most of the methods in this class have a <code>text</code> > * argument which may be just a part of a larger body of text. >@@ -100,7 +100,7 @@ > * Add directional formatting characters to a structured text > * to ensure correct presentation. > * >- * @param handler the handler applicable to the text. If <code>null</code>, >+ * @param processor the processor applicable to the text. If <code>null</code>, > * the method returns unmodified text. > * > * @param environment a bidi environment. If <code>null</code>, the default environment >@@ -122,11 +122,11 @@ > * Given a <i>lean</i> string, compute the positions of each of its > * characters within the corresponding <i>full</i> string. > * >- * @param handler designates a handler instance. If <code>null</code>, this >+ * @param processor designates a processor instance. If <code>null</code>, this > * method returns an identity map. > * > * @param environment specifies an environment whose characteristics may affect >- * the handler's behavior. If <code>null</code>, the default environment is used. >+ * the processor's behavior. If <code>null</code>, the default environment is used. > * > * @param text is the structured text string. > * >@@ -151,10 +151,10 @@ > * depending on the {@link STextEnvironment#getOrientation orientation} of the > * GUI component used for display are not reflected in this method. > * </p> >- * @param handler designates a handler instance >+ * @param processor designates a processor instance > * > * @param environment specifies an environment whose characteristics may affect >- * the handler's behavior. If <code>null</code>, the default environment is used. >+ * the processor's behavior. If <code>null</code>, the default environment is used. > * > * @param text is the structured text string > * >@@ -173,10 +173,10 @@ > * Remove directional formatting characters which were added to a > * structured text string to ensure correct presentation. > * >- * @param handler designates a handler instance >+ * @param processor designates a processor instance > * > * @param environment specifies an environment whose characteristics may affect >- * the handler's behavior. If <code>null</code>, the default environment is used. >+ * the processor's behavior. If <code>null</code>, the default environment is used. > * > * @param text is the structured text string including directional formatting characters. > * >@@ -195,10 +195,10 @@ > * Given a <i>full</i> string, compute the positions of each of its > * characters within the corresponding <i>lean</i> string. > * >- * @param handler designates a handler instance >+ * @param processor designates a processor instance > * > * @param environment specifies an environment whose characteristics may affect >- * the handler's behavior. If <code>null</code>, the default environment is used. >+ * the processor's behavior. If <code>null</code>, the default environment is used. > * > * @param text is the structured text string including directional formatting characters. > * >@@ -225,10 +225,10 @@ > * or suffixed depending on the {@link STextEnvironment#getOrientation orientation} > * of the GUI component used for display. > * </p> >- * @param handler designates a handler instance >+ * @param processor designates a processor instance > * > * @param environment specifies an environment whose characteristics may affect >- * the handler's behavior. If <code>null</code>, the default environment is used. >+ * the processor's behavior. If <code>null</code>, the default environment is used. > * > * @param text is the structured text string including directional formatting characters > * >@@ -248,10 +248,10 @@ > * whether the text contains Arabic or Hebrew words. If the text contains both, > * the first Arabic or Hebrew letter in the text determines which is the governing script. > * >- * @param handler designates a handler instance >+ * @param processor designates a processor instance > * > * @param environment specifies an environment whose characteristics may affect >- * the handler's behavior. If <code>null</code>, the default environment is used. >+ * the processor's behavior. If <code>null</code>, the default environment is used. > * > * @param text is the structured text string > * >diff --git src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java >index cebf2fd..f69a48f 100644 >--- src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java >+++ src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java >@@ -17,7 +17,7 @@ > public int getState(); > > /** >- * Resets non-shared expert state to initial. >+ * Resets non-shared processor state to initial. > */ > public void resetState(); > >diff --git src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java >index 220de73..3518830 100644 >--- src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java >+++ src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java >@@ -12,9 +12,10 @@ > > import java.util.HashMap; > import java.util.Map; >-import org.eclipse.equinox.bidi.STextTypeHandlerFactory; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >-import org.eclipse.equinox.bidi.internal.STextImpl; >+import org.eclipse.equinox.bidi.STextProcessorFactory; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+import org.eclipse.equinox.bidi.internal.STextExpertImpl; >+import org.eclipse.equinox.bidi.internal.STextExpertMultipassImpl; > > final public class STextExpertFactory { > >@@ -35,49 +36,49 @@ > > static public ISTextExpert getExpert() { > if (defaultExpert == null) { >- STextTypeHandler handler = new STextTypeHandler(defaultSeparators); >- defaultExpert = new STextImpl(handler, STextEnvironment.DEFAULT, null); >+ STextProcessor descriptor = new STextProcessor(defaultSeparators); >+ defaultExpert = new STextExpertImpl(descriptor, STextEnvironment.DEFAULT); > } > return defaultExpert; > } > > static public ISTextExpert getExpert(String type) { >- ISTextExpert expert; >+ ISTextExpert processor; > synchronized (sharedDefaultExperts) { >- expert = (ISTextExpert) sharedDefaultExperts.get(type); >- if (expert == null) { >- STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type); >- if (handler == null) >+ processor = (ISTextExpert) sharedDefaultExperts.get(type); >+ if (processor == null) { >+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type); >+ if (descriptor == null) > return null; >- expert = new STextImpl(handler, STextEnvironment.DEFAULT, null); >- sharedDefaultExperts.put(type, expert); >+ processor = new STextExpertImpl(descriptor, STextEnvironment.DEFAULT); >+ sharedDefaultExperts.put(type, processor); > } > } >- return expert; >+ return processor; > } > > static public ISTextExpert getExpert(String type, STextEnvironment environment) { >- ISTextExpert expert; >+ ISTextExpert processor; > synchronized (sharedExperts) { >- Map experts = (Map) sharedExperts.get(type); >- if (experts == null) { >- experts = new HashMap(); // environment -> expert >- sharedExperts.put(type, experts); >+ Map processors = (Map) sharedExperts.get(type); >+ if (processors == null) { >+ processors = new HashMap(); // environment -> processor >+ sharedExperts.put(type, processors); > } >- expert = (ISTextExpert) experts.get(environment); >- if (expert == null) { >- STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type); >- if (handler == null) >+ processor = (ISTextExpert) processors.get(environment); >+ if (processor == null) { >+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type); >+ if (descriptor == null) > return null; >- expert = new STextImpl(handler, environment, null); >- experts.put(type, expert); >+ processor = new STextExpertImpl(descriptor, environment); >+ processors.put(type, processor); > } > } >- return expert; >+ return processor; > } > >- static public ISTextExpert getExpert(STextTypeHandler handler, STextEnvironment environment) { >- return new STextImpl(handler, environment, new int[1]); >+ static public ISTextExpert getExpert(STextProcessor descriptor, STextEnvironment environment) { >+ return new STextExpertImpl(descriptor, environment); > } > > static public ISTextExpertStateful getPrivateExpert(String type) { >@@ -85,10 +86,10 @@ > } > > static public ISTextExpertStateful getPrivateExpert(String type, STextEnvironment environment) { >- STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type); >- if (handler == null) >+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type); >+ if (descriptor == null) > return null; >- return new STextImpl(handler, environment, new int[1]); >+ return new STextExpertMultipassImpl(descriptor, environment); > } > > } >diff --git src/org/eclipse/equinox/bidi/custom/STextCharTypes.java src/org/eclipse/equinox/bidi/custom/STextCharTypes.java >index ba1f0b7..f74bd7b 100644 >--- src/org/eclipse/equinox/bidi/custom/STextCharTypes.java >+++ src/org/eclipse/equinox/bidi/custom/STextCharTypes.java >@@ -35,32 +35,32 @@ > > private static final int CHARTYPES_ADD = 2; > >- final protected STextTypeHandler handler; >+ final protected STextProcessor processor; > final protected STextEnvironment environment; > final protected String text; > > // 1 byte for each char in text > private byte[] types; > >- // structured text direction. -1 means not yet computed; -2 means within handler.getDirection >+ // structured text direction. -1 means not yet computed; -2 means within processor.getDirection > private int direction = -1; > > /** > * Constructor > * >- * @param handler is the handler handling this occurrence of >+ * @param processor is the processor handling this occurrence of > * structured text. > * > * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >+ * 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 text whose characters are analyzed. > */ >- public STextCharTypes(STextTypeHandler handler, STextEnvironment environment, String text) { >- this.handler = handler; >+ public STextCharTypes(STextProcessor processor, STextEnvironment environment, String text) { >+ this.processor = processor; > this.environment = environment; > this.text = text; > types = new byte[text.length()]; >@@ -68,7 +68,7 @@ > > public int getDirection() { > if (direction < 0) >- direction = handler.getDirection(environment, text, this); >+ direction = processor.getDirection(environment, text, this); > return direction; > } > >@@ -96,10 +96,10 @@ > byte charType = Character.getDirectionality(text.charAt(index)); > if (charType == B) { > if (direction < 0) { >- if (direction < -1) // called by handler.getDirection >+ if (direction < -1) // called by processor.getDirection > return charType; // avoid infinite recursion >- direction = -2; // signal we go within handler.getDirection >- direction = handler.getDirection(environment, text, this); >+ direction = -2; // signal we go within processor.getDirection >+ direction = processor.getDirection(environment, text, this); > } > charType = (direction == STextEnvironment.ORIENT_RTL) ? R : L; > } >@@ -125,7 +125,7 @@ > * be displayed. > * > * @param envir is the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >+ * the processor. This parameter may be specified as > * <code>null</code>, in which case the > * {@link STextEnvironment#DEFAULT DEFAULT} > * environment should be assumed. >diff --git src/org/eclipse/equinox/bidi/custom/STextOffsets.java src/org/eclipse/equinox/bidi/custom/STextOffsets.java >index 4ac9270..5358ad5 100644 >--- src/org/eclipse/equinox/bidi/custom/STextOffsets.java >+++ src/org/eclipse/equinox/bidi/custom/STextOffsets.java >@@ -67,7 +67,7 @@ > /** > * Insert an offset value in the offset array so that the array > * stays in ascending order. >- * @param procData is a group of data accessible to handlers. >+ * @param procData is a group of data accessible to processors. > * @param offset is the value to insert. > */ > public void insertOffset(STextCharTypes charTypes, int offset) { >diff --git src/org/eclipse/equinox/bidi/custom/STextProcessor.java src/org/eclipse/equinox/bidi/custom/STextProcessor.java >new file mode 0 >index 0000000..e760eff 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/custom/STextProcessor.java >@@ -0,0 +1,416 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.custom; >+ >+import org.eclipse.equinox.bidi.STextDirection; >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.advanced.ISTextExpert; >+import org.eclipse.equinox.bidi.internal.STextImpl; >+ >+/** >+ * Generic processor to be used as superclass (base class) >+ * for specific structured text processors. >+ * <p> >+ * Here are some guidelines about how to write structured text >+ * processors. >+ * <ul> >+ * <li>Processor instances may be accessed simultaneously by >+ * several threads. They should have no instance variables.</li> >+ * <li>The common logic uses processor methods to query the >+ * characteristics of the specific processor: >+ * <ul> >+ * <li>the separators which separate the structured text into >+ * tokens. See {@link #getSeparators getSeparators}.</li> >+ * <li>the direction which governs the display of tokens >+ * one after the other. See {@link #getDirection getDirection}.</li> >+ * <li>the number of special cases which need to be handled by >+ * code specific to that processor. >+ * See {@link #getSpecialsCount getSpecialsCount}.</li> >+ * </ul></li> >+ * <li>Before starting deeper analysis of the submitted text, the common >+ * logic gives to the processor a chance to shorten the processus by >+ * invoking its {@link #skipProcessing skipProcessing} method.</li> >+ * <li>The common logic then analyzes the text to segment it into tokens >+ * according to the appearance of separators (as retrieved using >+ * {@link #getSeparators getSeparators}).</li> >+ * <li>If the processor indicated a positive number of special cases as >+ * return value from its {@link #getSpecialsCount getSpecialsCount} >+ * method, the common logic will repeatedly invoke the processor's >+ * {@link #indexOfSpecial indexOfSpecial} method to let it signal the >+ * presence of special strings which may further delimit the source text.</li> >+ * <li>When such a special case is signalled by the processor, the common >+ * logic will call the processor's {@link #processSpecial processSpecial} >+ * method to give it the opportunity to handle it as needed. Typical >+ * actions that the processor may perform are to add directional marks >+ * inconditionally (by calling {@link #insertMark insertMark} or >+ * conditionally (by calling {@link #processSeparator processSeparator}).</li> >+ * </ul> >+ * >+ * @author Matitiahu Allouche >+ */ >+public class STextProcessor { >+ >+ final private String separators; >+ >+ /** >+ * Creates a new instance of the STextProcessor class. >+ */ >+ public STextProcessor() { >+ separators = ""; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Creates a new instance of the STextProcessor class. >+ * @param separators string consisting of characters that split the text into fragments >+ */ >+ public STextProcessor(String separators) { >+ this.separators = separators; >+ } >+ >+ /** >+ * Locate occurrences of special strings within a structured text >+ * and return their indexes one after the other in successive calls. >+ * <p> >+ * This method is called repeatedly if the number of special cases >+ * returned by {@link #getSpecialsCount} is greater than zero. >+ * </p><p> >+ * A processor handling special cases must override this method. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @param text is the structured text string before >+ * addition of any directional formatting characters. >+ * >+ * @param charTypes is a parameter received by <code>indexOfSpecial</code> >+ * uniquely to be used as argument for calls to methods which >+ * need it. >+ * >+ * @param offsets is a parameter received by <code>indexOfSpecial</code> >+ * uniquely to be used as argument for calls to methods which >+ * need it. >+ * >+ * @param caseNumber number of the special case to locate. >+ * This number varies from 1 to the number of special cases >+ * returned by {@link #getSpecialsCount getSpecialsCount} >+ * for this processor. >+ * The meaning of this number is internal to the class >+ * implementing <code>indexOfSpecial</code>. >+ * >+ * @param fromIndex the index within <code>text</code> to start >+ * the search from. >+ * >+ * @return the position where the start of the special case >+ * corresponding to <code>caseNumber</code> was located. >+ * The method must return the first occurrence of whatever >+ * identifies the start of the special case starting from >+ * <code>fromIndex</code>. The method does not have to check if >+ * this occurrence appears within the scope of another special >+ * case (e.g. a comment starting delimiter within the scope of >+ * a literal or vice-versa). >+ * <br>If no occurrence is found, the method must return -1. >+ * >+ * @throws IllegalStateException If not overridden, this method throws an >+ * <code>IllegalStateException</code>. This is appropriate behavior >+ * (and does not need to be overridden) for processors whose >+ * number of special cases is zero, which means that >+ * <code>indexOfSpecial</code> should never be called for them. >+ */ >+ public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) { >+ // This method must be overridden by all subclasses with special cases. >+ throw new IllegalStateException("A processor with specialsCount > 0 must have an indexOfSpecial() method."); //$NON-NLS-1$ >+ } >+ >+ /** >+ * This method handles special cases specific to this processor. >+ * It is called when a special case occurrence >+ * is located by {@link #indexOfSpecial}. >+ * <p> >+ * If a special processing cannot be completed within a current call to >+ * <code>processSpecial</code> (for instance, a comment has been started >+ * in the current line but its end appears in a following line), >+ * <code>processSpecial</code> should specify a final state by >+ * putting its value in the first element of the <code>state</code> >+ * parameter. >+ * The meaning of this state is internal to the processor. >+ * On a later call, <code>processSpecial</code> will be called with that value >+ * for parameter <code>caseNumber</code> and <code>-1</code> for parameter >+ * <code>separLocation</code> and should perform whatever initializations are required >+ * depending on the state. >+ * </p><p> >+ * A processor handling special cases (with a number of >+ * special cases greater than zero) must override this method. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @param text is the structured text string before >+ * addition of any directional formatting characters. >+ * >+ * @param charTypes is a parameter received by <code>processSpecial</code> >+ * uniquely to be used as argument for calls to methods which >+ * need it. >+ * >+ * @param offsets is a parameter received by <code>processSpecial</code> >+ * uniquely to be used as argument for calls to methods which >+ * need it. >+ * >+ * @param state is an integer array with at least one element. >+ * If the processor needs to signal the occurrence of a >+ * special case which must be passed to the next call to >+ * <code>leanToFullText</code> (for instance, a comment or a >+ * literal started but not closed in the current >+ * <code>text</code>), it must put a value in the first element >+ * of the <code>state</code> parameter. >+ * This number must be >= 1 and less or equal to the number of special >+ * cases returned by {@link #getSpecialsCount getSpecialsCount} >+ * by this processor. >+ * This number is passed back to the caller >+ * and should be specified as <code>state</code> argument >+ * in the next call to <code>leanToFullText</code> together >+ * with the continuation text. >+ * The meaning of this number is internal to the processor. >+ * >+ * @param caseNumber number of the special case to handle. >+ * >+ * @param separLocation the position returned by >+ * {@link #indexOfSpecial indexOfSpecial}. In calls to >+ * {@link ISTextExpert#leanToFullText leanToFullText} and other >+ * methods of {@link ISTextExpert} specifying a non-null >+ * <code>state</code> parameter, <code>processSpecial</code> is >+ * called when initializing the processing with the value of >+ * <code>caseNumber</code> equal to the value returned in the >+ * first element of <code>state</code> and the value of >+ * <code>separLocation</code> equal to <code>-1</code>. >+ * >+ * @return the position after the scope of the special case ends. >+ * For instance, the position after the end of a comment, >+ * the position after the end of a literal. >+ * <br>A value greater or equal to the length of <code>text</code> >+ * means that there is no further occurrence of this case in the >+ * current structured text. >+ * >+ * @throws IllegalStateException If not overridden, this method throws an >+ * <code>IllegalStateException</code>. This is appropriate behavior >+ * (and does not need to be overridden) for processors whose >+ * number of special cases is zero, which means that >+ * <code>processSpecial</code> should never be called for them. >+ */ >+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >+ // This method must be overridden by all subclasses with any special case. >+ throw new IllegalStateException("A processor with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$ >+ } >+ >+ /** >+ * This method can be called from within {@link #indexOfSpecial} or >+ * {@link #processSpecial} in extensions of <code>STextProcessor</code> >+ * to specify that a mark character must be added before the character >+ * at the specified position of the <i>lean</i> text when generating the >+ * <i>full</i> text. The mark character will be LRM for structured text >+ * with a LTR base direction, and RLM for structured text with RTL >+ * base direction. The mark character is not added physically by this >+ * method, but its position is noted and will be used when generating >+ * the <i>full</i> text. >+ * >+ * @param text is the structured text string received as >+ * parameter to <code>indexOfSpecial</code> or >+ * <code>processSpecial</code>. >+ * >+ * @param charTypes is a parameter received by <code>indexOfSpecial</code> >+ * or <code>processSpecial</code>, uniquely to be used as argument >+ * for calls to <code>insertMark</code> and other methods used >+ * by processors. >+ * >+ * @param offsets is a parameter received by <code>indexOfSpecial</code> >+ * or <code>processSpecial</code>, uniquely to be used as argument >+ * for calls to <code>insertMark</code> and other methods used >+ * by processors. >+ * >+ * @param offset position of the character in the <i>lean</i> text. >+ * It must be a non-negative number smaller than the length >+ * of the <i>lean</i> text. >+ * For the benefit of efficiency, it is better to insert >+ * multiple marks in ascending order of the offsets. >+ */ >+ public static final void insertMark(String text, STextCharTypes charTypes, STextOffsets offsets, int offset) { >+ offsets.insertOffset(charTypes, offset); >+ } >+ >+ /** >+ * This method can be called from within {@link #indexOfSpecial} or >+ * {@link #processSpecial} in extensions of <code>STextProcessor</code> to add >+ * a directional mark before a separator if needed for correct display, >+ * depending on the base direction of the text and on the class of the >+ * characters in the <i>lean</i> text preceding and following the separator itself. >+ * <p> >+ * The logic implemented in this method considers the text before >+ * <code>separLocation</code> and the text following it. If, and only if, >+ * a directional mark is needed to insure that the two parts of text >+ * will be laid out according to the base direction, a mark will be >+ * added when generating the <i>full</i> text. >+ * </p> >+ * @param text is the structured text string received as >+ * parameter to <code>indexOfSpecial</code> or >+ * <code>processSpecial</code>. >+ * >+ * @param charTypes is a parameter received by <code>indexOfSpecial</code> >+ * or <code>processSpecial</code>, uniquely to be used as argument >+ * for calls to <code>processSeparator</code> and other methods used >+ * by processors. >+ * >+ * @param offsets is a parameter received by <code>indexOfSpecial</code> >+ * or <code>processSpecial</code>, uniquely to be used as argument >+ * for calls to <code>processSeparator</code> and other methods used >+ * by processors. >+ * >+ * @param separLocation offset of the separator in the <i>lean</i> text. >+ * It must be a non-negative number smaller than the length >+ * of the <i>lean</i> text. >+ */ >+ public static final void processSeparator(String text, STextCharTypes charTypes, STextOffsets offsets, int separLocation) { >+ STextImpl.processSeparator(text, charTypes, offsets, separLocation); >+ } >+ >+ /** >+ * Indicate the separators to use for the current processor. >+ * This method is invoked before starting the processing. >+ * <p> >+ * If no separators are specified, this method returns an empty string. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @return a string grouping one-character separators which separate >+ * the structured text into tokens. >+ */ >+ public String getSeparators(STextEnvironment environment) { >+ return separators; >+ } >+ >+ /** >+ * Indicate the base text direction appropriate for an instance of structured text. >+ * This method is invoked before starting the processing. >+ * <p> >+ * If not overridden, this method returns <code>DIR_LTR</code>. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @param text is the structured text string to process. >+ * >+ * @return the base direction of the structured text. This direction >+ * may not be the same depending on the environment and on >+ * whether the structured text contains Arabic or Hebrew >+ * letters.<br> >+ * The value returned is either >+ * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}. >+ */ >+ public int getDirection(STextEnvironment environment, String text) { >+ return STextDirection.DIR_LTR; >+ } >+ >+ /** >+ * Indicate the base text direction appropriate for an instance of structured text. >+ * This method is invoked before starting the processing. >+ * <p> >+ * If not overridden, this method returns <code>DIR_LTR</code>. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @param text is the structured text string to process. >+ * >+ * @param charTypes is a parameter received uniquely to be used as argument >+ * for calls to <code>getCharType</code> and other methods used >+ * by processors. >+ * >+ * @return the base direction of the structured text. This direction >+ * may not be the same depending on the environment and on >+ * whether the structured text contains Arabic or Hebrew >+ * letters.<br> >+ * The value returned is either >+ * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}. >+ */ >+ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { >+ return STextDirection.DIR_LTR; >+ } >+ >+ /** >+ * Indicate the number of special cases handled by the current processor. >+ * This method is invoked before starting the processing. >+ * If the number returned is zero, {@link #indexOfSpecial} and >+ * {@link #processSpecial} will not be invoked. >+ * <p> >+ * If not overridden, this method returns <code>zero</code>. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @return the number of special cases for the associated processor. >+ * Special cases exist for some types of structured text >+ * processors. They are implemented by overriding methods >+ * {@link STextProcessor#indexOfSpecial} and {@link STextProcessor#processSpecial}. >+ * Examples of special cases are comments, literals, or >+ * anything which is not identified by a one-character separator. >+ * >+ */ >+ public int getSpecialsCount(STextEnvironment environment) { >+ return 0; >+ } >+ >+ /** >+ * Checks if there is a need for processing structured text. >+ * This method is invoked before starting the processing. If the >+ * processor returns <code>true</code>, no directional formatting >+ * characters are added to the <i>lean</i> text and the processing >+ * is shortened. >+ * <p> >+ * If not overridden, this method returns <code>false</code>. >+ * </p> >+ * @param environment the current environment, which may affect the behavior of >+ * the processor. This parameter may be specified as >+ * <code>null</code>, in which case the >+ * {@link STextEnvironment#DEFAULT DEFAULT} >+ * environment should be assumed. >+ * >+ * @param text is the structured text string to process. >+ * >+ * @param charTypes is a parameter received uniquely to be used as argument >+ * for calls to <code>getCharType</code> and other methods used >+ * by processors. >+ * >+ * @return a flag indicating if there is no need to process the structured >+ * text to add directional formatting characters. >+ * >+ */ >+ public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) { >+ return false; >+ } >+ >+} >diff --git src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java >deleted file mode 100644 >index 993033e..0000000 100644 >--- src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java >+++ /dev/null >@@ -1,416 +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.STextDirection; >-import org.eclipse.equinox.bidi.advanced.ISTextExpert; >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; >-import org.eclipse.equinox.bidi.internal.STextImpl; >- >-/** >- * Generic handler to be used as superclass (base class) >- * for specific structured text handlers. >- * <p> >- * Here are some guidelines about how to write structured text >- * handlers. >- * <ul> >- * <li>Handler instances may be accessed simultaneously by >- * several threads. They should have no instance variables.</li> >- * <li>The common logic uses handler methods to query the >- * characteristics of the specific handler: >- * <ul> >- * <li>the separators which separate the structured text into >- * tokens. See {@link #getSeparators getSeparators}.</li> >- * <li>the direction which governs the display of tokens >- * one after the other. See {@link #getDirection getDirection}.</li> >- * <li>the number of special cases which need to be handled by >- * code specific to that handler. >- * See {@link #getSpecialsCount getSpecialsCount}.</li> >- * </ul></li> >- * <li>Before starting deeper analysis of the submitted text, the common >- * logic gives to the handler a chance to shorten the processus by >- * invoking its {@link #skipProcessing skipProcessing} method.</li> >- * <li>The common logic then analyzes the text to segment it into tokens >- * according to the appearance of separators (as retrieved using >- * {@link #getSeparators getSeparators}).</li> >- * <li>If the handler indicated a positive number of special cases as >- * return value from its {@link #getSpecialsCount getSpecialsCount} >- * method, the common logic will repeatedly invoke the handler's >- * {@link #indexOfSpecial indexOfSpecial} method to let it signal the >- * presence of special strings which may further delimit the source text.</li> >- * <li>When such a special case is signalled by the handler, the common >- * logic will call the handler's {@link #processSpecial processSpecial} >- * method to give it the opportunity to handle it as needed. Typical >- * actions that the handler may perform are to add directional marks >- * inconditionally (by calling {@link #insertMark insertMark} or >- * conditionally (by calling {@link #processSeparator processSeparator}).</li> >- * </ul> >- * >- * @author Matitiahu Allouche >- */ >-public class STextTypeHandler { >- >- final private String separators; >- >- /** >- * Creates a new instance of the STextTypeHandler class. >- */ >- public STextTypeHandler() { >- separators = ""; //$NON-NLS-1$ >- } >- >- /** >- * Creates a new instance of the STextTypeHandler class. >- * @param separators string consisting of characters that split the text into fragments >- */ >- public STextTypeHandler(String separators) { >- this.separators = separators; >- } >- >- /** >- * Locate occurrences of special strings within a structured text >- * and return their indexes one after the other in successive calls. >- * <p> >- * This method is called repeatedly if the number of special cases >- * returned by {@link #getSpecialsCount} is greater than zero. >- * </p><p> >- * A handler handling special cases must override this method. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @param text is the structured text string before >- * addition of any directional formatting characters. >- * >- * @param charTypes is a parameter received by <code>indexOfSpecial</code> >- * uniquely to be used as argument for calls to methods which >- * need it. >- * >- * @param offsets is a parameter received by <code>indexOfSpecial</code> >- * uniquely to be used as argument for calls to methods which >- * need it. >- * >- * @param caseNumber number of the special case to locate. >- * This number varies from 1 to the number of special cases >- * returned by {@link #getSpecialsCount getSpecialsCount} >- * for this handler. >- * The meaning of this number is internal to the class >- * implementing <code>indexOfSpecial</code>. >- * >- * @param fromIndex the index within <code>text</code> to start >- * the search from. >- * >- * @return the position where the start of the special case >- * corresponding to <code>caseNumber</code> was located. >- * The method must return the first occurrence of whatever >- * identifies the start of the special case starting from >- * <code>fromIndex</code>. The method does not have to check if >- * this occurrence appears within the scope of another special >- * case (e.g. a comment starting delimiter within the scope of >- * a literal or vice-versa). >- * <br>If no occurrence is found, the method must return -1. >- * >- * @throws IllegalStateException If not overridden, this method throws an >- * <code>IllegalStateException</code>. This is appropriate behavior >- * (and does not need to be overridden) for handlers whose >- * number of special cases is zero, which means that >- * <code>indexOfSpecial</code> should never be called for them. >- */ >- public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) { >- // This method must be overridden by all subclasses with special cases. >- throw new IllegalStateException("A handler with specialsCount > 0 must have an indexOfSpecial() method."); //$NON-NLS-1$ >- } >- >- /** >- * This method handles special cases specific to this handler. >- * It is called when a special case occurrence >- * is located by {@link #indexOfSpecial}. >- * <p> >- * If a special processing cannot be completed within a current call to >- * <code>processSpecial</code> (for instance, a comment has been started >- * in the current line but its end appears in a following line), >- * <code>processSpecial</code> should specify a final state by >- * putting its value in the first element of the <code>state</code> >- * parameter. >- * The meaning of this state is internal to the handler. >- * On a later call, <code>processSpecial</code> will be called with that value >- * for parameter <code>caseNumber</code> and <code>-1</code> for parameter >- * <code>separLocation</code> and should perform whatever initializations are required >- * depending on the state. >- * </p><p> >- * A handler handling special cases (with a number of >- * special cases greater than zero) must override this method. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @param text is the structured text string before >- * addition of any directional formatting characters. >- * >- * @param charTypes is a parameter received by <code>processSpecial</code> >- * uniquely to be used as argument for calls to methods which >- * need it. >- * >- * @param offsets is a parameter received by <code>processSpecial</code> >- * uniquely to be used as argument for calls to methods which >- * need it. >- * >- * @param state is an integer array with at least one element. >- * If the handler needs to signal the occurrence of a >- * special case which must be passed to the next call to >- * <code>leanToFullText</code> (for instance, a comment or a >- * literal started but not closed in the current >- * <code>text</code>), it must put a value in the first element >- * of the <code>state</code> parameter. >- * This number must be >= 1 and less or equal to the number of special >- * cases returned by {@link #getSpecialsCount getSpecialsCount} >- * by this handler. >- * This number is passed back to the caller >- * and should be specified as <code>state</code> argument >- * in the next call to <code>leanToFullText</code> together >- * with the continuation text. >- * The meaning of this number is internal to the handler. >- * >- * @param caseNumber number of the special case to handle. >- * >- * @param separLocation the position returned by >- * {@link #indexOfSpecial indexOfSpecial}. In calls to >- * {@link ISTextExpert#leanToFullText leanToFullText} and other >- * methods of {@link ISTextExpert} specifying a non-null >- * <code>state</code> parameter, <code>processSpecial</code> is >- * called when initializing the processing with the value of >- * <code>caseNumber</code> equal to the value returned in the >- * first element of <code>state</code> and the value of >- * <code>separLocation</code> equal to <code>-1</code>. >- * >- * @return the position after the scope of the special case ends. >- * For instance, the position after the end of a comment, >- * the position after the end of a literal. >- * <br>A value greater or equal to the length of <code>text</code> >- * means that there is no further occurrence of this case in the >- * current structured text. >- * >- * @throws IllegalStateException If not overridden, this method throws an >- * <code>IllegalStateException</code>. This is appropriate behavior >- * (and does not need to be overridden) for handlers whose >- * number of special cases is zero, which means that >- * <code>processSpecial</code> should never be called for them. >- */ >- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >- // This method must be overridden by all subclasses with any special case. >- throw new IllegalStateException("A handler with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$ >- } >- >- /** >- * This method can be called from within {@link #indexOfSpecial} or >- * {@link #processSpecial} in extensions of <code>STextTypeHandler</code> >- * to specify that a mark character must be added before the character >- * at the specified position of the <i>lean</i> text when generating the >- * <i>full</i> text. The mark character will be LRM for structured text >- * with a LTR base direction, and RLM for structured text with RTL >- * base direction. The mark character is not added physically by this >- * method, but its position is noted and will be used when generating >- * the <i>full</i> text. >- * >- * @param text is the structured text string received as >- * parameter to <code>indexOfSpecial</code> or >- * <code>processSpecial</code>. >- * >- * @param charTypes is a parameter received by <code>indexOfSpecial</code> >- * or <code>processSpecial</code>, uniquely to be used as argument >- * for calls to <code>insertMark</code> and other methods used >- * by handlers. >- * >- * @param offsets is a parameter received by <code>indexOfSpecial</code> >- * or <code>processSpecial</code>, uniquely to be used as argument >- * for calls to <code>insertMark</code> and other methods used >- * by handlers. >- * >- * @param offset position of the character in the <i>lean</i> text. >- * It must be a non-negative number smaller than the length >- * of the <i>lean</i> text. >- * For the benefit of efficiency, it is better to insert >- * multiple marks in ascending order of the offsets. >- */ >- public static final void insertMark(String text, STextCharTypes charTypes, STextOffsets offsets, int offset) { >- offsets.insertOffset(charTypes, offset); >- } >- >- /** >- * This method can be called from within {@link #indexOfSpecial} or >- * {@link #processSpecial} in extensions of <code>STextTypeHandler</code> to add >- * a directional mark before a separator if needed for correct display, >- * depending on the base direction of the text and on the class of the >- * characters in the <i>lean</i> text preceding and following the separator itself. >- * <p> >- * The logic implemented in this method considers the text before >- * <code>separLocation</code> and the text following it. If, and only if, >- * a directional mark is needed to insure that the two parts of text >- * will be laid out according to the base direction, a mark will be >- * added when generating the <i>full</i> text. >- * </p> >- * @param text is the structured text string received as >- * parameter to <code>indexOfSpecial</code> or >- * <code>processSpecial</code>. >- * >- * @param charTypes is a parameter received by <code>indexOfSpecial</code> >- * or <code>processSpecial</code>, uniquely to be used as argument >- * for calls to <code>processSeparator</code> and other methods used >- * by handlers. >- * >- * @param offsets is a parameter received by <code>indexOfSpecial</code> >- * or <code>processSpecial</code>, uniquely to be used as argument >- * for calls to <code>processSeparator</code> and other methods used >- * by handlers. >- * >- * @param separLocation offset of the separator in the <i>lean</i> text. >- * It must be a non-negative number smaller than the length >- * of the <i>lean</i> text. >- */ >- public static final void processSeparator(String text, STextCharTypes charTypes, STextOffsets offsets, int separLocation) { >- STextImpl.processSeparator(text, charTypes, offsets, separLocation); >- } >- >- /** >- * Indicate the separators to use for the current handler. >- * This method is invoked before starting the processing. >- * <p> >- * If no separators are specified, this method returns an empty string. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @return a string grouping one-character separators which separate >- * the structured text into tokens. >- */ >- public String getSeparators(STextEnvironment environment) { >- return separators; >- } >- >- /** >- * Indicate the base text direction appropriate for an instance of structured text. >- * This method is invoked before starting the processing. >- * <p> >- * If not overridden, this method returns <code>DIR_LTR</code>. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @param text is the structured text string to process. >- * >- * @return the base direction of the structured text. This direction >- * may not be the same depending on the environment and on >- * whether the structured text contains Arabic or Hebrew >- * letters.<br> >- * The value returned is either >- * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}. >- */ >- public int getDirection(STextEnvironment environment, String text) { >- return STextDirection.DIR_LTR; >- } >- >- /** >- * Indicate the base text direction appropriate for an instance of structured text. >- * This method is invoked before starting the processing. >- * <p> >- * If not overridden, this method returns <code>DIR_LTR</code>. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @param text is the structured text string to process. >- * >- * @param charTypes is a parameter received uniquely to be used as argument >- * for calls to <code>getCharType</code> and other methods used >- * by handlers. >- * >- * @return the base direction of the structured text. This direction >- * may not be the same depending on the environment and on >- * whether the structured text contains Arabic or Hebrew >- * letters.<br> >- * The value returned is either >- * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}. >- */ >- public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { >- return STextDirection.DIR_LTR; >- } >- >- /** >- * Indicate the number of special cases handled by the current handler. >- * This method is invoked before starting the processing. >- * If the number returned is zero, {@link #indexOfSpecial} and >- * {@link #processSpecial} will not be invoked. >- * <p> >- * If not overridden, this method returns <code>zero</code>. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @return the number of special cases for the associated handler. >- * Special cases exist for some types of structured text >- * handlers. They are implemented by overriding methods >- * {@link STextTypeHandler#indexOfSpecial} and {@link STextTypeHandler#processSpecial}. >- * Examples of special cases are comments, literals, or >- * anything which is not identified by a one-character separator. >- * >- */ >- public int getSpecialsCount(STextEnvironment environment) { >- return 0; >- } >- >- /** >- * Checks if there is a need for processing structured text. >- * This method is invoked before starting the processing. If the >- * handler returns <code>true</code>, no directional formatting >- * characters are added to the <i>lean</i> text and the processing >- * is shortened. >- * <p> >- * If not overridden, this method returns <code>false</code>. >- * </p> >- * @param environment the current environment, which may affect the behavior of >- * the handler. This parameter may be specified as >- * <code>null</code>, in which case the >- * {@link STextEnvironment#DEFAULT DEFAULT} >- * environment should be assumed. >- * >- * @param text is the structured text string to process. >- * >- * @param charTypes is a parameter received uniquely to be used as argument >- * for calls to <code>getCharType</code> and other methods used >- * by handlers. >- * >- * @return a flag indicating if there is no need to process the structured >- * text to add directional formatting characters. >- * >- */ >- public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes charTypes) { >- return false; >- } >- >-} >diff --git src/org/eclipse/equinox/bidi/internal/STextDelims.java src/org/eclipse/equinox/bidi/internal/STextDelims.java >index ce86629..110bcc4 100644 >--- src/org/eclipse/equinox/bidi/internal/STextDelims.java >+++ src/org/eclipse/equinox/bidi/internal/STextDelims.java >@@ -11,10 +11,11 @@ > package org.eclipse.equinox.bidi.internal; > > import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+ > import org.eclipse.equinox.bidi.custom.*; > > /** >- * A base handler for structured text composed of text segments separated >+ * A base processor for structured text composed of text segments separated > * by separators where the text segments may include delimited parts within > * which separators are treated like regular characters. > * <p> >@@ -22,7 +23,7 @@ > * </p> > * @author Matitiahu Allouche > */ >-public abstract class STextDelims extends STextTypeHandler { >+public abstract class STextDelims extends STextProcessor { > > public STextDelims() { > // placeholder >@@ -59,7 +60,7 @@ > * of <code>text</code> if no end delimiter is found. > */ > public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > int loc = separLocation + 1; > char delim = getDelimiters().charAt((caseNumber * 2) - 1); > loc = text.indexOf(delim, loc); >diff --git src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java >index 3f81242..37d5217 100644 >--- src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java >+++ src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java >@@ -11,10 +11,11 @@ > package org.eclipse.equinox.bidi.internal; > > import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+ > import org.eclipse.equinox.bidi.custom.*; > > /** >- * A base handler for structured text composed of text segments separated >+ * A base processor for structured text composed of text segments separated > * by separators where the text segments may include delimited parts within > * which separators are treated like regular characters and the delimiters > * may be escaped. >@@ -50,7 +51,7 @@ > * ignoring possibly escaped end delimiters. > */ > public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > int location = separLocation + 1; > char delim = getDelimiters().charAt((caseNumber * 2) - 1); > while (true) { >diff --git src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java >new file mode 0 >index 0000000..985495c 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/STextExpertImpl.java >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal; >+ >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.advanced.ISTextExpert; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+ >+public class STextExpertImpl implements ISTextExpert { >+ >+ protected STextProcessor structuredTextDescriptor; >+ protected STextEnvironment environment; >+ >+ // XXX potentially problematic - implementation might write into it? >+ private final static int[] initialState = new int[] {0}; >+ >+ public STextExpertImpl(STextProcessor structuredTextDescriptor, STextEnvironment environment) { >+ this.structuredTextDescriptor = structuredTextDescriptor; >+ this.environment = environment; >+ } >+ >+ public String leanToFullText(String text) { >+ return STextImpl.leanToFullText(structuredTextDescriptor, environment, text, initialState); >+ } >+ >+ public int[] leanToFullMap(String text) { >+ return STextImpl.leanToFullMap(structuredTextDescriptor, environment, text, initialState); >+ } >+ >+ public int[] leanBidiCharOffsets(String text) { >+ return STextImpl.leanBidiCharOffsets(structuredTextDescriptor, environment, text, initialState); >+ } >+ >+ public String fullToLeanText(String text) { >+ return STextImpl.fullToLeanText(structuredTextDescriptor, environment, text, initialState); >+ } >+ >+ public int[] fullToLeanMap(String text) { >+ return STextImpl.fullToLeanMap(structuredTextDescriptor, environment, text, initialState); >+ } >+ >+ public int[] fullBidiCharOffsets(String text) { >+ return STextImpl.fullBidiCharOffsets(structuredTextDescriptor, environment, text, initialState); >+ } >+ >+ public int getCurDirection(String text) { >+ return structuredTextDescriptor.getDirection(environment, text); >+ } >+ >+} >diff --git src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java >new file mode 0 >index 0000000..c46ee3c 0 >--- /dev/null >+++ src/org/eclipse/equinox/bidi/internal/STextExpertMultipassImpl.java >@@ -0,0 +1,74 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal; >+ >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.advanced.ISTextExpertStateful; >+import org.eclipse.equinox.bidi.custom.STextProcessor; >+ >+public class STextExpertMultipassImpl extends STextExpertImpl implements ISTextExpertStateful { >+ >+ /** >+ * Constant to use in the first element of the <code>state</code> >+ * argument when calling most methods of this class >+ * to indicate that there is no context of previous lines which >+ * should be initialized before performing the operation. >+ */ >+ public static final int STATE_INITIAL = 0; >+ >+ private int[] state = new int[] {STATE_INITIAL}; >+ >+ public STextExpertMultipassImpl(STextProcessor structuredTextDescriptor, STextEnvironment environment) { >+ super(structuredTextDescriptor, environment); >+ resetState(); >+ } >+ >+ public String leanToFullText(String text) { >+ return STextImpl.leanToFullText(structuredTextDescriptor, environment, text, state); >+ } >+ >+ public int[] leanToFullMap(String text) { >+ return STextImpl.leanToFullMap(structuredTextDescriptor, environment, text, state); >+ } >+ >+ public int[] leanBidiCharOffsets(String text) { >+ return STextImpl.leanBidiCharOffsets(structuredTextDescriptor, environment, text, state); >+ } >+ >+ public String fullToLeanText(String text) { >+ return STextImpl.fullToLeanText(structuredTextDescriptor, environment, text, state); >+ } >+ >+ public int[] fullToLeanMap(String text) { >+ return STextImpl.fullToLeanMap(structuredTextDescriptor, environment, text, state); >+ } >+ >+ public int[] fullBidiCharOffsets(String text) { >+ return STextImpl.fullBidiCharOffsets(structuredTextDescriptor, environment, text, state); >+ } >+ >+ public int getCurDirection(String text) { >+ return structuredTextDescriptor.getDirection(environment, text); >+ } >+ >+ public void resetState() { >+ state[0] = STATE_INITIAL; >+ } >+ >+ public void setState(int newState) { >+ state[0] = newState; >+ } >+ >+ public int getState() { >+ return state[0]; >+ } >+ >+} >diff --git src/org/eclipse/equinox/bidi/internal/STextImpl.java src/org/eclipse/equinox/bidi/internal/STextImpl.java >index 1137826..c102319 100644 >--- src/org/eclipse/equinox/bidi/internal/STextImpl.java >+++ src/org/eclipse/equinox/bidi/internal/STextImpl.java >@@ -11,10 +11,11 @@ > package org.eclipse.equinox.bidi.internal; > > import org.eclipse.equinox.bidi.STextDirection; >-import org.eclipse.equinox.bidi.advanced.*; >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+import org.eclipse.equinox.bidi.advanced.ISTextExpert; > import org.eclipse.equinox.bidi.custom.*; > >-public class STextImpl implements ISTextExpertStateful { >+public class STextImpl { > > static final String EMPTY_STRING = ""; //$NON-NLS-1$ > >@@ -46,67 +47,18 @@ > static final int FIXES_LENGTH = PREFIX_LENGTH + SUFFIX_LENGTH; > static final int[] EMPTY_INT_ARRAY = new int[0]; > static final STextEnvironment IGNORE_ENVIRONMENT = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE); >- static final int STATE_INITIAL = 0; > >- protected STextTypeHandler structuredTextHandler; >- protected STextEnvironment environment; >- protected int[] state; >- >- public STextImpl(STextTypeHandler structuredTextHandler, STextEnvironment environment, int[] state) { >- this.structuredTextHandler = structuredTextHandler; >- this.environment = environment; >- this.state = state; >+ /** >+ * Prevent creation of a STextImpl instance >+ */ >+ private STextImpl() { >+ // nothing to do > } > >- public String leanToFullText(String text) { >- return STextImpl.leanToFullText(structuredTextHandler, environment, text, state); >- } >- >- public int[] leanToFullMap(String text) { >- return STextImpl.leanToFullMap(structuredTextHandler, environment, text, state); >- } >- >- public int[] leanBidiCharOffsets(String text) { >- return STextImpl.leanBidiCharOffsets(structuredTextHandler, environment, text, state); >- } >- >- public String fullToLeanText(String text) { >- return STextImpl.fullToLeanText(structuredTextHandler, environment, text, state); >- } >- >- public int[] fullToLeanMap(String text) { >- return STextImpl.fullToLeanMap(structuredTextHandler, environment, text, state); >- } >- >- public int[] fullBidiCharOffsets(String text) { >- return STextImpl.fullBidiCharOffsets(structuredTextHandler, environment, text, state); >- } >- >- public int getCurDirection(String text) { >- return structuredTextHandler.getDirection(environment, text); >- } >- >- public void resetState() { >- state[0] = STATE_INITIAL; >- } >- >- public void setState(int newState) { >- state[0] = newState; >- } >- >- public static void setState(int[] state, int newState) { >- if (state != null) >- state[0] = newState; >- } >- >- public int getState() { >- return state[0]; >- } >- >- static long computeNextLocation(STextTypeHandler handler, STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] locations, int curPos) { >- String separators = handler.getSeparators(environment); >+ static long computeNextLocation(STextProcessor processor, STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] locations, int curPos) { >+ String separators = processor.getSeparators(environment); > int separCount = separators.length(); >- int specialsCount = handler.getSpecialsCount(environment); >+ int specialsCount = processor.getSpecialsCount(environment); > int len = text.length(); > int nextLocation = len; > int idxLocation = 0; >@@ -116,7 +68,7 @@ > int location = locations[separCount + i]; > if (location < curPos) { > offsets.ensureRoom(); >- location = handler.indexOfSpecial(environment, text, charTypes, offsets, i + 1, curPos); >+ location = processor.indexOfSpecial(environment, text, charTypes, offsets, i + 1, curPos); > if (location < 0) > location = len; > locations[separCount + i] = location; >@@ -243,12 +195,12 @@ > * <p> > * @see ISTextExpert#leanToFullText STextEngine.leanToFullText > */ >- public static String leanToFullText(STextTypeHandler handler, 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; >- STextCharTypes charTypes = new STextCharTypes(handler, environment, text); >- STextOffsets offsets = leanToFullCommon(handler, environment, text, state, charTypes); >+ STextCharTypes charTypes = new STextCharTypes(processor, environment, text); >+ STextOffsets offsets = leanToFullCommon(processor, environment, text, state, charTypes); > int prefixLength = offsets.getPrefixLength(); > int count = offsets.getCount(); > if (count == 0 && prefixLength == 0) >@@ -290,12 +242,12 @@ > return new String(fullChars); > } > >- public static int[] leanToFullMap(STextTypeHandler handler, 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; >- STextCharTypes charTypes = new STextCharTypes(handler, environment, text); >- STextOffsets offsets = leanToFullCommon(handler, environment, text, state, charTypes); >+ STextCharTypes charTypes = new STextCharTypes(processor, environment, text); >+ STextOffsets offsets = leanToFullCommon(processor, environment, text, state, charTypes); > int prefixLength = offsets.getPrefixLength(); > int[] map = new int[len]; > int count = offsets.getCount(); // number of used entries >@@ -310,42 +262,54 @@ > return map; > } > >- public static int[] leanBidiCharOffsets(STextTypeHandler handler, 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; >- STextCharTypes charTypes = new STextCharTypes(handler, environment, text); >- STextOffsets offsets = leanToFullCommon(handler, environment, text, state, charTypes); >+ STextCharTypes charTypes = new STextCharTypes(processor, environment, text); >+ STextOffsets offsets = leanToFullCommon(processor, environment, text, state, charTypes); > return offsets.getArray(); > } >+ >+ /** >+ * Constant to use in the first element of the <code>state</code> >+ * argument when calling most methods of this class >+ * to indicate that there is no context of previous lines which >+ * should be initialized before performing the operation. >+ */ >+ public static final int STATE_INITIAL = 0; // TBD move > >- static STextOffsets leanToFullCommon(STextTypeHandler handler, STextEnvironment environment, String text, int[] state, STextCharTypes charTypes) { >+ static STextOffsets leanToFullCommon(STextProcessor processor, STextEnvironment environment, String text, int[] state, STextCharTypes charTypes) { > if (environment == null) > environment = STextEnvironment.DEFAULT; >+ if (state == null) { >+ state = new int[1]; >+ state[0] = STATE_INITIAL; >+ } > int len = text.length(); >- int direction = handler.getDirection(environment, text, charTypes); >+ int direction = processor.getDirection(environment, text, charTypes); > STextOffsets offsets = new STextOffsets(); >- if (!handler.skipProcessing(environment, text, charTypes)) { >+ if (!processor.skipProcessing(environment, text, charTypes)) { > // initialize locations >- int separCount = handler.getSeparators(environment).length(); >- int[] locations = new int[separCount + handler.getSpecialsCount(environment)]; >+ int separCount = processor.getSeparators(environment).length(); >+ int[] locations = new int[separCount + processor.getSpecialsCount(environment)]; > for (int i = 0, k = locations.length; i < k; i++) { > locations[i] = -1; > } > // current position > int curPos = 0; >- if (state != null && state[0] > STATE_INITIAL) { >+ if (state[0] > STATE_INITIAL) { > offsets.ensureRoom(); > int initState = state[0]; > state[0] = STATE_INITIAL; >- curPos = handler.processSpecial(environment, text, charTypes, offsets, state, initState, -1); >+ curPos = processor.processSpecial(environment, text, charTypes, offsets, state, initState, -1); > } > while (true) { > // location of next token to handle > int nextLocation; > // index of next token to handle (if < separCount, this is a separator; otherwise a special case > int idxLocation; >- long res = computeNextLocation(handler, environment, text, charTypes, offsets, locations, curPos); >+ long res = computeNextLocation(processor, environment, text, charTypes, offsets, locations, curPos); > nextLocation = (int) (res & 0x00000000FFFFFFFF); /* low word */ > if (nextLocation >= len) > break; >@@ -356,12 +320,12 @@ > curPos = nextLocation + 1; > } else { > idxLocation -= (separCount - 1); // because caseNumber starts from 1 >- curPos = handler.processSpecial(environment, text, charTypes, offsets, state, idxLocation, nextLocation); >+ curPos = processor.processSpecial(environment, text, charTypes, offsets, state, idxLocation, nextLocation); > } > if (curPos >= len) > break; > } // end while >- } // end if (!handler.skipProcessing()) >+ } // end if (!processor.skipProcessing()) > int prefixLength; > int orientation = environment.getOrientation(); > if (orientation == STextEnvironment.ORIENT_IGNORE) >@@ -379,12 +343,12 @@ > return offsets; > } > >- public static String fullToLeanText(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) { >+ public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) { > if (text.length() == 0) > return text; > if (environment == null) > environment = STextEnvironment.DEFAULT; >- int dir = handler.getDirection(environment, text); >+ int dir = processor.getDirection(environment, text); > char curMark = MARKS[dir]; > char curEmbed = EMBEDS[dir]; > int i; // used as loop index >@@ -422,7 +386,7 @@ > chars[i - cnt] = c; > } > String lean = new String(chars, 0, lenText - cnt); >- String full = leanToFullText(handler, IGNORE_ENVIRONMENT, lean, state); >+ String full = leanToFullText(processor, IGNORE_ENVIRONMENT, lean, state); > if (full.equals(text)) > return lean; > >@@ -467,13 +431,13 @@ > return lean; > } > >- public static int[] fullToLeanMap(STextTypeHandler handler, 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(handler, environment, full, state); >+ String lean = fullToLeanText(processor, environment, full, state); > int lenLean = lean.length(); >- int dir = handler.getDirection(environment, lean); >+ int dir = processor.getDirection(environment, lean); > char curMark = MARKS[dir]; > char curEmbed = EMBEDS[dir]; > int[] map = new int[lenFull]; >@@ -498,11 +462,11 @@ > return map; > } > >- public static int[] fullBidiCharOffsets(STextTypeHandler handler, 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(handler, environment, full, state); >+ String lean = fullToLeanText(processor, environment, full, state); > STextOffsets offsets = new STextOffsets(); > int lenLean = lean.length(); > int idxLean, idxFull; >diff --git src/org/eclipse/equinox/bidi/internal/STextSingle.java src/org/eclipse/equinox/bidi/internal/STextSingle.java >index 3ea4d4a..42e1be0 100644 >--- src/org/eclipse/equinox/bidi/internal/STextSingle.java >+++ src/org/eclipse/equinox/bidi/internal/STextSingle.java >@@ -11,25 +11,26 @@ > package org.eclipse.equinox.bidi.internal; > > import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+ > import org.eclipse.equinox.bidi.custom.*; > > /** >- * A base handler for structured text composed of two parts separated by a separator. >+ * A base processor for structured text composed of two parts separated by a separator. > * The first occurrence of the separator delimits the end of the first part > * and the start of the second part. Further occurrences of the separator, > * if any, are treated like regular characters of the second text part. >- * The handler makes sure that the text be presented in the form >+ * The processor makes sure that the text be presented in the form > * (assuming that the equal sign is the separator): > * <pre> > * part1=part2 > * </pre> >- * The string returned by {@link STextTypeHandler#getSeparators getSeparators} >- * for this handler 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 > */ >-public class STextSingle extends STextTypeHandler { >+public class STextSingle extends STextProcessor { > > public STextSingle(String separator) { > super(separator); >@@ -51,12 +52,12 @@ > * @return the length of <code>text</code>. > */ > public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > return text.length(); > } > > /** >- * This method returns 1 as number of special cases handled by this handler. >+ * This method returns 1 as number of special cases handled by this processor. > * > * @return 1. > */ >diff --git src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java >index f97f51e..bbcf564 100644 >--- src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java >+++ src/org/eclipse/equinox/bidi/internal/STextTypesCollector.java >@@ -13,7 +13,7 @@ > import java.util.HashMap; > import java.util.Map; > import org.eclipse.core.runtime.*; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > public class STextTypesCollector implements IRegistryEventListener { > >@@ -21,7 +21,7 @@ > > private static final String CE_NAME = "typeDescription"; //$NON-NLS-1$ > private static final String ATTR_TYPE = "type"; //$NON-NLS-1$ >- private static final String ATTR_HANDLER = "class"; //$NON-NLS-1$ >+ private static final String ATTR_PROCESSOR = "class"; //$NON-NLS-1$ > > private Map types; > private Map factories; >@@ -46,12 +46,12 @@ > return result; > } > >- public STextTypeHandler getHandler(String type) { >+ public STextProcessor getProcessor(String type) { > if (types == null) > read(); >- Object handler = types.get(type); >- if (handler instanceof STextTypeHandler) >- return (STextTypeHandler) handler; >+ Object processor = types.get(type); >+ if (processor instanceof STextProcessor) >+ return (STextProcessor) processor; > return null; > } > >@@ -76,14 +76,14 @@ > if (CE_NAME != confElements[j].getName()) > STextActivator.logError("BiDi types: unexpected element name " + confElements[j].getName(), new IllegalArgumentException()); //$NON-NLS-1$ > String type = confElements[j].getAttribute(ATTR_TYPE); >- Object handler; >+ Object processor; > try { >- handler = confElements[j].createExecutableExtension(ATTR_HANDLER); >+ processor = confElements[j].createExecutableExtension(ATTR_PROCESSOR); > } catch (CoreException e) { >- STextActivator.logError("BiDi types: unable to create handler for " + type, e); //$NON-NLS-1$ >+ STextActivator.logError("BiDi types: unable to create processor for " + type, e); //$NON-NLS-1$ > continue; > } >- types.put(type, handler); >+ types.put(type, processor); > factories.put(type, confElements[j]); > } > } >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java >index 7aab1f4..418873f 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextComma.java >@@ -10,15 +10,15 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.consumable; > >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > /** >- * Handler adapted to processing comma-delimited lists, such as: >+ * Processor adapted to processing comma-delimited lists, such as: > * <pre> > * part1,part2,part3 > * </pre> > */ >-public class STextComma extends STextTypeHandler { >+public class STextComma extends STextProcessor { > public STextComma() { > super(","); //$NON-NLS-1$ > } >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java >index 2be4a2b..940f192 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java >@@ -16,7 +16,7 @@ > import org.eclipse.equinox.bidi.internal.STextDelimsEsc; > > /** >- * Handler adapted to processing e-mail addresses. >+ * Processor adapted to processing e-mail addresses. > */ > public class STextEmail extends STextDelimsEsc { > static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT; >@@ -59,7 +59,7 @@ > } > > /** >- * @return 2 as number of special cases handled by this handler. >+ * @return 2 as number of special cases handled by this processor. > */ > public int getSpecialsCount(STextEnvironment environment) { > return 2; >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java >index b8f4b10..d7185d3 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextFile.java >@@ -10,12 +10,12 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.consumable; > >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > /** >- * Handler adapted to processing directory and file paths. >+ * Processor adapted to processing directory and file paths. > */ >-public class STextFile extends STextTypeHandler { >+public class STextFile extends STextProcessor { > > public STextFile() { > super(":/\\."); //$NON-NLS-1$ >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java >index 5e3d49c..bb4dff1 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java >@@ -10,14 +10,13 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.consumable; > >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.advanced.ISTextExpert; >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.custom.*; > import org.eclipse.equinox.bidi.internal.STextActivator; >-import org.eclipse.equinox.bidi.internal.STextImpl; > > /** >- * <code>STextJava</code> is a handler for structured text >+ * <code>STextJava</code> is a processor for structured text > * composed of Java statements. Such a structured text may span > * multiple lines. > * <p> >@@ -35,7 +34,7 @@ > * > * @author Matitiahu Allouche > */ >-public class STextJava extends STextTypeHandler { >+public class STextJava extends STextProcessor { > private static final byte WS = Character.DIRECTIONALITY_WHITESPACE; > static final String lineSep = STextActivator.getInstance().getProperty("line.separator"); //$NON-NLS-1$ > >@@ -44,7 +43,7 @@ > } > > /** >- * @return 4 as the number of special cases handled by this handler. >+ * @return 4 as the number of special cases handled by this processor. > */ > public int getSpecialsCount(STextEnvironment environment) { > return 4; >@@ -86,7 +85,7 @@ > public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { > int location, counter, i; > >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > switch (caseNumber) { > case 1 : /* space */ > separLocation++; >@@ -115,12 +114,12 @@ > location = separLocation + 2; // skip the opening slash-aster > location = text.indexOf("*/", location); //$NON-NLS-1$ > if (location < 0) { >- STextImpl.setState(state, caseNumber); >+ state[0] = caseNumber; > return text.length(); > } > // we need to call processSeparator since text may follow the > // end of comment immediately without even a space >- STextTypeHandler.processSeparator(text, charTypes, offsets, location); >+ STextProcessor.processSeparator(text, charTypes, offsets, location); > return location + 2; > case 4 : /* slash-slash comment */ > location = text.indexOf(lineSep, separLocation + 2); >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java >index d15af0b..0aa241d 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java >@@ -13,13 +13,13 @@ > import org.eclipse.equinox.bidi.STextDirection; > import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.custom.STextCharTypes; >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > /** >- * Handler adapted to processing arithmetic expressions with >+ * Processor adapted to processing arithmetic expressions with > * a possible right-to-left base direction. > */ >-public class STextMath extends STextTypeHandler { >+public class STextMath extends STextProcessor { > static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT; > static final byte R = Character.DIRECTIONALITY_RIGHT_TO_LEFT; > static final byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java >index a99f12f..994a80e 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextProperty.java >@@ -13,7 +13,7 @@ > import org.eclipse.equinox.bidi.internal.STextSingle; > > /** >- * Handler adapted to processing property file statements. >+ * Processor adapted to processing property file statements. > * It expects the following string format: > * <pre> > * name=value >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java >index 4816d4e..c5d3bb9 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java >@@ -11,13 +11,12 @@ > package org.eclipse.equinox.bidi.internal.consumable; > > import org.eclipse.equinox.bidi.STextDirection; >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.advanced.ISTextExpert; >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.custom.*; >-import org.eclipse.equinox.bidi.internal.STextImpl; > > /** >- * <code>STextRegex</code> is a handler for regular expressions. >+ * <code>STextRegex</code> is a processor for regular expressions. > * Such expressions may span multiple lines. > * <p> > * In applications like an editor where parts of the text might be modified >@@ -34,7 +33,7 @@ > * > * @author Matitiahu Allouche > */ >-public class STextRegex extends STextTypeHandler { >+public class STextRegex extends STextProcessor { > static final String[] startStrings = {"", /* 0 *//* dummy *///$NON-NLS-1$ > "(?#", /* 1 *//* comment (?#...) *///$NON-NLS-1$ > "(?<", /* 2 *//* named group (?<name> *///$NON-NLS-1$ >@@ -66,9 +65,9 @@ > static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER; > > /** >- * This method retrieves the number of special cases handled by this handler. >+ * This method retrieves the number of special cases handled by this processor. > * >- * @return the number of special cases for this handler. >+ * @return the number of special cases for this processor. > */ > public int getSpecialsCount(STextEnvironment environment) { > return maxSpecial; >@@ -155,13 +154,13 @@ > // initial state from previous line > location = 0; > } else { >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > // skip the opening "(?#" > location = separLocation + 3; > } > location = text.indexOf(')', location); > if (location < 0) { >- STextImpl.setState(state, caseNumber); >+ state[0] = caseNumber; > return text.length(); > } > return location + 1; >@@ -171,7 +170,7 @@ > case 5 : /* conditional named back reference (?(<name>) */ > case 6 : /* conditional named back reference (?('name') */ > case 7 : /* named parentheses reference (?&name) */ >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > // no need for calling processSeparator() for the following cases > // since the starting string contains a L char > case 8 : /* named group (?P<name> */ >@@ -195,20 +194,20 @@ > // initial state from previous line > location = 0; > } else { >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > // skip the opening "\Q" > location = separLocation + 2; > } > location = text.indexOf("\\E", location); //$NON-NLS-1$ > if (location < 0) { >- STextImpl.setState(state, caseNumber); >+ state[0] = caseNumber; > return text.length(); > } > // set the charType for the "E" to L (Left to Right character) > charTypes.setBidiTypeAt(location + 1, L); > return location + 2; > case 18 : /* R, AL, AN, EN */ >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > return separLocation + 1; > > } >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java >index 3b74b43..9fbe5e4 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java >@@ -10,14 +10,13 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.consumable; > >+import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.advanced.ISTextExpert; >-import org.eclipse.equinox.bidi.advanced.STextEnvironment; > import org.eclipse.equinox.bidi.custom.*; > import org.eclipse.equinox.bidi.internal.STextActivator; >-import org.eclipse.equinox.bidi.internal.STextImpl; > > /** >- * <code>STextSql</code> is a handler for structured text >+ * <code>STextSql</code> is a processor for structured text > * composed of SQL statements. Such a structured text may span > * multiple lines. > * <p> >@@ -35,7 +34,7 @@ > * > * @author Matitiahu Allouche > */ >-public class STextSql extends STextTypeHandler { >+public class STextSql extends STextProcessor { > private static final byte WS = Character.DIRECTIONALITY_WHITESPACE; > static final String lineSep = STextActivator.getInstance().getProperty("line.separator"); //$NON-NLS-1$ > >@@ -44,7 +43,7 @@ > } > > /** >- * @return 5 as the number of special cases handled by this handler. >+ * @return 5 as the number of special cases handled by this processor. > */ > public int getSpecialsCount(STextEnvironment environment) { > return 5; >@@ -90,7 +89,7 @@ > public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) { > int location; > >- STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); >+ STextProcessor.processSeparator(text, charTypes, offsets, separLocation); > switch (caseNumber) { > case 1 : /* space */ > separLocation++; >@@ -104,7 +103,7 @@ > while (true) { > location = text.indexOf('\'', location); > if (location < 0) { >- STextImpl.setState(state, caseNumber); >+ state[0] = caseNumber; > return text.length(); > } > if ((location + 1) < text.length() && text.charAt(location + 1) == '\'') { >@@ -133,12 +132,12 @@ > location = separLocation + 2; // skip the opening slash-aster > location = text.indexOf("*/", location); //$NON-NLS-1$ > if (location < 0) { >- STextImpl.setState(state, caseNumber); >+ state[0] = caseNumber; > return text.length(); > } > // we need to call processSeparator since text may follow the > // end of comment immediately without even a space >- STextTypeHandler.processSeparator(text, charTypes, offsets, location); >+ STextProcessor.processSeparator(text, charTypes, offsets, location); > return location + 2; > case 5 : /* hyphen-hyphen comment */ > location = text.indexOf(lineSep, separLocation + 2); >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java >index a4241fb..32b2307 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextSystem.java >@@ -13,7 +13,7 @@ > import org.eclipse.equinox.bidi.internal.STextSingle; > > /** >- * Handler adapted to processing structured text with the following format: >+ * Processor adapted to processing structured text with the following format: > * <pre> > * system(user) > * </pre> >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java >index 09794fa..5b2df1a 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextURL.java >@@ -10,12 +10,12 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.consumable; > >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > /** >- * Handler adapted to processing URLs. >+ * Processor adapted to processing URLs. > */ >-public class STextURL extends STextTypeHandler { >+public class STextURL extends STextProcessor { > public STextURL() { > super(":?#/@.[]"); //$NON-NLS-1$ > } >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java >index 387f39f..eae11f6 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextUnderscore.java >@@ -10,16 +10,16 @@ > ******************************************************************************/ > package org.eclipse.equinox.bidi.internal.consumable; > >-import org.eclipse.equinox.bidi.custom.STextTypeHandler; >+import org.eclipse.equinox.bidi.custom.STextProcessor; > > /** >- * Handler adapted to processing compound names. >+ * 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 class STextUnderscore extends STextTypeHandler { >+public class STextUnderscore extends STextProcessor { > > public STextUnderscore() { > super("_"); //$NON-NLS-1$ >diff --git src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java >index 637b229..40000ab 100644 >--- src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java >+++ src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java >@@ -11,10 +11,11 @@ > package org.eclipse.equinox.bidi.internal.consumable; > > import org.eclipse.equinox.bidi.advanced.STextEnvironment; >+ > import org.eclipse.equinox.bidi.internal.STextDelims; > > /** >- * Handler adapted to processing XPath expressions. >+ * Processor adapted to processing XPath expressions. > */ > public class STextXPath extends STextDelims { > >@@ -23,7 +24,7 @@ > } > > /** >- * @return 2 as the number of special cases handled by this handler. >+ * @return 2 as the number of special cases handled by this processor. > */ > public int getSpecialsCount(STextEnvironment environment) { > return 2;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 183164
:
148967
|
157821
|
158092
|
158531
|
160015
|
160017
|
160081
|
160698
|
160858
|
162228
|
162229
|
164476
|
186038
|
186054
|
186488
|
186490
|
188406
|
188407
|
188408
|
188627
|
194078
|
194079
|
195082
|
195084
|
196575
|
196576
|
199068
|
199070
|
199113
|
199855
|
200008
|
200389
|
200629
|
200630
|
200631
|
200742
|
200743
|
200803
|
200805
|
200905
|
200907
|
201464
|
201465
|
201467
|
201468
|
201469
|
201470
|
201676
|
201677
|
201785
|
201787
|
202172
|
202173
|
205767
|
205768
|
206588
|
210657