attr.addAttribute(StyleConstants.NameAttribute, Tag.B.toString());
htmlDoc.insertString(0, "0000", attr);
StyleConstants.setItalic(attr, true);
htmlDoc.insertString(4, "1111", attr);
final Iterator iterator1 = htmlDoc.getIterator(Tag.HTML);
final Iterator iterator2 = htmlDoc.getIterator(Tag.HTML);
final Iterator iterator3 = htmlDoc.getIterator(Tag.A);
final Iterator iterator4 = htmlDoc.getIterator(Tag.P);
final Iterator iterator5 = htmlDoc.getIterator(Tag.B);
assertNotNull(iterator1);
assertNotNull(iterator2);
assertNotNull(iterator3);
if (isHarmony()) {
assertNotNull(iterator4);
}
assertNotNull(iterator5);
assertNotSame(iterator1, iterator2);
assertNotSame(iterator2, iterator3);
assertNotSame(iterator3, iterator5);
assertEquals(Tag.HTML, iterator1.getTag());
if (isHarmony()) {
assertTrue(iterator1.isValid());
assertEquals(0, iterator1.getStartOffset());
assertEquals(9, iterator1.getEndOffset());
assertNotNull(iterator1.getAttributes());
iterator1.next();
assertFalse(iterator1.isValid());
assertEquals(-1, iterator1.getStartOffset());
assertEquals(-1, iterator1.getEndOffset());
assertNull(iterator1.getAttributes());
}
assertEquals(Tag.HTML, iterator2.getTag());
if (isHarmony()) {
assertTrue(iterator2.isValid());
assertEquals(0, iterator2.getStartOffset());
assertEquals(9, iterator2.getEndOffset());
assertNotNull(iterator2.getAttributes());
iterator2.next();
assertFalse(iterator2.isValid());
assertEquals(-1, iterator2.getStartOffset());
assertEquals(-1, iterator2.getEndOffset());
assertNull(iterator2.getAttributes());
}
assertEquals(Tag.A, iterator3.getTag());
if (isHarmony()) {
assertFalse(iterator3.isValid());
assertNull(iterator3.getAttributes());
iterator3.next();
assertEquals(-1, iterator3.getStartOffset());
assertEquals(-1, iterator3.getEndOffset());
}
if (isHarmony()) {
assertEquals(Tag.P, iterator4.getTag());
assertTrue(iterator4.isValid());
assertEquals(0, iterator4.getStartOffset());
assertEquals(9, iterator4.getEndOffset());
iterator4.next();
assertFalse(iterator4.isValid());
assertEquals(-1, iterator4.getStartOffset());
assertEquals(-1, iterator4.getEndOffset());
assertNull(iterator4.getAttributes());
}
assertEquals(Tag.B, iterator5.getTag());
if (isHarmony()) {
assertTrue(iterator5.isValid());
assertEquals(0, iterator5.getStartOffset());
assertEquals(4, iterator5.getEndOffset());
assertFalse(StyleConstants.isBold(iterator5.getAttributes()));
assertFalse(StyleConstants.isItalic(iterator5.getAttributes()));
iterator5.next();
assertTrue(iterator5.isValid());
assertEquals(4, iterator5.getStartOffset());
assertEquals(8, iterator5.getEndOffset());
assertFalse(StyleConstants.isBold(iterator5.getAttributes()));
assertTrue(StyleConstants.isItalic(iterator5.getAttributes()));
iterator5.next();
assertFalse(iterator5.isValid());
assertEquals(-1, iterator5.getStartOffset());
assertEquals(-1, iterator5.getEndOffset());
assertNull(iterator5.getAttributes());
}
}