Class BidiFormatterBase

java.lang.Object
com.google.gwt.i18n.shared.BidiFormatterBase
Direct Known Subclasses:
BidiFormatter, SafeHtmlBidiFormatter

public abstract class BidiFormatterBase extends Object
Base class for BidiFormatter and SafeHtmlBidiFormatter that contains their common implementation.
  • Constructor Details

  • Method Details

    • estimateDirection

      public HasDirection.Direction estimateDirection(String str)
      Like estimateDirection(String, boolean), but assumes isHtml is false.
      Parameters:
      str - String whose direction is to be estimated
      Returns:
      str's estimated overall direction
    • estimateDirection

      public HasDirection.Direction estimateDirection(String str, boolean isHtml)
      Estimates the direction of a string using the best known general-purpose method, i.e. using relative word counts. Direction.DEFAULT return value indicates completely neutral input.
      Parameters:
      str - String whose direction is to be estimated
      isHtml - Whether str is HTML / HTML-escaped
      Returns:
      str's estimated overall direction
    • getAlwaysSpan

      public boolean getAlwaysSpan()
      Returns whether the span structure added by the formatter should be stable, i.e., spans added even when the direction does not need to be declared.
    • getContextDir

      public HasDirection.Direction getContextDir()
      Returns the context direction.
    • isRtlContext

      public boolean isRtlContext()
      Returns whether the context direction is RTL.
    • dirAttrBase

      protected String dirAttrBase(String str, boolean isHtml)
      Parameters:
      str - String whose direction is to be estimated
      isHtml - Whether str is HTML / HTML-escaped
      Returns:
      "dir=rtl" for RTL text in non-RTL context; "dir=ltr" for LTR text in non-LTR context; else, the empty string.
      See Also:
    • endEdgeBase

      protected String endEdgeBase()
      See Also:
    • knownDirAttrBase

      protected String knownDirAttrBase(HasDirection.Direction dir)
      Parameters:
      dir - Given direction
      Returns:
      "dir=rtl" for RTL text in non-RTL context; "dir=ltr" for LTR text in non-LTR context; else, the empty string.
      See Also:
    • markAfterBase

      protected String markAfterBase(String str, boolean isHtml)
      Parameters:
      str - String after which the mark may need to appear
      isHtml - Whether str is HTML / HTML-escaped
      Returns:
      LRM for RTL text in LTR context; RLM for LTR text in RTL context; else, the empty string.
      See Also:
    • markBase

      protected String markBase()
      See Also:
    • spanWrapBase

      protected String spanWrapBase(String str, boolean isHtml, boolean dirReset)
      Parameters:
      str - The input string
      isHtml - Whether str is HTML / HTML-escaped
      dirReset - Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may follow str
      Returns:
      Input string after applying the above processing.
      See Also:
    • spanWrapWithKnownDirBase

      protected String spanWrapWithKnownDirBase(HasDirection.Direction dir, String str, boolean isHtml, boolean dirReset)
      Parameters:
      dir - str's direction
      str - The input string
      isHtml - Whether str is HTML / HTML-escaped
      dirReset - Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may follow str
      Returns:
      Input string after applying the above processing.
      See Also:
    • startEdgeBase

      protected String startEdgeBase()
      See Also:
    • unicodeWrapBase

      protected String unicodeWrapBase(String str, boolean isHtml, boolean dirReset)
      Parameters:
      str - The input string
      isHtml - Whether str is HTML / HTML-escaped
      dirReset - Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may follow str
      Returns:
      Input string after applying the above processing.
      See Also:
    • unicodeWrapWithKnownDirBase

      protected String unicodeWrapWithKnownDirBase(HasDirection.Direction dir, String str, boolean isHtml, boolean dirReset)
      Parameters:
      dir - str's direction
      str - The input string
      isHtml - Whether str is HTML / HTML-escaped
      dirReset - Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may follow str
      Returns:
      Input string after applying the above processing.
      See Also: