1 24 package org.riotfamily.common.markup; 25 26 import java.io.PrintWriter ; 27 28 43 public class DocumentWriter { 44 45 private TagWriter tagWriter; 46 47 public DocumentWriter(PrintWriter writer) { 48 this(writer, true); 49 } 50 51 public DocumentWriter(PrintWriter writer, boolean xhtml) { 52 tagWriter = new TagWriter(writer); 53 tagWriter.setXhtml(xhtml); 54 } 55 56 public DocumentWriter start(String tagName) { 57 tagWriter = tagWriter.start(tagName); 58 return this; 59 } 60 61 public DocumentWriter startEmpty(String tagName) { 62 tagWriter = tagWriter.startEmpty(tagName); 63 return this; 64 } 65 66 public DocumentWriter start(String tagName, boolean empty) { 67 tagWriter = tagWriter.start(tagName, empty); 68 return this; 69 } 70 71 public DocumentWriter attribute(String name) { 72 tagWriter.attribute(name); 73 return this; 74 } 75 76 public DocumentWriter attribute(String name, int value) { 77 tagWriter.attribute(name, value); 78 return this; 79 } 80 81 public DocumentWriter attribute(String name, boolean present) { 82 tagWriter.attribute(name, present); 83 return this; 84 } 85 86 public DocumentWriter attribute(String name, String value) { 87 tagWriter.attribute(name, value); 88 return this; 89 } 90 91 public DocumentWriter attribute(String name, String value, boolean renderEmpty) { 92 tagWriter.attribute(name ,value, renderEmpty); 93 return this; 94 } 95 96 public DocumentWriter body() { 97 tagWriter.body(); 98 return this; 99 } 100 101 public DocumentWriter body(String body) { 102 tagWriter.body(body); 103 return this; 104 } 105 106 public DocumentWriter body(String body, boolean escapeHtml) { 107 tagWriter.body(body, escapeHtml); 108 return this; 109 } 110 111 public DocumentWriter println(String s) { 112 tagWriter.println(s); 113 return this; 114 } 115 116 public DocumentWriter end() { 117 tagWriter = tagWriter.end(); 118 return this; 119 } 120 121 public void closeAll() { 122 tagWriter.closeAll(); 123 } 124 } 125 | Popular Tags |