/** * Use Java's built in support for bidi text to determine the base directionality of the element's text. The * response to this only indicates the *base* directionality, it does not indicate whether or not there are any RTL * characters in the text. According to the Atom Bidi spec, if the dir attribute is set explicitly, we should not do * language guessing. This restriction can be bypassed by setting ignoredir to true. */ public static <T extends Element> Direction guessDirectionFromJavaBidi(T element, boolean ignoredir) { if (!ignoredir && hasDirection(element)) return getDirection(element); return Bidi.guessDirectionFromJavaBidi(element.getText()); }