Package com.google.gwt.i18n.shared
Class BidiFormatterBase
- java.lang.Object
-
- com.google.gwt.i18n.shared.BidiFormatterBase
-
- Direct Known Subclasses:
BidiFormatter
,SafeHtmlBidiFormatter
public abstract class BidiFormatterBase extends java.lang.Object
Base class forBidiFormatter
andSafeHtmlBidiFormatter
that contains their common implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BidiFormatterBase.Factory<T extends BidiFormatterBase>
Abstract factory class for BidiFormatterBase.(package private) static class
BidiFormatterBase.Format
A container class for direction-related string constants, e.g.
-
Constructor Summary
Constructors Modifier Constructor Description protected
BidiFormatterBase(HasDirection.Direction contextDir, boolean alwaysSpan)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
dirAttrBase(java.lang.String str, boolean isHtml)
protected java.lang.String
endEdgeBase()
HasDirection.Direction
estimateDirection(java.lang.String str)
LikeestimateDirection(String, boolean)
, but assumesisHtml
is false.HasDirection.Direction
estimateDirection(java.lang.String str, boolean isHtml)
Estimates the direction of a string using the best known general-purpose method, i.e.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.HasDirection.Direction
getContextDir()
Returns the context direction.boolean
isRtlContext()
Returns whether the context direction is RTL.protected java.lang.String
knownDirAttrBase(HasDirection.Direction dir)
protected java.lang.String
markAfterBase(java.lang.String str, boolean isHtml)
protected java.lang.String
markBase()
protected java.lang.String
spanWrapBase(java.lang.String str, boolean isHtml, boolean dirReset)
protected java.lang.String
spanWrapWithKnownDirBase(HasDirection.Direction dir, java.lang.String str, boolean isHtml, boolean dirReset)
protected java.lang.String
startEdgeBase()
protected java.lang.String
unicodeWrapBase(java.lang.String str, boolean isHtml, boolean dirReset)
protected java.lang.String
unicodeWrapWithKnownDirBase(HasDirection.Direction dir, java.lang.String str, boolean isHtml, boolean dirReset)
-
-
-
Constructor Detail
-
BidiFormatterBase
protected BidiFormatterBase(HasDirection.Direction contextDir, boolean alwaysSpan)
-
-
Method Detail
-
estimateDirection
public HasDirection.Direction estimateDirection(java.lang.String str)
LikeestimateDirection(String, boolean)
, but assumesisHtml
is false.- Parameters:
str
- String whose direction is to be estimated- Returns:
str
's estimated overall direction
-
estimateDirection
public HasDirection.Direction estimateDirection(java.lang.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 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
public HasDirection.Direction getContextDir()
Returns the context direction.
-
isRtlContext
public boolean isRtlContext()
Returns whether the context direction is RTL.
-
dirAttrBase
protected java.lang.String dirAttrBase(java.lang.String str, boolean isHtml)
- 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:
BidiFormatter.dirAttr(String, boolean)
-
endEdgeBase
protected java.lang.String endEdgeBase()
- See Also:
BidiFormatter.endEdge()
-
knownDirAttrBase
protected java.lang.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:
BidiFormatter.knownDirAttr(HasDirection.Direction)
-
markAfterBase
protected java.lang.String markAfterBase(java.lang.String str, boolean isHtml)
- 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:
BidiFormatter.markAfter(String, boolean)
-
markBase
protected java.lang.String markBase()
- See Also:
BidiFormatter.mark()
-
spanWrapBase
protected java.lang.String spanWrapBase(java.lang.String str, boolean isHtml, boolean dirReset)
- 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:
BidiFormatter.spanWrap(String, boolean, boolean)
-
spanWrapWithKnownDirBase
protected java.lang.String spanWrapWithKnownDirBase(HasDirection.Direction dir, java.lang.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:
BidiFormatter.spanWrapWithKnownDir(HasDirection.Direction, String, boolean, boolean)
-
startEdgeBase
protected java.lang.String startEdgeBase()
- See Also:
BidiFormatter.startEdge()
-
unicodeWrapBase
protected java.lang.String unicodeWrapBase(java.lang.String str, boolean isHtml, boolean dirReset)
- 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:
BidiFormatter.unicodeWrap(String, boolean, boolean)
-
unicodeWrapWithKnownDirBase
protected java.lang.String unicodeWrapWithKnownDirBase(HasDirection.Direction dir, java.lang.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:
BidiFormatter.unicodeWrapWithKnownDir(HasDirection.Direction, String, boolean, boolean)
-
-