001 package net.sf.tacos.markup; 002 003 import org.apache.tapestry.IMarkupWriter; 004 import org.apache.tapestry.NestedMarkupWriter; 005 import org.apache.tapestry.markup.Attribute; 006 007 /** 008 * 009 */ 010 public class ExtendedMarkupWriterImpl implements IExtendedMarkupWriter { 011 private IMarkupWriter writer; 012 013 public ExtendedMarkupWriterImpl(IMarkupWriter writer) { 014 this.writer = writer; 015 } 016 017 public IExtendedMarkupWriter createEmpty(String tag, String... attributes) { 018 writer.beginEmpty(tag); 019 writeAttributesAndValues(attributes); 020 return this; 021 } 022 023 public IExtendedMarkupWriter create(String tag, String... attributes) { 024 writer.begin(tag); 025 writeAttributesAndValues(attributes); 026 return this; 027 } 028 029 private void writeAttributesAndValues(String... attributes) { 030 for (int i=0; i<attributes.length; i+=2) { 031 writer.attribute(attributes[i], attributes[i+1]); 032 } 033 } 034 035 public void attribute(String name, int value) { 036 writer.attribute(name, value); 037 } 038 039 public void attribute(String name, boolean value) { 040 writer.attribute(name, value); 041 } 042 043 public void attribute(String name, String value) { 044 writer.attribute(name, value); 045 } 046 047 public void attributeRaw(String name, String value) { 048 writer.attributeRaw(name, value); 049 } 050 051 public void appendAttribute(String name, int value) { 052 writer.appendAttribute(name, value); 053 } 054 055 public void appendAttribute(String name, boolean value) { 056 writer.appendAttribute(name, value); 057 } 058 059 public void appendAttribute(String name, String value) { 060 writer.appendAttribute(name, value); 061 } 062 063 public void appendAttributeRaw(String name, String value) { 064 writer.appendAttributeRaw(name, value); 065 } 066 067 public boolean hasAttribute(String name) { 068 return writer.hasAttribute(name); 069 } 070 071 public Attribute getAttribute(String name) { 072 return writer.getAttribute(name); 073 } 074 075 public Attribute removeAttribute(String name) { 076 return writer.removeAttribute(name); 077 } 078 079 public void clearAttributes() { 080 writer.clearAttributes(); 081 } 082 083 public void begin(String name) { 084 writer.begin(name); 085 } 086 087 public void beginEmpty(String name) { 088 writer.beginEmpty(name); 089 } 090 091 public boolean checkError() { 092 return writer.checkError(); 093 } 094 095 public void close() { 096 writer.close(); 097 } 098 099 public void closeTag() { 100 writer.closeTag(); 101 } 102 103 public void comment(String value) { 104 writer.comment(value); 105 } 106 107 public void end() { 108 writer.end(); 109 } 110 111 public void end(String name) { 112 writer.end(name); 113 } 114 115 public void flush() { 116 writer.flush(); 117 } 118 119 public NestedMarkupWriter getNestedWriter() { 120 return writer.getNestedWriter(); 121 } 122 123 public void print(char[] data, int offset, int length) { 124 writer.print(data, offset, length); 125 } 126 127 public void print(char[] data, int offset, int length, boolean raw) { 128 writer.print(data, offset, length, raw); 129 } 130 131 public void print(char value) { 132 writer.print(value); 133 } 134 135 public void print(int value) { 136 writer.print(value); 137 } 138 139 public void print(String value) { 140 writer.print(value); 141 } 142 143 public void print(String value, boolean raw) { 144 writer.print(value, raw); 145 } 146 147 public void println() { 148 writer.println(); 149 } 150 151 public void printRaw(char[] buffer, int offset, int length) { 152 writer.printRaw(buffer, offset, length); 153 } 154 155 public void printRaw(String value) { 156 writer.printRaw(value); 157 } 158 159 public String getContentType() { 160 return writer.getContentType(); 161 } 162 } 163