aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/xml/TagWriter.java
blob: 35f27477f5aa3ea7012f2d0af9452b184c51ca64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package de.gultsch.chat.xml;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import android.util.Log;

public class TagWriter {
	
	OutputStreamWriter writer;
	
	public TagWriter() {
		
	}
	
	public TagWriter(OutputStream out) {
		this.setOutputStream(out);
	}
	
	public void setOutputStream(OutputStream out) {
		this.writer = new OutputStreamWriter(out);
	}
	
	public TagWriter beginDocument() throws IOException {
		writer.write("<?xml version='1.0'?>");
		return this;
	}
	
	public TagWriter writeTag(Tag tag) throws IOException {
		writer.write(tag.toString());
		return this;
	}
	
	public void flush() throws IOException {
		writer.flush();
	}

	public void writeString(String string) throws IOException {
		writer.write(string);
	}

	public void writeElement(Element element) throws IOException {
		writer.write(element.toString());
	}
}