nl_tokens: This method determines if the direction of a substring is right - to - left . If the string is empty that determination is based on the default system language Locale . getDefault () . The method can handle invalid substring definitions ( start > end etc . ) in which case the method returns False .
pl_tokens: public static boolean isRTL ( CharSequence s , int start , int end ) { if ( s == null || s . length ( ) == 0 ) { // empty string --> determine the direction from the default language return isRTL ( Locale . getDefault ( ) ) ; } if ( start == end ) { // if no character is selected we need to expand the selection start = Math . <mask> ( 0 , -- start ) ; if ( start == end ) { end = Math . min ( s . length ( ) , ++ end ) ; } } try { Bidi bidi = new Bidi ( s . subSequence ( start , end ) . toString ( ) , Bidi . DIRECTION_DEFAULT_LEFT_TO_RIGHT ) ; return ! bidi . baseIsLeftToRight ( ) ; } catch ( IndexOutOfBoundsException e ) { return false ; } }