From 4e23e283afc82a2c3bd484608d908e6b5fd055ba Mon Sep 17 00:00:00 2001
From: Oleg Besedin
Date: Wed, 3 Aug 2011 15:36:27 -0400
Subject: Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
---
.../bidi/internal/tests/STextExtensionsTest.java | 2 +-
.../bidi/internal/tests/STextMethodsTest.java | 24 +++--
.../bidi/internal/tests/STextSomeMoreTest.java | 14 +--
.../src/org/eclipse/equinox/bidi/STextEngine.java | 3 +-
.../equinox/bidi/custom/STextCharTypes.java | 118 ++++++++++++++++++++
.../equinox/bidi/custom/STextDirections.java | 119 ---------------------
.../equinox/bidi/custom/STextProcessor.java | 53 +++++----
.../eclipse/equinox/bidi/internal/STextDelims.java | 6 +-
.../equinox/bidi/internal/STextDelimsEsc.java | 4 +-
.../eclipse/equinox/bidi/internal/STextImpl.java | 32 +++---
.../eclipse/equinox/bidi/internal/STextSingle.java | 10 +-
.../bidi/internal/consumable/STextEmail.java | 10 +-
.../bidi/internal/consumable/STextJava.java | 8 +-
.../bidi/internal/consumable/STextMath.java | 8 +-
.../bidi/internal/consumable/STextRegex.java | 14 ++-
.../equinox/bidi/internal/consumable/STextSql.java | 8 +-
.../bidi/internal/consumable/STextXPath.java | 3 +-
17 files changed, 231 insertions(+), 205 deletions(-)
create mode 100644 bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
delete mode 100644 bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextDirections.java
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
index a9d9f0414..6f010b28b 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
@@ -216,7 +216,7 @@ public class STextExtensionsTest extends STextTestBase {
processor = STextProcessorFactory.PROC_EMAIL;
state[0] = STextEngine.STATE_INITIAL;
- assertEquals("<>.:,;@", processor.getSeparators(null, "", null));
+ assertEquals("<>.:,;@", processor.getSeparators(null));
doTest3("DelimsEsc #1", "abc.DEF.GHI", "abc.DEF@.GHI");
doTest3("DelimsEsc #2", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK ");
doTest3("DelimsEsc #3", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK ");
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
index cb9b58993..3c0938517 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
@@ -12,7 +12,7 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.*;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -35,18 +35,22 @@ public class STextMethodsTest extends STextTestBase {
class MyComma extends STextProcessor {
- public String getSeparators(STextEnvironment environment, String text, STextDirections dirProps) {
+ public String getSeparators(STextEnvironment environment) {
return ","; //$NON-NLS-1$
}
- public boolean skipProcessing(STextEnvironment environment, String text, STextDirections dirProps) {
+ public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes dirProps) {
byte dirProp = dirProps.getBidiTypeAt(0);
if (dirProp == AL)
return true;
return false;
}
- public int getDirection(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getDirection(STextEnvironment environment, String text) {
+ return getDirection(environment, text, new STextCharTypes(text));
+ }
+
+ public int getDirection(STextEnvironment environment, String text, STextCharTypes dirProps) {
for (int i = 0; i < text.length(); i++) {
byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == AL)
@@ -187,18 +191,18 @@ public class STextMethodsTest extends STextTestBase {
dirHebrew = LTR;
msg = "TestDirection #1";
String text = toUT16("###");
- dirA = processor.getDirection(null, text, new STextDirections(text));
+ dirA = processor.getDirection(null, text);
text = toUT16("ABC");
- dirH = processor.getDirection(null, toUT16("ABC"), new STextDirections(text));
+ dirH = processor.getDirection(null, toUT16("ABC"));
assertTrue(msg, dirA == RTL && dirH == LTR);
dirArabic = RTL;
dirHebrew = RTL;
msg = "TestDirection #2";
text = toUT16("###");
- dirA = processor.getDirection(null, text, new STextDirections(text));
+ dirA = processor.getDirection(null, text);
text = toUT16("ABC");
- dirH = processor.getDirection(null, text, new STextDirections(text));
+ dirH = processor.getDirection(null, text);
assertTrue(msg, dirA == RTL && dirH == RTL);
dirArabic = dirHebrew = LTR;
@@ -218,9 +222,9 @@ public class STextMethodsTest extends STextTestBase {
dirArabic = RTL;
msg = "TestDirection #10.5";
text = toUT16("###");
- dirA = processor.getDirection(null, text, new STextDirections(text));
+ dirA = processor.getDirection(null, text);
text = toUT16("ABC");
- dirH = processor.getDirection(null, text, new STextDirections(text));
+ dirH = processor.getDirection(null, text);
assertTrue(msg, dirA == RTL && dirH == LTR);
STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
data = "ABC,#DEF,HOST,com";
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
index 4e64ee83f..e10dd73fe 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
@@ -13,7 +13,7 @@ package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -27,15 +27,15 @@ public class STextSomeMoreTest extends STextTestBase {
class Processor1 extends STextProcessor {
- public int getSpecialsCount(STextEnvironment env, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment env) {
return 1;
}
- public int indexOfSpecial(STextEnvironment env, String text, STextDirections dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes dirProps, int[] offsets, int caseNumber, int fromIndex) {
return fromIndex;
}
- public int processSpecial(STextEnvironment env, String text, STextDirections dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment env, String text, STextCharTypes dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
int len = text.length();
for (int i = len - 1; i >= 0; i--) {
STextProcessor.insertMark(text, dirProps, offsets, i);
@@ -47,7 +47,7 @@ public class STextSomeMoreTest extends STextTestBase {
class Processor2 extends STextProcessor {
- public int getSpecialsCount(STextEnvironment env, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment env) {
return 1;
}
@@ -55,11 +55,11 @@ public class STextSomeMoreTest extends STextTestBase {
class Processor3 extends STextProcessor {
- public int getSpecialsCount(STextEnvironment env, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment env) {
return 1;
}
- public int indexOfSpecial(STextEnvironment env, String text, STextDirections dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes dirProps, int[] offsets, int caseNumber, int fromIndex) {
return fromIndex;
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
index 512e28bf2..0bc00210f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java
@@ -10,7 +10,6 @@
******************************************************************************/
package org.eclipse.equinox.bidi;
-import org.eclipse.equinox.bidi.custom.STextDirections;
import org.eclipse.equinox.bidi.custom.STextProcessor;
import org.eclipse.equinox.bidi.internal.STextImpl;
@@ -313,7 +312,7 @@ public class STextEngine {
public static int getCurDirection(STextProcessor processor, STextEnvironment environment, String text) {
if (processor == null)
return DIR_LTR;
- return processor.getDirection(environment, text, new STextDirections(text));
+ return processor.getDirection(environment, text);
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
new file mode 100644
index 000000000..50d768dd0
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.custom;
+
+import org.eclipse.equinox.bidi.STextEnvironment;
+
+/**
+ * The class determines bidirectional types of characters in a string.
+ */
+public class STextCharTypes {
+
+ // In the following lines, B, L, R and AL represent bidi categories
+ // as defined in the Unicode Bidirectional Algorithm
+ // ( http://www.unicode.org/reports/tr9/ ).
+ // B represents the category Block Separator.
+ // L represents the category Left to Right character.
+ // R represents the category Right to Left character.
+ // AL represents the category Arabic Letter.
+ // AN represents the category Arabic Number.
+ // EN represents the category European Number.
+ static final byte B = Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR;
+ static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
+ static final byte R = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
+ static final byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
+ static final byte AN = Character.DIRECTIONALITY_ARABIC_NUMBER;
+ static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
+
+ private static final int DIRPROPS_ADD = 2;
+
+ final protected String text;
+
+ // 1 byte for each char in text
+ private byte[] dirProps;
+
+ // current orientation
+ private int orientation = -1; // "-1" means "unknown"
+
+ public STextCharTypes(String text) {
+ this.text = text;
+ dirProps = new byte[text.length()];
+ }
+
+ private byte getCachedDirectionAt(int index) {
+ return (byte) (dirProps[index] - DIRPROPS_ADD);
+ }
+
+ private boolean hasCachedDirectionAt(int i) {
+ return (dirProps[i] != 0); // "0" means "unknown"
+ }
+
+ /**
+ * @param dirProp bidirectional class of the character. It must be
+ * one of the values which can be returned by
+ * java.lang.Character.getDirectionality
.
+ */
+ public void setBidiTypeAt(int i, byte dirProp) {
+ dirProps[i] = (byte) (dirProp + DIRPROPS_ADD);
+ }
+
+ public int getOrientation(STextEnvironment environment) {
+ int result;
+ int orient = environment.getOrientation();
+ if ((orient & STextEnvironment.ORIENT_CONTEXTUAL_LTR) == 0) { // absolute orientation
+ result = orient;
+ } else { // contextual orientation:
+ result = orient & 1; // initiate to the default orientation minus contextual bit
+ int len = text.length();
+ byte dirProp;
+ for (int i = 0; i < len; i++) {
+ if (!hasCachedDirectionAt(i)) {
+ dirProp = Character.getDirectionality(text.charAt(i));
+ if (dirProp == B) // B char resolves to L or R depending on orientation
+ continue;
+ setBidiTypeAt(i, dirProp);
+ } else {
+ dirProp = getCachedDirectionAt(i);
+ }
+ if (dirProp == L) {
+ result = STextEnvironment.ORIENT_LTR;
+ break;
+ }
+ if (dirProp == R || dirProp == AL) {
+ result = STextEnvironment.ORIENT_RTL;
+ break;
+ }
+ }
+ }
+ orientation = result;
+ return result;
+ }
+
+ /**
+ * Returns directionality of the character in the original string at
+ * the specified index.
+ * @param index position of the character in the lean text
+ * @return the bidirectional class of the character. It is one of the
+ * values which can be returned by {@link Character#getDirectionality(char)}
+ */
+ public byte getBidiTypeAt(int index) {
+ if (hasCachedDirectionAt(index))
+ return getCachedDirectionAt(index);
+ byte dirProp = Character.getDirectionality(text.charAt(index));
+ if (dirProp == B) {
+ dirProp = (orientation == STextEnvironment.ORIENT_RTL) ? R : L;
+ }
+ setBidiTypeAt(index, dirProp);
+ return dirProp;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextDirections.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextDirections.java
deleted file mode 100644
index bc469bb78..000000000
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextDirections.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.custom;
-
-import org.eclipse.equinox.bidi.STextEnvironment;
-
-/**
- * The class determines bidirectional types of characters in a string.
- */
-public class STextDirections {
-
- // In the following lines, B, L, R and AL represent bidi categories
- // as defined in the Unicode Bidirectional Algorithm
- // ( http://www.unicode.org/reports/tr9/ ).
- // B represents the category Block Separator.
- // L represents the category Left to Right character.
- // R represents the category Right to Left character.
- // AL represents the category Arabic Letter.
- // AN represents the category Arabic Number.
- // EN represents the category European Number.
- static final byte B = Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR;
- static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
- static final byte R = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
- static final byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
- static final byte AN = Character.DIRECTIONALITY_ARABIC_NUMBER;
- static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
-
- private static final int DIRPROPS_ADD = 2;
-
- final protected String text;
-
- // 1 byte for each char in text
- private byte[] dirProps;
-
- // current orientation
- private byte baseOrientation = 0; // "0" means "unknown" // Mati: 0 is not a good choice for unknown orientation since 0 corresponds to LTR.
-
- public STextDirections(String text) {
- this.text = text;
- dirProps = new byte[text.length()];
- }
-
- private byte getCachedDirectionAt(int index) {
- return (byte) (dirProps[index] - DIRPROPS_ADD);
- }
-
- private boolean hasCachedDirectionAt(int i) {
- return (dirProps[i] != 0); // "0" means "unknown"
- }
-
- /**
- * @param dirProp bidirectional class of the character. It must be
- * one of the values which can be returned by
- * java.lang.Character.getDirectionality
.
- */
- public void setBidiTypeAt(int i, byte dirProp) {
- dirProps[i] = (byte) (dirProp + DIRPROPS_ADD);
- }
-
- public int getBaseOrientation(STextEnvironment environment) {
- int result;
- int orient = environment.getOrientation();
- if ((orient & STextEnvironment.ORIENT_CONTEXTUAL_LTR) == 0) { // absolute orientation
- result = orient;
- } else { // contextual orientation:
- result = orient & 1; // initiate to the default orientation minus contextual bit
- int len = text.length();
- byte dirProp;
- for (int i = 0; i < len; i++) {
- if (!hasCachedDirectionAt(i)) {
- dirProp = Character.getDirectionality(text.charAt(i));
- if (dirProp == B) // B char resolves to L or R depending on orientation
- continue;
- setBidiTypeAt(i, dirProp);
- } else {
- dirProp = getCachedDirectionAt(i);
- }
- if (dirProp == L) { // TBD || == EN ?
- result = STextEnvironment.ORIENT_LTR;
- break;
- }
- if (dirProp == R || dirProp == AL) {
- result = STextEnvironment.ORIENT_RTL;
- break;
- }
- }
- }
- baseOrientation = (byte) result;
- return result;
- }
-
- /**
- * Returns directionality of the character in the original string at
- * the specified index.
- * @param index position of the character in the lean text
- * @return the bidirectional class of the character. It is one of the
- * values which can be returned by {@link Character#getDirectionality(char)}
- */
- public byte getBidiTypeAt(int index) {
- if (hasCachedDirectionAt(index))
- return getCachedDirectionAt(index);
- byte dirProp = Character.getDirectionality(text.charAt(index));
- if (dirProp == B) {
- byte orient = baseOrientation;
- dirProp = (orient == STextEnvironment.ORIENT_RTL) ? R : L;
- }
- setBidiTypeAt(index, dirProp);
- return dirProp;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
index 481f1a350..f24d84ce7 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java
@@ -132,7 +132,7 @@ public class STextProcessor {
* number of special cases is zero, which means that
* indexOfSpecial
should never be called for them.
*/
- public int indexOfSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] 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$
}
@@ -216,7 +216,7 @@ public class STextProcessor {
* number of special cases is zero, which means that
* processSpecial
should never be called for them.
*/
- public int processSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
// This method must be overridden by all subclasses with any special case.
throw new IllegalStateException("A processor with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$
}
@@ -252,7 +252,7 @@ public class STextProcessor {
* 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, STextDirections dirProps, int[] offsets, int offset) {
+ public static final void insertMark(String text, STextCharTypes dirProps, int[] offsets, int offset) {
STextImpl.insertMark(text, dirProps, offsets, offset);
}
@@ -287,7 +287,7 @@ public class STextProcessor {
* It must be a non-negative number smaller than the length
* of the lean text.
*/
- public static final void processSeparator(String text, STextDirections dirProps, int[] offsets, int separLocation) {
+ public static final void processSeparator(String text, STextCharTypes dirProps, int[] offsets, int separLocation) {
STextImpl.processSeparator(text, dirProps, offsets, separLocation);
}
@@ -303,19 +303,38 @@ public class STextProcessor {
* {@link STextEnvironment#DEFAULT DEFAULT}
* environment should be assumed.
*
- * @param text is the structured text string to process.
- *
- * @param dirProps is a parameter received uniquely to be used as argument
- * for calls to getDirProp
and other methods used
- * by processors.
- *
* @return a string grouping one-character separators which separate
* the structured text into tokens.
*/
- public String getSeparators(STextEnvironment environment, String text, STextDirections dirProps) {
+ 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.
+ *
+ * If not overridden, this method returns DIR_LTR
.
+ *
null
, 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.getDirProp
and other methods used
- * by processors.
- *
* @return the number of special cases for the associated processor.
* Special cases exist for some types of structured text
* processors. They are implemented by overriding methods
@@ -373,7 +386,7 @@ public class STextProcessor {
* anything which is not identified by a one-character separator.
*
*/
- public int getSpecialsCount(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment environment) {
return 0;
}
@@ -402,7 +415,7 @@ public class STextProcessor {
* text to add directional formatting characters.
*
*/
- public boolean skipProcessing(STextEnvironment environment, String text, STextDirections dirProps) {
+ public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes dirProps) {
return false;
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
index dd0bc3a0a..3a0cc7acb 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
@@ -11,7 +11,7 @@
package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -44,7 +44,7 @@ public abstract class STextDelims extends STextProcessor {
*
* @see #getDelimiters
*/
- public int indexOfSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int caseNumber, int fromIndex) {
char delim = getDelimiters().charAt((caseNumber - 1) * 2);
return text.indexOf(delim, fromIndex);
}
@@ -59,7 +59,7 @@ public abstract class STextDelims extends STextProcessor {
* @return the position after the matching end delimiter, or the length
* of text
if no end delimiter is found.
*/
- public int processSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
int loc = separLocation + 1;
char delim = getDelimiters().charAt((caseNumber * 2) - 1);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
index 25438e684..e583e9e1c 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
@@ -11,7 +11,7 @@
package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -50,7 +50,7 @@ public abstract class STextDelimsEsc extends STextDelims {
* and skips until after the matching end delimiter,
* ignoring possibly escaped end delimiters.
*/
- public int processSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
int location = separLocation + 1;
char delim = getDelimiters().charAt((caseNumber * 2) - 1);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
index a980eeeb6..5a4064508 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -65,10 +65,10 @@ public class STextImpl {
// nothing to do
}
- static long computeNextLocation(STextProcessor processor, STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int[] locations, int[] state, int curPos) {
- String separators = processor.getSeparators(environment, text, dirProps);
+ static long computeNextLocation(STextProcessor processor, STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int[] locations, int[] state, int curPos) {
+ String separators = processor.getSeparators(environment);
int separCount = separators.length();
- int specialsCount = processor.getSpecialsCount(environment, text, dirProps);
+ int specialsCount = processor.getSpecialsCount(environment);
int len = text.length();
int nextLocation = len;
int idxLocation = 0;
@@ -107,7 +107,7 @@ public class STextImpl {
/**
* @see STextProcessor#processSeparator STextProcessor.processSeparator
*/
- public static void processSeparator(String text, STextDirections dirProps, int[] offsets, int separLocation) {
+ public static void processSeparator(String text, STextCharTypes dirProps, int[] offsets, int separLocation) {
int len = text.length();
// offsets[2] contains the structured text direction
if (offsets[2] == STextEngine.DIR_RTL) {
@@ -212,7 +212,7 @@ public class STextImpl {
int len = text.length();
if (len == 0)
return text;
- STextDirections dirProps = new STextDirections(text);
+ STextCharTypes dirProps = new STextCharTypes(text);
int[] offsets = leanToFullCommon(processor, environment, text, state, dirProps);
int prefixLength = offsets[1];
int count = offsets[0] - OFFSETS_SHIFT;
@@ -263,7 +263,7 @@ public class STextImpl {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
- STextDirections dirProps = new STextDirections(text);
+ STextCharTypes dirProps = new STextCharTypes(text);
int[] offsets = leanToFullCommon(processor, environment, text, state, dirProps);
int prefixLength = offsets[1];
int[] map = new int[len];
@@ -286,7 +286,7 @@ public class STextImpl {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
- STextDirections dirProps = new STextDirections(text);
+ STextCharTypes dirProps = new STextCharTypes(text);
int[] offsets = leanToFullCommon(processor, environment, text, state, dirProps);
// offsets[0] contains the number of used entries
int count = offsets[0] - OFFSETS_SHIFT;
@@ -295,7 +295,7 @@ public class STextImpl {
return result;
}
- static int[] leanToFullCommon(STextProcessor processor, STextEnvironment environment, String text, int[] state, STextDirections dirProps) {
+ static int[] leanToFullCommon(STextProcessor processor, STextEnvironment environment, String text, int[] state, STextCharTypes dirProps) {
if (environment == null)
environment = STextEnvironment.DEFAULT;
if (state == null) {
@@ -303,7 +303,7 @@ public class STextImpl {
state[0] = STextEngine.STATE_INITIAL;
}
int len = text.length();
- int orient = dirProps.getBaseOrientation(environment);
+ int orient = dirProps.getOrientation(environment);
int direction = processor.getDirection(environment, text, dirProps);
// offsets of marks to add. Entry 0 is the number of used slots;
// entry 1 is reserved to pass prefixLength.
@@ -313,8 +313,8 @@ public class STextImpl {
offsets[2] = direction;
if (!processor.skipProcessing(environment, text, dirProps)) {
// initialize locations
- int separCount = processor.getSeparators(environment, text, dirProps).length();
- int[] locations = new int[separCount + processor.getSpecialsCount(environment, text, dirProps)];
+ 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;
}
@@ -353,7 +353,7 @@ public class STextImpl {
offsets[1] = 0;
else {
// recompute orient since it may have changed if contextual
- orient = dirProps.getBaseOrientation(environment);
+ orient = dirProps.getOrientation(environment);
if (orient == direction && orient != STextEnvironment.ORIENT_UNKNOWN)
offsets[1] = 0;
else if ((environment.getOrientation() & STextEnvironment.ORIENT_CONTEXTUAL_LTR) != 0)
@@ -376,7 +376,7 @@ public class STextImpl {
state = new int[1];
state[0] = STextEngine.STATE_INITIAL;
}
- int dir = processor.getDirection(environment, text, new STextDirections(text));
+ int dir = processor.getDirection(environment, text);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
int i; // used as loop index
@@ -468,7 +468,7 @@ public class STextImpl {
return EMPTY_INT_ARRAY;
String lean = fullToLeanText(processor, environment, full, state);
int lenLean = lean.length();
- int dir = processor.getDirection(environment, lean, new STextDirections(lean));
+ int dir = processor.getDirection(environment, lean);
char curMark = MARKS[dir];
char curEmbed = EMBEDS[dir];
int[] map = new int[lenFull];
@@ -536,7 +536,7 @@ public class STextImpl {
/**
* @see STextProcessor#insertMark STextProcessor.insertMark
*/
- public static void insertMark(String text, STextDirections dirProps, int[] offsets, int offset) {
+ public static void insertMark(String text, STextCharTypes dirProps, int[] offsets, int offset) {
int count = offsets[0];// number of used entries
int index = count - 1; // index of greatest member <= offset
// look up after which member the new offset should be inserted
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
index effffb345..4f6e3b1f7 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
@@ -11,7 +11,7 @@
package org.eclipse.equinox.bidi.internal;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -41,8 +41,8 @@ public class STextSingle extends STextProcessor {
*
* @see #getSeparators getSeparators
*/
- public int indexOfSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int caseNumber, int fromIndex) {
- return text.indexOf(this.getSeparators(environment, text, dirProps).charAt(0), fromIndex);
+ public int indexOfSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int caseNumber, int fromIndex) {
+ return text.indexOf(this.getSeparators(environment).charAt(0), fromIndex);
}
/**
@@ -51,7 +51,7 @@ public class STextSingle extends STextProcessor {
*
* @return the length of text
.
*/
- public int processSpecial(STextEnvironment environment, String text, STextDirections dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
return text.length();
}
@@ -61,7 +61,7 @@ public class STextSingle extends STextProcessor {
*
* @return 1.
*/
- public int getSpecialsCount(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment environment) {
return 1;
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
index ea52c7e78..cc8a1d20b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.internal.STextDelimsEsc;
/**
@@ -27,6 +27,10 @@ public class STextEmail extends STextDelimsEsc {
super("<>.:,;@"); //$NON-NLS-1$
}
+ public int getDirection(STextEnvironment environment, String text) {
+ return getDirection(environment, text, new STextCharTypes(text));
+ }
+
/**
* @return {@link STextEngine#DIR_RTL DIR_RTL} if the following
* conditions are satisfied:
@@ -38,7 +42,7 @@ public class STextEmail extends STextDelimsEsc {
*
* Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}.
*/
- public int getDirection(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getDirection(STextEnvironment environment, String text, STextCharTypes dirProps) {
String language = environment.getLanguage();
if (!language.equals("ar")) //$NON-NLS-1$
return STextEngine.DIR_LTR;
@@ -57,7 +61,7 @@ public class STextEmail extends STextDelimsEsc {
/**
* @return 2 as number of special cases handled by this processor.
*/
- public int getSpecialsCount(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment environment) {
return 2;
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
index 13c116db6..81b3b415d 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
import org.eclipse.equinox.bidi.internal.STextActivator;
@@ -46,7 +46,7 @@ public class STextJava extends STextProcessor {
/**
* @return 4 as the number of special cases handled by this processor.
*/
- public int getSpecialsCount(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment environment) {
return 4;
}
@@ -59,7 +59,7 @@ public class STextJava extends STextProcessor {
*