Code example for Bidi

Methods: isMixedisRightToLeft

0
        testBidi(RTLS, true);
        testBidi("This is a string with " + RTLS + RTLS + RTLS + " in it.", 22, 6);
    } 
 
    void testBidi(String string, boolean directionIsRTL) {
        Bidi bidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
        if (bidi.isMixed()) {
            throw new RuntimeException("bidi is mixed");
        } 
        if (bidi.isRightToLeft() != directionIsRTL) {
            throw new RuntimeException("bidi is not " + (directionIsRTL ? "rtl" : "ltr"));
        } 
    } 
 
    void testBidi(String string, int rtlstart, int rtllength) {
        Bidi bidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
        for (int i = 0; i < bidi.getRunCount(); ++i) {
            if ((bidi.getRunLevel(i) & 1) != 0) {
                if (bidi.getRunStart(i) != rtlstart ||
                    bidi.getRunLimit(i) != rtlstart + rtllength) {
Contextual code suggestions in your IDE  Get Codota for Java