コード例 #1
0
  public void testRemoveRedundantTagsFromDoc() throws BadLocationException {
    m_doc.insertString(0, "Foobar", SimpleAttributeSet.EMPTY);

    SimpleAttributeSet actualAttr = new SimpleAttributeSet();
    actualAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE);
    m_doc.setCharacterAttributes(1, 2, actualAttr, true);

    actualAttr = new SimpleAttributeSet();
    actualAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE);
    m_doc.setCharacterAttributes(3, 2, actualAttr, true);

    assertEquals("F<b>ooba</b>r", FormattedText.formatted(m_doc).getFormatted());
  }
コード例 #2
0
 public void testRemoveRedundantTagsFromEncoding() throws BadLocationException {
   StyledDocument doc = FormattedText.formatted("F<b>oo</b><b>ba</b>r").getDocument();
   assertEquals("F<b>ooba</b>r", FormattedText.formatted(doc).getFormatted());
 }
コード例 #3
0
 public void testEscapeCharsThatAreUsedForMarkupInUnformattedText() throws BadLocationException {
   FormattedText fText = FormattedText.unformatted("Foo<b>ba</b>r");
   assertEquals("Foo<b>ba</b>r", fText.getUnformatted());
 }
コード例 #4
0
  public void testEscapeCharsThatAreUsedForMarkupInDocumentText() throws BadLocationException {
    m_doc.insertString(0, "Foo<b>ba</b>r", SimpleAttributeSet.EMPTY);

    String encoding = FormattedText.formatted(m_doc).getFormatted();
    assertEquals("Foo<b>ba</b>r", FormattedText.formatted(encoding).getUnformatted());
  }
コード例 #5
0
 private static StyledDocument roundtrip(StyledDocument doc) {
   String encoding = FormattedText.formatted(doc).getFormatted();
   return FormattedText.formatted(encoding).getDocument();
 }