1 15 package org.apache.tapestry.markup; 16 17 import java.io.CharArrayWriter ; 18 import java.io.PrintWriter ; 19 20 import org.apache.tapestry.IMarkupWriter; 21 import org.apache.tapestry.NestedMarkupWriter; 22 23 31 public class NestedMarkupWriterImpl extends MarkupWriterImpl implements NestedMarkupWriter 32 { 33 private final IMarkupWriter _parent; 34 35 private final CharArrayWriter _charArrayWriter; 36 37 private boolean _closed; 38 39 public String getBuffer() 40 { 41 return _charArrayWriter.toString(); 42 } 43 44 public NestedMarkupWriterImpl(IMarkupWriter parent, MarkupFilter filter) 45 { 46 50 this(parent, new CharArrayWriter (), filter); 51 } 52 53 private NestedMarkupWriterImpl(IMarkupWriter parent, CharArrayWriter writer, MarkupFilter filter) 54 { 55 super(parent.getContentType(), new PrintWriter (writer), filter); 56 57 _parent = parent; 58 _charArrayWriter = writer; 59 } 60 61 66 67 public void close() 68 { 69 if (_closed) 70 throw new IllegalStateException (MarkupMessages.closeOnce()); 71 72 _closed = true; 73 74 super.close(); 75 76 String content = getBuffer(); 77 78 _parent.printRaw(content); 79 } 80 } | Popular Tags |