Package com.google.gwt.i18n.shared
Class SafeHtmlBidiFormatter
- java.lang.Object
-
- com.google.gwt.i18n.shared.BidiFormatterBase
-
- com.google.gwt.i18n.shared.SafeHtmlBidiFormatter
-
public class SafeHtmlBidiFormatter extends BidiFormatterBase
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSafeHtmlBidiFormatter.Factory-
Nested classes/interfaces inherited from class com.google.gwt.i18n.shared.BidiFormatterBase
BidiFormatterBase.Format
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SafeHtmldirAttr(SafeHtml html)SafeHtmldirAttr(java.lang.String str)SafeHtmlendEdge()Returns "left" for RTL context direction.HasDirection.DirectionestimateDirection(SafeHtml html)static SafeHtmlBidiFormattergetInstance(boolean rtlContext)Factory for creating an instance of SafeHtmlBidiFormatter given the context direction.static SafeHtmlBidiFormattergetInstance(boolean rtlContext, boolean alwaysSpan)Factory for creating an instance of SafeHtmlBidiFormatter given the context direction and the desired span wrapping behavior (see below).static SafeHtmlBidiFormattergetInstance(HasDirection.Direction contextDir)Factory for creating an instance of SafeHtmlBidiFormatter given the context direction.static SafeHtmlBidiFormattergetInstance(HasDirection.Direction contextDir, boolean alwaysSpan)Factory for creating an instance of SafeHtmlBidiFormatter given the context direction and the desired span wrapping behavior (see below).static SafeHtmlBidiFormattergetInstanceForCurrentLocale()Factory for creating an instance of SafeHtmlBidiFormatter whose context direction matches the current locale's direction.static SafeHtmlBidiFormattergetInstanceForCurrentLocale(boolean alwaysSpan)Factory for creating an instance of SafeHtmlBidiFormatter whose context direction matches the current locale's direction, and given the desired span wrapping behavior (see below).SafeHtmlknownDirAttr(HasDirection.Direction dir)SafeHtmlmark()SafeHtmlmarkAfter(SafeHtml html)SafeHtmlmarkAfter(java.lang.String str)SafeHtmlspanWrap(SafeHtml html)SafeHtmlspanWrap(SafeHtml html, boolean dirReset)SafeHtmlspanWrap(java.lang.String str)SafeHtmlspanWrap(java.lang.String str, boolean dirReset)SafeHtmlspanWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html)SafeHtmlspanWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html, boolean dirReset)SafeHtmlspanWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str)SafeHtmlspanWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str, boolean dirReset)SafeHtmlstartEdge()Returns "right" for RTL context direction.SafeHtmlunicodeWrap(SafeHtml html)SafeHtmlunicodeWrap(SafeHtml html, boolean dirReset)SafeHtmlunicodeWrap(java.lang.String str)SafeHtmlunicodeWrap(java.lang.String str, boolean dirReset)SafeHtmlunicodeWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html)SafeHtmlunicodeWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html, boolean dirReset)SafeHtmlunicodeWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str)SafeHtmlunicodeWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str, boolean dirReset)-
Methods inherited from class com.google.gwt.i18n.shared.BidiFormatterBase
dirAttrBase, endEdgeBase, estimateDirection, estimateDirection, getAlwaysSpan, getContextDir, isRtlContext, knownDirAttrBase, markAfterBase, markBase, spanWrapBase, spanWrapWithKnownDirBase, startEdgeBase, unicodeWrapBase, unicodeWrapWithKnownDirBase
-
-
-
-
Method Detail
-
getInstance
public static SafeHtmlBidiFormatter getInstance(boolean rtlContext)
Factory for creating an instance of SafeHtmlBidiFormatter given the context direction. The default behavior ofspanWrap(com.google.gwt.safehtml.shared.SafeHtml)and its variations is set to avoid span wrapping unless it's necessary ('dir' attribute needs to be set).- Parameters:
rtlContext- Whether the context direction is RTL. In one simple use case, the context direction would simply be the locale direction, which can be retrieved usingLocaleInfo.getCurrentLocale().isRTL()
-
getInstance
public static SafeHtmlBidiFormatter getInstance(boolean rtlContext, boolean alwaysSpan)
Factory for creating an instance of SafeHtmlBidiFormatter given the context direction and the desired span wrapping behavior (see below).- Parameters:
rtlContext- Whether the context direction is RTL. See an example of a simple use case atgetInstance(boolean)alwaysSpan- WhetherspanWrap(com.google.gwt.safehtml.shared.SafeHtml)(and its variations) should always use a 'span' tag, even when the input direction is neutral or matches the context, so that the DOM structure of the output does not depend on the combination of directions
-
getInstance
public static SafeHtmlBidiFormatter getInstance(HasDirection.Direction contextDir)
Factory for creating an instance of SafeHtmlBidiFormatter given the context direction. The default behavior ofspanWrap(com.google.gwt.safehtml.shared.SafeHtml)and its variations is set to avoid span wrapping unless it's necessary ('dir' attribute needs to be set).- Parameters:
contextDir- The context direction. See an example of a simple use case atgetInstance(boolean). Note: Direction.DEFAULT indicates unknown context direction. Try not to use it, since it is impossible to reset the direction back to the context when it is unknown
-
getInstance
public static SafeHtmlBidiFormatter getInstance(HasDirection.Direction contextDir, boolean alwaysSpan)
Factory for creating an instance of SafeHtmlBidiFormatter given the context direction and the desired span wrapping behavior (see below).- Parameters:
contextDir- The context direction. See an example of a simple use case atgetInstance(boolean). Note: Direction.DEFAULT indicates unknown context direction. Try not to use it, since it is impossible to reset the direction back to the context when it is unknownalwaysSpan- WhetherspanWrap(com.google.gwt.safehtml.shared.SafeHtml)(and its variations) should always use a 'span' tag, even when the input direction is neutral or matches the context, so that the DOM structure of the output does not depend on the combination of directions
-
getInstanceForCurrentLocale
public static SafeHtmlBidiFormatter getInstanceForCurrentLocale()
Factory for creating an instance of SafeHtmlBidiFormatter whose context direction matches the current locale's direction. The default behavior ofspanWrap(com.google.gwt.safehtml.shared.SafeHtml)and its variations is set to avoid span wrapping unless it's necessary ('dir' attribute needs to be set).
-
getInstanceForCurrentLocale
public static SafeHtmlBidiFormatter getInstanceForCurrentLocale(boolean alwaysSpan)
Factory for creating an instance of SafeHtmlBidiFormatter whose context direction matches the current locale's direction, and given the desired span wrapping behavior (see below).- Parameters:
alwaysSpan- WhetherspanWrap(com.google.gwt.safehtml.shared.SafeHtml)(and its variations) should always use a 'span' tag, even when the input direction is neutral or matches the context, so that the DOM structure of the output does not depend on the combination of directions
-
dirAttr
public SafeHtml dirAttr(SafeHtml html)
- Parameters:
html- Html whose direction is to be estimated- 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)
-
dirAttr
public SafeHtml dirAttr(java.lang.String str)
- Parameters:
str- String whose direction is to be estimated- 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(java.lang.String)
-
endEdge
public SafeHtml endEdge()
Returns "left" for RTL context direction. Otherwise (LTR or default / unknown context direction) returns "right".
-
estimateDirection
public HasDirection.Direction estimateDirection(SafeHtml html)
- Parameters:
html- Html whose direction is to be estimated- Returns:
html's estimated overall direction- See Also:
BidiFormatterBase.estimateDirection(String, boolean)
-
knownDirAttr
public SafeHtml knownDirAttr(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(com.google.gwt.i18n.client.HasDirection.Direction)
-
mark
public SafeHtml mark()
- See Also:
BidiFormatter.mark()
-
markAfter
public SafeHtml markAfter(SafeHtml html)
- Parameters:
html- Html after which the mark may need to appear- Returns:
- LRM for RTL text in LTR context; RLM for LTR text in RTL context; else, the empty string.
- See Also:
BidiFormatter.markAfter(java.lang.String)
-
markAfter
public SafeHtml markAfter(java.lang.String str)
- Parameters:
str- String after which the mark may need to appear- Returns:
- LRM for RTL text in LTR context; RLM for LTR text in RTL context; else, the empty string.
- See Also:
BidiFormatter.markAfter(java.lang.String)
-
spanWrap
public SafeHtml spanWrap(SafeHtml html)
- Parameters:
html- The input html- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.spanWrap(String, boolean)
-
spanWrap
public SafeHtml spanWrap(SafeHtml html, boolean dirReset)
- Parameters:
html- The input htmldirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followhtml- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.spanWrap(String, boolean, boolean)
-
spanWrap
public SafeHtml spanWrap(java.lang.String str)
- Parameters:
str- The input string- Returns:
- Input string after applying the above processing.
- See Also:
BidiFormatter.spanWrap(String)
-
spanWrap
public SafeHtml spanWrap(java.lang.String str, boolean dirReset)
- Parameters:
str- The input stringdirReset- 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)
-
spanWrapWithKnownDir
public SafeHtml spanWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html)
- Parameters:
dir-str's directionhtml- The input html- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.spanWrapWithKnownDir( com.google.gwt.i18n.client.HasDirection.Direction, String, boolean)
-
spanWrapWithKnownDir
public SafeHtml spanWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html, boolean dirReset)
- Parameters:
dir-html's directionhtml- The input htmldirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followhtml- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.spanWrapWithKnownDir( com.google.gwt.i18n.client.HasDirection.Direction, String, boolean, boolean)
-
spanWrapWithKnownDir
public SafeHtml spanWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str)
- Parameters:
dir-str's directionstr- The input string- Returns:
- Input string after applying the above processing.
- See Also:
BidiFormatter.spanWrapWithKnownDir( com.google.gwt.i18n.client.HasDirection.Direction, String)
-
spanWrapWithKnownDir
public SafeHtml spanWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str, boolean dirReset)
- Parameters:
dir-str's directionstr- The input stringdirReset- 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( com.google.gwt.i18n.client.HasDirection.Direction, String, boolean, boolean)
-
startEdge
public SafeHtml startEdge()
Returns "right" for RTL context direction. Otherwise (LTR or default / unknown context direction) returns "left".
-
unicodeWrap
public SafeHtml unicodeWrap(SafeHtml html)
- Parameters:
html- The input html- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.unicodeWrap(String, boolean)
-
unicodeWrap
public SafeHtml unicodeWrap(SafeHtml html, boolean dirReset)
- Parameters:
html- The input htmldirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followhtml- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.unicodeWrap(String, boolean, boolean)
-
unicodeWrap
public SafeHtml unicodeWrap(java.lang.String str)
- Parameters:
str- The input string- Returns:
- Input string after applying the above processing.
- See Also:
BidiFormatter.unicodeWrap(String)
-
unicodeWrap
public SafeHtml unicodeWrap(java.lang.String str, boolean dirReset)
- Parameters:
str- The input stringdirReset- 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)
-
unicodeWrapWithKnownDir
public SafeHtml unicodeWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html)
- Parameters:
dir-html's directionhtml- The input html- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.unicodeWrapWithKnownDir( com.google.gwt.i18n.client.HasDirection.Direction, String, boolean)
-
unicodeWrapWithKnownDir
public SafeHtml unicodeWrapWithKnownDir(HasDirection.Direction dir, SafeHtml html, boolean dirReset)
- Parameters:
dir-html's directionhtml- The input htmldirReset- Whether to append a trailing unicode bidi mark matching the context direction, when needed, to prevent the possible garbling of whatever may followhtml- Returns:
- Input html after applying the above processing.
- See Also:
BidiFormatter.unicodeWrapWithKnownDir( com.google.gwt.i18n.client.HasDirection.Direction, String, boolean, boolean)
-
unicodeWrapWithKnownDir
public SafeHtml unicodeWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str)
- Parameters:
dir-str's directionstr- The input string- Returns:
- Input string after applying the above processing.
- See Also:
BidiFormatter.unicodeWrapWithKnownDir( com.google.gwt.i18n.client.HasDirection.Direction, String)
-
unicodeWrapWithKnownDir
public SafeHtml unicodeWrapWithKnownDir(HasDirection.Direction dir, java.lang.String str, boolean dirReset)
- Parameters:
dir-str's directionstr- The input stringdirReset- 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( com.google.gwt.i18n.client.HasDirection.Direction, String, boolean, boolean)
-
-