Package org.jdom2.output

Examples of org.jdom2.output.XMLOutputter


  public void testXMLOutputterXMLOutputProcessor() {
    XMLOutputProcessor xoutp = new AbstractXMLOutputProcessor() {
      // nothing;
    };
    // double-constrcut it.
    XMLOutputter out = new XMLOutputter(xoutp);
    TestFormat.checkEquals(Format.getRawFormat(), out.getFormat());
    assertTrue(xoutp == out.getXMLOutputProcessor());
  }
View Full Code Here


  @Test
  public void testFormat() {
    Format mine = Format.getCompactFormat();
    mine.setEncoding("US-ASCII");
    // double-constcut it.
    XMLOutputter out = new XMLOutputter();
    TestFormat.checkEquals(Format.getRawFormat(), out.getFormat());
    out.setFormat(mine);
    TestFormat.checkEquals(mine, out.getFormat());
  }
View Full Code Here

  public void testXMLOutputProcessor() {
    XMLOutputProcessor xoutp = new AbstractXMLOutputProcessor() {
      // nothing;
    };
    // double-constcut it.
    XMLOutputter out = new XMLOutputter();
    XMLOutputProcessor xop = out.getXMLOutputProcessor();
    out.setXMLOutputProcessor(xoutp);
    assertTrue(xoutp != xop);
    assertTrue(xoutp == out.getXMLOutputProcessor());
  }
View Full Code Here

    totest.put("'", "'");

    totest.put("Frodo's Journey", "Frodo's Journey");
   
   
    XMLOutputter out = new XMLOutputter();
   
    for (Map.Entry<String,String> me : totest.entrySet()) {
      if (!me.getValue().equals(out.escapeAttributeEntities(me.getKey()))) {
        assertEquals("Failed attempt to escape '" + me.getKey() + "'",
            me.getValue(), out.escapeAttributeEntities(me.getKey()));
      }
    }
  }
View Full Code Here

    totest.put("'", "'");

    totest.put("Frodo's Journey", "Frodo's Journey");
   
   
    XMLOutputter out = new XMLOutputter();
   
    for (Map.Entry<String,String> me : totest.entrySet()) {
      if (!me.getValue().equals(out.escapeElementEntities(me.getKey()))) {
        assertEquals("Failed attempt to escape '" + me.getKey() + "'",
            me.getValue(), out.escapeElementEntities(me.getKey()));
      }
    }
  }
View Full Code Here

    root.addContent(new Text(" "));
    root.addContent(new Text("x"));
    root.addContent(new Text(" "));
    Format mf = Format.getRawFormat();
    mf.setTextMode(TextMode.TRIM_FULL_WHITE);
    XMLOutputter xout = new XMLOutputter(mf);
    String output = xout.outputString(root);
    assertEquals("<root> x </root>", output);
  }
View Full Code Here

  }
 
 
  @Test
  public void testClone() {
    XMLOutputter xo = new XMLOutputter();
    assertTrue(xo != xo.clone());
  }
View Full Code Here

  @Test
  public void testToString() {
    Format fmt = Format.getCompactFormat();
    fmt.setLineSeparator("\n\t ");
    XMLOutputter out = new XMLOutputter(fmt);
    assertNotNull(out.toString());
  }
View Full Code Here

    Text stuff = new Text("foo");
    root.addContent(child1);
    root.addContent(stuff);
    root.addContent(child2);
    doc.setRootElement(root);
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
    String actual = xout.outputString(doc);
    String expect = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
        + "<root>\r\n"
        + "  <child1 />\r\n"
        + "  foo\r\n"
        + "  <child2 />\r\n"
View Full Code Here

        getFormat(setup, Format.getPrettyFormat()),
        getFormat(setup, ftrimfw)};
    String[] result  = new String[] {expect(raw), expect(compact), expect(pretty), expect(trimfw)};
   
    for (int i = 0; i < 4; i++) {
      XMLOutputter out = new XMLOutputter(formats[i]);
      ByteArrayOutputStream baos = new ByteArrayOutputStream(result[i].length() * 2);
      CharArrayWriter caw = new CharArrayWriter(result[i].length() + 2);
      try {
        if (mstring != null) {
          String rstring = (String) mstring.invoke(out, content);
View Full Code Here

TOP

Related Classes of org.jdom2.output.XMLOutputter

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.