aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-07-27 14:55:00 (EDT)
committerOleg Besedin2011-07-27 15:30:44 (EDT)
commit9756afe6670ad80bb7f376fc87fc73f7a3082cf4 (patch)
tree7b91b0eed6c2c5175c9dbe817b70ce905ba83ca9
parentb7cf1b1837caf9691753413b9e42103d312d4347 (diff)
downloadrt.equinox.bundles-9756afe6670ad80bb7f376fc87fc73f7a3082cf4.zip
rt.equinox.bundles-9756afe6670ad80bb7f376fc87fc73f7a3082cf4.tar.gz
rt.equinox.bundles-9756afe6670ad80bb7f376fc87fc73f7a3082cf4.tar.bz2
Bug 183164 turning dirProps into API
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java1
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextDirections.java32
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java19
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java10
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java2
9 files changed, 29 insertions, 45 deletions
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 933f761..cb9b589 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
@@ -40,7 +40,7 @@ public class STextMethodsTest extends STextTestBase {
}
public boolean skipProcessing(STextEnvironment environment, String text, STextDirections dirProps) {
- byte dirProp = dirProps.getOrientationAt(0);
+ byte dirProp = dirProps.getBidiTypeAt(0);
if (dirProp == AL)
return true;
return false;
@@ -48,7 +48,7 @@ public class STextMethodsTest extends STextTestBase {
public int getDirection(STextEnvironment environment, String text, STextDirections dirProps) {
for (int i = 0; i < text.length(); i++) {
- byte dirProp = dirProps.getOrientationAt(i);
+ byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == AL)
return dirArabic;
}
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 df2201a..512e28b 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
@@ -296,7 +296,6 @@ public class STextEngine {
return STextImpl.fullBidiCharOffsets(processor, environment, text, state);
}
- // TBD why is this method here and not just in the processor? Is it interesting in general?
/**
* Get the base direction of a structured text. This base direction may depend on
* whether the text contains Arabic or Hebrew words. If the text contains both,
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
index 2d1e5ef..bc469bb 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/STextDirections.java
@@ -33,11 +33,7 @@ public class STextDirections {
static final byte AN = Character.DIRECTIONALITY_ARABIC_NUMBER;
static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
- // TBD consider moving L, R, AL, AN, EN, B into this class from STextImpl
- // TBD add methods:
- // isRTL (dirProp == R || dirProp == AL)
- // isLTR (dirProp == L || dirProp == EN)
- // isStrong (isRTL() || isLTR() || dirProp == AN) <= excludes unknown, B, WS
+ private static final int DIRPROPS_ADD = 2;
final protected String text;
@@ -45,23 +41,15 @@ public class STextDirections {
private byte[] dirProps;
// current orientation
- private byte baseOrientation = 0; // "0" means "unknown"
+ 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()];
}
- public void setBaseOrientation(byte orientation) {
- baseOrientation = orientation;
- }
-
- public byte getBaseOrientation() {
- return baseOrientation;
- }
-
private byte getCachedDirectionAt(int index) {
- return (byte) (dirProps[index] - 1);
+ return (byte) (dirProps[index] - DIRPROPS_ADD);
}
private boolean hasCachedDirectionAt(int i) {
@@ -73,8 +61,8 @@ public class STextDirections {
* one of the values which can be returned by
* <code>java.lang.Character.getDirectionality</code>.
*/
- public void setOrientationAt(int i, byte dirProp) {
- dirProps[i] = (byte) (dirProp + 1);
+ public void setBidiTypeAt(int i, byte dirProp) {
+ dirProps[i] = (byte) (dirProp + DIRPROPS_ADD);
}
public int getBaseOrientation(STextEnvironment environment) {
@@ -91,7 +79,7 @@ public class STextDirections {
dirProp = Character.getDirectionality(text.charAt(i));
if (dirProp == B) // B char resolves to L or R depending on orientation
continue;
- setOrientationAt(i, dirProp);
+ setBidiTypeAt(i, dirProp);
} else {
dirProp = getCachedDirectionAt(i);
}
@@ -104,8 +92,6 @@ public class STextDirections {
break;
}
}
- if (result == -1) // return the default orientation minus contextual bit
- result = orient & 1;
}
baseOrientation = (byte) result;
return result;
@@ -118,15 +104,15 @@ public class STextDirections {
* @return the bidirectional class of the character. It is one of the
* values which can be returned by {@link Character#getDirectionality(char)}
*/
- public byte getOrientationAt(int index) {
+ public byte getBidiTypeAt(int index) {
if (hasCachedDirectionAt(index))
return getCachedDirectionAt(index);
byte dirProp = Character.getDirectionality(text.charAt(index));
if (dirProp == B) {
- byte orient = getBaseOrientation();
+ byte orient = baseOrientation;
dirProp = (orient == STextEnvironment.ORIENT_RTL) ? R : L;
}
- setOrientationAt(index, dirProp);
+ setBidiTypeAt(index, dirProp);
return dirProp;
}
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 f7d7c35..a980eee 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
@@ -113,12 +113,12 @@ public class STextImpl {
if (offsets[2] == STextEngine.DIR_RTL) {
// the structured text base direction is RTL
for (int i = separLocation - 1; i >= 0; i--) {
- byte dirProp = dirProps.getOrientationAt(i);
+ byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == R || dirProp == AL)
return;
if (dirProp == L) {
for (int j = separLocation; j < len; j++) {
- dirProp = dirProps.getOrientationAt(j);
+ dirProp = dirProps.getBidiTypeAt(j);
if (dirProp == R || dirProp == AL)
return;
if (dirProp == L || dirProp == EN) {
@@ -135,12 +135,12 @@ public class STextImpl {
// the structured text base direction is LTR
boolean doneAN = false;
for (int i = separLocation - 1; i >= 0; i--) {
- byte dirProp = dirProps.getOrientationAt(i);
+ byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == L)
return;
if (dirProp == R || dirProp == AL) {
for (int j = separLocation; j < len; j++) {
- dirProp = dirProps.getOrientationAt(j);
+ dirProp = dirProps.getBidiTypeAt(j);
if (dirProp == L)
return;
if (dirProp == R || dirProp == EN || dirProp == AL || dirProp == AN) {
@@ -152,7 +152,7 @@ public class STextImpl {
}
if (dirProp == AN && !doneAN) {
for (int j = separLocation; j < len; j++) {
- dirProp = dirProps.getOrientationAt(j);
+ dirProp = dirProps.getBidiTypeAt(j);
if (dirProp == L)
return;
if (dirProp == AL || dirProp == AN || dirProp == R) {
@@ -505,19 +505,18 @@ public class STextImpl {
offsets[0] = OFFSETS_SHIFT;
int lenLean = lean.length();
int idxLean, idxFull;
- STextDirections dirProps = new STextDirections(full);
// lean must be a subset of Full, so we only check on iLean < leanLen
for (idxLean = idxFull = 0; idxLean < lenLean; idxFull++) {
if (full.charAt(idxFull) == lean.charAt(idxLean))
idxLean++;
else {
offsets = ensureRoomInOffsets(offsets);
- insertMark(lean, dirProps, offsets, idxFull);
+ insertMark(lean, null, offsets, idxFull);
}
}
for (; idxFull < lenFull; idxFull++) {
offsets = ensureRoomInOffsets(offsets);
- insertMark(lean, dirProps, offsets, idxFull);
+ insertMark(lean, null, offsets, idxFull);
}
int[] result = new int[offsets[0] - OFFSETS_SHIFT];
System.arraycopy(offsets, OFFSETS_SHIFT, result, 0, result.length);
@@ -559,7 +558,7 @@ public class STextImpl {
if (dirProps == null || offset < 1)
return;
- byte dirProp = dirProps.getOrientationAt(offset);
+ byte dirProp = dirProps.getBidiTypeAt(offset);
// if the current char is a strong one or a digit, we change the
// dirProp of the previous char to account for the inserted mark.
if (dirProp == L || dirProp == R || dirProp == AL || dirProp == EN || dirProp == AN)
@@ -569,7 +568,7 @@ public class STextImpl {
index = offset;
int dir = offsets[2]; // current structured text direction
- dirProps.setOrientationAt(index, STRONGS[dir]);
+ dirProps.setBidiTypeAt(index, STRONGS[dir]);
return;
}
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 bed40f5..ea52c7e 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
@@ -47,7 +47,7 @@ public class STextEmail extends STextDelimsEsc {
if (domainStart < 0)
domainStart = 0;
for (int i = domainStart; i < text.length(); i++) {
- byte dirProp = dirProps.getOrientationAt(i);
+ byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == AL || dirProp == R)
return STextEngine.DIR_RTL;
}
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 6c57928..13c116d 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
@@ -91,7 +91,7 @@ public class STextJava extends STextProcessor {
case 1 : /* space */
separLocation++;
while (separLocation < text.length() && text.charAt(separLocation) == ' ') {
- dirProps.setOrientationAt(separLocation, WS);
+ dirProps.setBidiTypeAt(separLocation, WS);
separLocation++;
}
return 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 6b3768b..0f130f9 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
@@ -47,7 +47,7 @@ public class STextMath extends STextProcessor {
return STextEngine.DIR_LTR;
boolean flagAN = false;
for (int i = 0; i < text.length(); i++) {
- byte dirProp = dirProps.getOrientationAt(i);
+ byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == AL)
return STextEngine.DIR_RTL;
if (dirProp == L || dirProp == R)
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 36c76fd..214eb57 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
@@ -113,18 +113,18 @@ public class STextRegex extends STextProcessor {
fromIndex = 1;
// look for R, AL, AN, EN which are potentially needing a mark
for (; fromIndex < text.length(); fromIndex++) {
- dirProp = dirProps.getOrientationAt(fromIndex);
+ dirProp = dirProps.getBidiTypeAt(fromIndex);
// R and AL will always be examined using processSeparator()
if (dirProp == R || dirProp == AL)
return fromIndex;
if (dirProp == EN || dirProp == AN) {
// no need for a mark after the first digit in a number
- if (dirProps.getOrientationAt(fromIndex - 1) == dirProp)
+ if (dirProps.getBidiTypeAt(fromIndex - 1) == dirProp)
continue;
for (int i = fromIndex - 1; i >= 0; i--) {
- dirProp = dirProps.getOrientationAt(i);
+ dirProp = dirProps.getBidiTypeAt(i);
// after a L char, no need for a mark
if (dirProp == L)
continue;
@@ -204,7 +204,7 @@ public class STextRegex extends STextProcessor {
return text.length();
}
// set the dirProp for the "E" to L (Left to Right character)
- dirProps.setOrientationAt(location + 1, L);
+ dirProps.setBidiTypeAt(location + 1, L);
return location + 2;
case 18 : /* R, AL, AN, EN */
STextProcessor.processSeparator(text, dirProps, offsets, separLocation);
@@ -232,7 +232,7 @@ public class STextRegex extends STextProcessor {
if (!language.equals("ar")) //$NON-NLS-1$
return STextEngine.DIR_LTR;
for (int i = 0; i < text.length(); i++) {
- byte dirProp = dirProps.getOrientationAt(i);
+ byte dirProp = dirProps.getBidiTypeAt(i);
if (dirProp == AL || dirProp == R)
return STextEngine.DIR_RTL;
if (dirProp == L)
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 9446545..e45af32 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
@@ -95,7 +95,7 @@ public class STextSql extends STextProcessor {
case 1 : /* space */
separLocation++;
while (separLocation < text.length() && text.charAt(separLocation) == ' ') {
- dirProps.setOrientationAt(separLocation, WS);
+ dirProps.setBidiTypeAt(separLocation, WS);
separLocation++;
}
return separLocation;