public Writer getWriter() { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); return new FilterWriter(new OutputStreamWriter(bytesOut, UTF8)) { @Override public void flush() throws IOException { super.flush(); publishData(); } @Override public void close() throws IOException { super.close(); publishData(); } private void publishData() { XmlResult.this.dataHolder = new BytesDataHolder(bytesOut.toByteArray()); } }; }
@Override public Writer openWriter() { return new FilterWriter(new StringWriter()) { @Override public void close() throws IOException { out.close(); String text = ((StringWriter) out).toString(); save(location, name, new Content() { @Override public byte[] getBytes() { return text.getBytes(); } @Override public String getString() { return text; } }); } }; }
/** * @tests java.io.FilterWriter#FilterReader(java.io.Reader) */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "Verifies constructor FilterWriter(java.io.Writer).", method = "FilterWriter", args = {java.io.Writer.class} ) public void test_ConstructorLjava_io_Writer() { FilterWriter myWriter = null; called = true; try { myWriter = new MyFilterWriter(null); fail("NullPointerException expected."); } catch (NullPointerException e) { // expected } }
@Override public HierarchicalStreamWriter createWriter(final Writer out) { final HierarchicalStreamWriter[] writer = new HierarchicalStreamWriter[1]; final FilterWriter filter = new FilterWriter(out) { @Override public void close() { writer[0].close(); } }; writer[0] = new Dom4JXmlWriter(new XMLWriter(filter, outputFormat), getNameCoder()); return writer[0]; }
public void test_ConstructorLjava_io_Writer() { FilterWriter myWriter = null; called = true; try { myWriter = new MyFilterWriter(null); fail("NullPointerException expected."); } catch (NullPointerException e) { // expected } }
public HierarchicalStreamWriter createWriter(Writer paramWriter) { final HierarchicalStreamWriter[] arrayOfHierarchicalStreamWriter = new HierarchicalStreamWriter[1]; arrayOfHierarchicalStreamWriter[0] = new Dom4JXmlWriter(new XMLWriter(new FilterWriter(paramWriter) { public void close() { arrayOfHierarchicalStreamWriter[0].close(); } } , this.outputFormat), getNameCoder()); return arrayOfHierarchicalStreamWriter[0]; }
@Override public Writer create(Writer delegate) throws Exception { return new FilterWriter(delegate) {}; }