public class

BidiUtils

extends Object
java.lang.Object
   ↳ com.google.gwt.i18n.shared.BidiUtils

Class Overview

Utility functions for performing common Bidi tests on strings.

Summary

Public Methods
boolean endsWithLtr(String str)
Like endsWithLtr(String, boolean), but assumes str is not HTML / HTML-escaped.
boolean endsWithLtr(String str, boolean isHtml)
Check whether the last strongly-directional character in the string is LTR.
boolean endsWithRtl(String str)
Like endsWithRtl(String, boolean), but assumes str is not HTML / HTML-escaped.
boolean endsWithRtl(String str, boolean isHtml)
Check whether the last strongly-directional character in the string is RTL.
HasDirection.Direction estimateDirection(String str)
Like estimateDirection(String, boolean), but assumes str is not HTML / HTML-escaped.
HasDirection.Direction estimateDirection(String str, boolean isHtml)
Estimates the directionality of a string based on relative word counts.
static BidiUtils get()
Get an instance of BidiUtils.
boolean hasAnyLtr(String str, boolean isHtml)
Checks if the given string has any LTR characters in it.
boolean hasAnyLtr(String str)
Like hasAnyLtr(String, boolean), but assumes str is not HTML / HTML-escaped.
boolean hasAnyRtl(String str)
Like hasAnyRtl(String, boolean), but assumes str is not HTML / HTML-escaped.
boolean hasAnyRtl(String str, boolean isHtml)
Checks if the given string has any RTL characters in it.
boolean startsWithLtr(String str)
Like startsWithLtr(String, boolean), but assumes str is not HTML / HTML-escaped.
boolean startsWithLtr(String str, boolean isHtml)
Check whether the first strongly-directional character in the string is LTR.
boolean startsWithRtl(String str)
Like startsWithRtl(String, boolean), but assumes str is not HTML / HTML-escaped.
boolean startsWithRtl(String str, boolean isHtml)
Check whether the first strongly-directional character in the string is RTL.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean endsWithLtr (String str)

Like endsWithLtr(String, boolean), but assumes str is not HTML / HTML-escaped.

public boolean endsWithLtr (String str, boolean isHtml)

Check whether the last strongly-directional character in the string is LTR.

Parameters
str the string to check
isHtml whether str is HTML / HTML-escaped
Returns
  • whether LTR exit directionality was detected

public boolean endsWithRtl (String str)

Like endsWithRtl(String, boolean), but assumes str is not HTML / HTML-escaped.

public boolean endsWithRtl (String str, boolean isHtml)

Check whether the last strongly-directional character in the string is RTL.

Parameters
str the string to check
isHtml whether str is HTML / HTML-escaped
Returns
  • whether RTL exit directionality was detected

public HasDirection.Direction estimateDirection (String str)

Like estimateDirection(String, boolean), but assumes str is not HTML / HTML-escaped.

public HasDirection.Direction estimateDirection (String str, boolean isHtml)

Estimates the directionality of a string based on relative word counts. If the number of RTL words is above a certain percentage of the total number of strongly directional words, returns RTL. Otherwise, if any words are strongly or weakly LTR, returns LTR. Otherwise, returns DEFAULT, which is used to mean "neutral". Numbers are counted as weakly LTR.

Parameters
str the string to check
isHtml whether str is HTML / HTML-escaped. Use this to ignore HTML tags and escapes that would otherwise be mistaken for LTR text.
Returns
  • the string's directionality

public static BidiUtils get ()

Get an instance of BidiUtils.

Returns
  • An instance of BidiUtils

public boolean hasAnyLtr (String str, boolean isHtml)

Checks if the given string has any LTR characters in it.

Parameters
str the string to be tested
isHtml whether str is HTML / HTML-escaped
Returns
  • whether the string contains any LTR characters

public boolean hasAnyLtr (String str)

Like hasAnyLtr(String, boolean), but assumes str is not HTML / HTML-escaped.

Parameters
str the string to be tested
Returns
  • whether the string contains any LTR characters

public boolean hasAnyRtl (String str)

Like hasAnyRtl(String, boolean), but assumes str is not HTML / HTML-escaped.

Parameters
str the string to be tested
Returns
  • whether the string contains any RTL characters

public boolean hasAnyRtl (String str, boolean isHtml)

Checks if the given string has any RTL characters in it.

Parameters
str the string to be tested
isHtml whether str is HTML / HTML-escaped
Returns
  • whether the string contains any RTL characters

public boolean startsWithLtr (String str)

Like startsWithLtr(String, boolean), but assumes str is not HTML / HTML-escaped.

public boolean startsWithLtr (String str, boolean isHtml)

Check whether the first strongly-directional character in the string is LTR.

Parameters
str the string to check
isHtml whether str is HTML / HTML-escaped
Returns
  • whether LTR exit directionality was detected

public boolean startsWithRtl (String str)

Like startsWithRtl(String, boolean), but assumes str is not HTML / HTML-escaped.

public boolean startsWithRtl (String str, boolean isHtml)

Check whether the first strongly-directional character in the string is RTL.

Parameters
str the string to check
isHtml whether str is HTML / HTML-escaped
Returns
  • whether RTL exit directionality was detected