Package com.google.gwt.i18n.shared
Class BidiFormatterBase
java.lang.Object
com.google.gwt.i18n.shared.BidiFormatterBase
- Direct Known Subclasses:
BidiFormatter,SafeHtmlBidiFormatter
Base class for
BidiFormatter and SafeHtmlBidiFormatter that
contains their common implementation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classBidiFormatterBase.Factory<T extends BidiFormatterBase>Abstract factory class for BidiFormatterBase.(package private) static final classA container class for direction-related string constants, e.g. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBidiFormatterBase(HasDirection.Direction contextDir, boolean alwaysSpan) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringdirAttrBase(String str, boolean isHtml) protected StringestimateDirection(String str) LikeestimateDirection(String, boolean), but assumesisHtmlis false.estimateDirection(String str, boolean isHtml) Estimates the direction of a string using the best known general-purpose method, i.e.booleanReturns 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.Returns the context direction.booleanReturns whether the context direction is RTL.protected Stringprotected StringmarkAfterBase(String str, boolean isHtml) protected StringmarkBase()protected StringspanWrapBase(String str, boolean isHtml, boolean dirReset) protected StringspanWrapWithKnownDirBase(HasDirection.Direction dir, String str, boolean isHtml, boolean dirReset) protected Stringprotected StringunicodeWrapBase(String str, boolean isHtml, boolean dirReset) protected StringunicodeWrapWithKnownDirBase(HasDirection.Direction dir, String str, boolean isHtml, boolean dirReset)
-
Constructor Details
-
BidiFormatterBase
-
-
Method Details
-
estimateDirection
LikeestimateDirection(String, boolean), but assumesisHtmlis false.- Parameters:
str- String whose direction is to be estimated- Returns:
str's estimated overall direction
-
estimateDirection
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 estimatedisHtml- Whetherstris 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
Returns the context direction. -
isRtlContext
public boolean isRtlContext()Returns whether the context direction is RTL. -
dirAttrBase
- Parameters:
str- String whose direction is to be estimatedisHtml- Whetherstris 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
- See Also:
-
knownDirAttrBase
- 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
- Parameters:
str- String after which the mark may need to appearisHtml- Whetherstris 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
- See Also:
-
spanWrapBase
- Parameters:
str- The input stringisHtml- Whetherstris HTML / HTML-escapeddirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followstr- 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 directionstr- The input stringisHtml- Whetherstris HTML / HTML-escapeddirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followstr- Returns:
- Input string after applying the above processing.
- See Also:
-
startEdgeBase
- See Also:
-
unicodeWrapBase
- Parameters:
str- The input stringisHtml- Whetherstris HTML / HTML-escapeddirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followstr- 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 directionstr- The input stringisHtml- Whetherstris HTML / HTML-escapeddirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followstr- Returns:
- Input string after applying the above processing.
- See Also:
-