1 42 43 package org.jfree.xml.writer; 44 45 import java.io.IOException ; 46 import java.io.Writer ; 47 import java.util.Properties ; 48 49 52 public class XMLWriter extends XMLWriterSupport { 53 54 57 private Writer writer; 58 59 65 public XMLWriter(final Writer writer) { 66 this(writer, " "); 67 } 68 69 76 public XMLWriter(final Writer writer, final String indentString) { 77 super(new SafeTagList(), 0, indentString); 78 if (writer == null) { 79 throw new NullPointerException ("Writer must not be null."); 80 } 81 82 this.writer = writer; 83 } 84 85 92 public void writeXmlDeclaration() throws IOException { 93 this.writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 94 this.writer.write(getLineSeparator()); 95 } 96 97 105 public void writeTag(final String name, final boolean close) 106 throws IOException { 107 if (close) { 108 writeTag(this.writer, name, new AttributeList(), close); 109 } 110 else { 111 writeTag(this.writer, name); 112 } 113 } 114 115 121 public void writeCloseTag(final String tag) throws IOException { 122 writeCloseTag(this.writer, tag); 123 } 124 125 134 public void writeTag(final String name, final String attributeName, 135 final String attributeValue, final boolean close) 136 throws IOException { 137 writeTag(this.writer, name, attributeName, attributeValue, close); 138 } 139 140 148 public void writeTag(final String name, final AttributeList attributes, 149 final boolean close) throws IOException { 150 writeTag(this.writer, name, attributes, close); 151 } 152 153 162 public void writeTag(final String name, final Properties attributes, 163 final boolean close) throws IOException { 164 writeTag(this.writer, name, attributes, close); 165 } 166 167 174 public void writeText(final String text) throws IOException { 175 this.writer.write(text); 176 } 177 178 183 public void close() throws IOException { 184 this.writer.close(); 185 } 186 187 } 188 | Popular Tags |