Revision: 9248
Author: [email protected]
Date: Wed Nov 17 11:26:39 2010
Log: *** Reason for rollback ***
BidiFormatter should remain immutable.
*** Original change description ***
A few small changes to BidiFormatter. Mainly, it now uses
DirectionEstimator that can be modified instead of the constant estimating
function of BidiUtils.
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9248
Modified:
/trunk/user/src/com/google/gwt/i18n/shared/BidiFormatter.java
=======================================
--- /trunk/user/src/com/google/gwt/i18n/shared/BidiFormatter.java Sun Nov
14 23:21:13 2010
+++ /trunk/user/src/com/google/gwt/i18n/shared/BidiFormatter.java Wed Nov
17 11:26:39 2010
@@ -211,8 +211,6 @@
private boolean alwaysSpan;
private Direction contextDir;
- private DirectionEstimator directionEstimator =
- WordCountDirectionEstimator.get();
/**
* @param contextDir The context direction
@@ -242,14 +240,14 @@
* Returns "dir=ltr" or "dir=rtl", depending on {...@code str}'s estimated
* direction, if it is not the same as the context direction. Otherwise,
* returns the empty string.
- *
+ *
* @param str String whose direction is to be estimated
* @param isHtml Whether {...@code str} is HTML / HTML-escaped
* @return "dir=rtl" for RTL text in non-RTL context; "dir=ltr" for LTR
text
* in non-LTR context; else, the empty string.
*/
public String dirAttr(String str, boolean isHtml) {
- return knownDirAttr(directionEstimator.estimateDirection(str, isHtml));
+ return knownDirAttr(BidiUtils.get().estimateDirection(str, isHtml));
}
/**
@@ -268,7 +266,7 @@
* @return {...@code str}'s estimated overall direction
*/
public Direction estimateDirection(String str) {
- return directionEstimator.estimateDirection(str);
+ return BidiUtils.get().estimateDirection(str);
}
/**
@@ -281,7 +279,7 @@
* @return {...@code str}'s estimated overall direction
*/
public Direction estimateDirection(String str, boolean isHtml) {
- return directionEstimator.estimateDirection(str, isHtml);
+ return BidiUtils.get().estimateDirection(str, isHtml);
}
/**
@@ -298,10 +296,6 @@
public Direction getContextDir() {
return contextDir;
}
-
- public DirectionEstimator getDirectionEstimator() {
- return directionEstimator;
- }
/**
* Returns whether the context direction is RTL.
@@ -360,12 +354,8 @@
*/
public String markAfter(String str, boolean isHtml) {
str = BidiUtils.get().stripHtmlIfNeeded(str, isHtml);
- return dirResetIfNeeded(str, directionEstimator.estimateDirection(str),
- false, true);
- }
-
- public void setDirectionEstimator(DirectionEstimator directionEstimator)
{
- this.directionEstimator = directionEstimator;
+ return dirResetIfNeeded(str, BidiUtils.get().estimateDirection(str),
false,
+ true);
}
/**
@@ -417,7 +407,7 @@
* @return Input string after applying the above processing.
*/
public String spanWrap(String str, boolean isHtml, boolean dirReset) {
- Direction dir = directionEstimator.estimateDirection(str, isHtml);
+ Direction dir = BidiUtils.get().estimateDirection(str, isHtml);
return spanWrapWithKnownDir(dir, str, isHtml, dirReset);
}
@@ -555,7 +545,7 @@
* @return Input string after applying the above processing.
*/
public String unicodeWrap(String str, boolean isHtml, boolean dirReset) {
- Direction dir = directionEstimator.estimateDirection(str, isHtml);
+ Direction dir = BidiUtils.get().estimateDirection(str, isHtml);
return unicodeWrapWithKnownDir(dir, str, isHtml, dirReset);
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors