code clean up in TagWriter

This commit is contained in:
Daniel Gultsch 2022-02-14 10:27:12 +01:00
parent 2553895300
commit cdc239b040

View file

@ -53,37 +53,33 @@ public class TagWriter {
this.outputStream = new OutputStreamWriter(out); this.outputStream = new OutputStreamWriter(out);
} }
public TagWriter beginDocument() throws IOException { public void beginDocument() throws IOException {
if (outputStream == null) { if (outputStream == null) {
throw new IOException("output stream was null"); throw new IOException("output stream was null");
} }
outputStream.write("<?xml version='1.0'?>"); outputStream.write("<?xml version='1.0'?>");
outputStream.flush(); outputStream.flush();
return this;
} }
public synchronized TagWriter writeTag(Tag tag) throws IOException { public synchronized void writeTag(Tag tag) throws IOException {
if (outputStream == null) { if (outputStream == null) {
throw new IOException("output stream was null"); throw new IOException("output stream was null");
} }
outputStream.write(tag.toString()); outputStream.write(tag.toString());
outputStream.flush(); outputStream.flush();
return this;
} }
public synchronized TagWriter writeElement(Element element) throws IOException { public synchronized void writeElement(Element element) throws IOException {
if (outputStream == null) { if (outputStream == null) {
throw new IOException("output stream was null"); throw new IOException("output stream was null");
} }
outputStream.write(element.toString()); outputStream.write(element.toString());
outputStream.flush(); outputStream.flush();
return this;
} }
public TagWriter writeStanzaAsync(AbstractStanza stanza) { public void writeStanzaAsync(AbstractStanza stanza) {
if (finished) { if (finished) {
Log.d(Config.LOGTAG, "attempting to write stanza to finished TagWriter"); Log.d(Config.LOGTAG, "attempting to write stanza to finished TagWriter");
return this;
} else { } else {
if (!asyncStanzaWriter.isAlive()) { if (!asyncStanzaWriter.isAlive()) {
try { try {
@ -93,7 +89,6 @@ public class TagWriter {
} }
} }
writeQueue.add(stanza); writeQueue.add(stanza);
return this;
} }
} }