*** 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: aharon@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9248 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/i18n/shared/BidiFormatter.java b/user/src/com/google/gwt/i18n/shared/BidiFormatter.java
index a043fe5..69e1221 100644
--- a/user/src/com/google/gwt/i18n/shared/BidiFormatter.java
+++ b/user/src/com/google/gwt/i18n/shared/BidiFormatter.java
@@ -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);
   }
 
   /**
@@ -299,10 +297,6 @@
     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);
   }