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
Modifier and TypeClassDescriptionprotected static class
BidiFormatterBase.Factory<T extends BidiFormatterBase>
Abstract factory class for BidiFormatterBase.(package private) static final class
A container class for direction-related string constants, e.g. -
Constructor Summary
ModifierConstructorDescriptionprotected
BidiFormatterBase
(HasDirection.Direction contextDir, boolean alwaysSpan) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
dirAttrBase
(String str, boolean isHtml) protected String
estimateDirection
(String str) LikeestimateDirection(String, boolean)
, but assumesisHtml
is false.estimateDirection
(String str, boolean isHtml) Estimates the direction of a string using the best known general-purpose method, i.e.boolean
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.Returns the context direction.boolean
Returns whether the context direction is RTL.protected String
protected String
markAfterBase
(String str, boolean isHtml) protected String
markBase()
protected String
spanWrapBase
(String str, boolean isHtml, boolean dirReset) protected String
spanWrapWithKnownDirBase
(HasDirection.Direction dir, String str, boolean isHtml, boolean dirReset) protected String
protected String
unicodeWrapBase
(String str, boolean isHtml, boolean dirReset) protected String
unicodeWrapWithKnownDirBase
(HasDirection.Direction dir, String str, boolean isHtml, boolean dirReset)
-
Constructor Details
-
BidiFormatterBase
-
-
Method Details
-
estimateDirection
LikeestimateDirection(String, boolean)
, but assumesisHtml
is 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
- Whetherstr
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
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
- Whetherstr
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
- 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
- Whetherstr
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
- See Also:
-
spanWrapBase
- Parameters:
str
- The input stringisHtml
- Whetherstr
is 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
- Whetherstr
is 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
- Whetherstr
is 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
- Whetherstr
is 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:
-