Package java.text

Examples of java.text.Bidi


    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testBadFlags() {
    bd = new Bidi("", 173);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
View Full Code Here


    assertFalse(bd.isRightToLeft());
  }

  public void testBadEmbeddings() {
    try {
      bd = new Bidi("".toCharArray(), 0, new byte[] {}, 0, 1,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }
View Full Code Here

      // expected
    }
  }

  public void testOverrideEmbeddings() {
    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -7,
        (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(7, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 7 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
        (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
        (byte) -2, (byte) -3 }, 0, 3, Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
        (byte) -2, (byte) -3 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
View Full Code Here

    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testDefaultEmbeddings() {
    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) 0,
        (byte) 0, (byte) 0 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(2, bd.getLevelAt(0));
View Full Code Here

    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testRelativeEmbeddings() {
    bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) 1,
        (byte) 2, (byte) 3 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(2, bd.getLevelAt(0));
View Full Code Here

    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testSimpleHebrewParagraph() {
    bd = new Bidi("\u05D0", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());

    bd = new Bidi("\u05D0", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());

    bd = new Bidi("\u05D0", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
View Full Code Here

    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());
  }

  public void testSimpleBidiParagraph_1() {
    bd = new Bidi("\u05D0a", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(2, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("\u05D0a", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(2, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("\u05D0a", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(2, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 0 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("\u05D0a", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
View Full Code Here

    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testSimpleBidiParagraph_2() {
    bd = new Bidi("a\u05D0", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(2, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, { 1, 2, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("a\u05D0", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(2, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, { 1, 2, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("a\u05D0", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(2, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, { 1, 2, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("a\u05D0", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(2, bd.getLength());
    assertEquals(2, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1));
View Full Code Here

   * spec reads: public static final int DIRECTION_RIGHT_TO_LEFT Constant
   * indicating base direction is right-to-left. according to that, the method
   * baseIsLeftToRight() here should return false. however, RI doesn't act so.
   */
  public void testRIBug_1() {
    bd = new Bidi("t", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    // the base level it the essential cause
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(2, bd.getLevelAt(0));
View Full Code Here

    assertFalse(bd.isRightToLeft());
  }

  // this is essentially the same bug as Bug_1
  public void testRIBug_2() {
    bd = new Bidi("\u05D0", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
View Full Code Here

TOP

Related Classes of java.text.Bidi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.