Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java24
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java14
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java (renamed from bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextDirections.java)15
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java53
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java32
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java10
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java10
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java14
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java8
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java3
16 files changed, 120 insertions, 94 deletions
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/STextDirections.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java
index bc469bb78..50d768dd0 100644
--- 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/STextCharTypes.java
@@ -15,7 +15,7 @@ import org.eclipse.equinox.bidi.STextEnvironment;
/**
* The class determines bidirectional types of characters in a string.
*/
-public class STextDirections {
+public class STextCharTypes {
// In the following lines, B, L, R and AL represent bidi categories
// as defined in the Unicode Bidirectional Algorithm
@@ -41,9 +41,9 @@ public class STextDirections {
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.
+ private int orientation = -1; // "-1" means "unknown"
- public STextDirections(String text) {
+ public STextCharTypes(String text) {
this.text = text;
dirProps = new byte[text.length()];
}
@@ -65,7 +65,7 @@ public class STextDirections {
dirProps[i] = (byte) (dirProp + DIRPROPS_ADD);
}
- public int getBaseOrientation(STextEnvironment environment) {
+ public int getOrientation(STextEnvironment environment) {
int result;
int orient = environment.getOrientation();
if ((orient & STextEnvironment.ORIENT_CONTEXTUAL_LTR) == 0) { // absolute orientation
@@ -83,7 +83,7 @@ public class STextDirections {
} else {
dirProp = getCachedDirectionAt(i);
}
- if (dirProp == L) { // TBD || == EN ?
+ if (dirProp == L) {
result = STextEnvironment.ORIENT_LTR;
break;
}
@@ -93,7 +93,7 @@ public class STextDirections {
}
}
}
- baseOrientation = (byte) result;
+ orientation = result;
return result;
}
@@ -109,8 +109,7 @@ public class STextDirections {
return getCachedDirectionAt(index);
byte dirProp = Character.getDirectionality(text.charAt(index));
if (dirProp == B) {
- byte orient = baseOrientation;
- dirProp = (orient == STextEnvironment.ORIENT_RTL) ? R : L;
+ 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/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
* <code>indexOfSpecial</code> 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
* <code>processSpecial</code> 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 <i>lean</i> 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,16 +303,10 @@ 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 <code>getDirProp</code> 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;
}
@@ -330,6 +324,31 @@ public class STextProcessor {
*
* @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 STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}.
+ */
+ public int getDirection(STextEnvironment environment, String text) {
+ return STextEngine.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 dirProps is a parameter received uniquely to be used as argument
* for calls to <code>getDirProp</code> and other methods used
* by processors.
@@ -341,7 +360,7 @@ public class STextProcessor {
* The value returned is either
* {@link STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}.
*/
- public int getDirection(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getDirection(STextEnvironment environment, String text, STextCharTypes dirProps) {
return STextEngine.DIR_LTR;
}
@@ -359,12 +378,6 @@ 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 <code>getDirProp</code> and other methods used
- * by processors.
- *
* @return the number of special cases for the associated processor.
* Special cases exist for some types of structured text
* processors. They are implemented by overriding methods
@@ -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 <code>text</code> 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 <code>text</code>.
*/
- 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 {
* </ul>
* 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 {
* <li>comments starting with slash-slash</li>
* </ol>
*/
- 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) {
switch (caseNumber) {
case 1 : /* space */
return text.indexOf(' ', fromIndex);
@@ -83,7 +83,7 @@ public class STextJava extends STextProcessor {
* <li>skip until after a line separator</li>
* </ol>
*/
- 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) {
int location, counter, i;
STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
index 0f130f93c..69d7a284b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java
@@ -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;
/**
@@ -29,6 +29,10 @@ public class STextMath extends STextProcessor {
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:
@@ -41,7 +45,7 @@ public class STextMath extends STextProcessor {
* </ul>
* 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;
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
index 214eb575b..56b1baa24 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEngine;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
import org.eclipse.equinox.bidi.custom.STextProcessor;
/**
@@ -69,7 +69,7 @@ public class STextRegex extends STextProcessor {
*
* @return the number of special cases for this processor.
*/
- public int getSpecialsCount(STextEnvironment environment, String text, STextDirections dirProps) {
+ public int getSpecialsCount(STextEnvironment environment) {
return maxSpecial;
}
@@ -77,7 +77,7 @@ public class STextRegex extends STextProcessor {
* This method locates occurrences of the syntactic strings and of
* R, AL, EN, AN characters.
*/
- 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) {
// In this method, L, R, AL, AN and EN represent bidi categories
// as defined in the Unicode Bidirectional Algorithm
// ( http://www.unicode.org/reports/tr9/ ).
@@ -145,7 +145,7 @@ public class STextRegex extends STextProcessor {
/**
* This method process the special cases.
*/
- 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) {
int location;
switch (caseNumber) {
@@ -215,6 +215,10 @@ public class STextRegex extends STextProcessor {
return text.length();
}
+ 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:
@@ -227,7 +231,7 @@ public class STextRegex extends STextProcessor {
* </ul>
* 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;
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
index e45af3218..426d7328c 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
@@ -12,7 +12,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 STextSql extends STextProcessor {
/**
* @return 5 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 5;
}
@@ -60,7 +60,7 @@ public class STextSql extends STextProcessor {
* <li>comments starting with hyphen-hyphen</li>
* </ol>
*/
- 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) {
switch (caseNumber) {
case 1 : /* space */
return text.indexOf(" ", fromIndex); //$NON-NLS-1$
@@ -87,7 +87,7 @@ public class STextSql extends STextProcessor {
* <li>skip until after a line separator</li>
* </ol>
*/
- 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) {
int location;
STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java
index cef45e5e6..7ead88bba 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextEnvironment;
-import org.eclipse.equinox.bidi.custom.STextDirections;
import org.eclipse.equinox.bidi.internal.STextDelims;
/**
@@ -26,7 +25,7 @@ public class STextXPath extends STextDelims {
/**
* @return 2 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 2;
}

Back to the top