From 7382e3af9769f76fe4e19934a59e45a3f9858332 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sun, 3 May 2015 22:25:46 +0200 Subject: renaming eu.siacs.conversations to de.thedevstack.conversationsplus "renaming eu.siacs.conversations to de.thedevstack.conversationsplus" package renaming completed --- .../java/eu/siacs/conversations/xml/TagWriter.java | 114 --------------------- 1 file changed, 114 deletions(-) delete mode 100644 src/main/java/eu/siacs/conversations/xml/TagWriter.java (limited to 'src/main/java/eu/siacs/conversations/xml/TagWriter.java') diff --git a/src/main/java/eu/siacs/conversations/xml/TagWriter.java b/src/main/java/eu/siacs/conversations/xml/TagWriter.java deleted file mode 100644 index f11c1846..00000000 --- a/src/main/java/eu/siacs/conversations/xml/TagWriter.java +++ /dev/null @@ -1,114 +0,0 @@ -package eu.siacs.conversations.xml; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.concurrent.LinkedBlockingQueue; - -import eu.siacs.conversations.xmpp.stanzas.AbstractStanza; - -public class TagWriter { - - private OutputStream plainOutputStream; - private OutputStreamWriter outputStream; - private boolean finshed = false; - private LinkedBlockingQueue writeQueue = new LinkedBlockingQueue(); - private Thread asyncStanzaWriter = new Thread() { - private boolean shouldStop = false; - - @Override - public void run() { - while (!shouldStop) { - if ((finshed) && (writeQueue.size() == 0)) { - return; - } - try { - AbstractStanza output = writeQueue.take(); - if (outputStream == null) { - shouldStop = true; - } else { - outputStream.write(output.toString()); - outputStream.flush(); - } - } catch (IOException e) { - shouldStop = true; - } catch (InterruptedException e) { - shouldStop = true; - } - } - } - }; - - public TagWriter() { - } - - public void setOutputStream(OutputStream out) throws IOException { - if (out == null) { - throw new IOException(); - } - this.plainOutputStream = out; - this.outputStream = new OutputStreamWriter(out); - } - - public OutputStream getOutputStream() throws IOException { - if (this.plainOutputStream == null) { - throw new IOException(); - } - return this.plainOutputStream; - } - - public TagWriter beginDocument() throws IOException { - if (outputStream == null) { - throw new IOException("output stream was null"); - } - outputStream.write(""); - outputStream.flush(); - return this; - } - - public TagWriter writeTag(Tag tag) throws IOException { - if (outputStream == null) { - throw new IOException("output stream was null"); - } - outputStream.write(tag.toString()); - outputStream.flush(); - return this; - } - - public TagWriter writeElement(Element element) throws IOException { - if (outputStream == null) { - throw new IOException("output stream was null"); - } - outputStream.write(element.toString()); - outputStream.flush(); - return this; - } - - public TagWriter writeStanzaAsync(AbstractStanza stanza) { - if (finshed) { - return this; - } else { - if (!asyncStanzaWriter.isAlive()) { - try { - asyncStanzaWriter.start(); - } catch (IllegalThreadStateException e) { - // already started - } - } - writeQueue.add(stanza); - return this; - } - } - - public void finish() { - this.finshed = true; - } - - public boolean finished() { - return (this.writeQueue.size() == 0); - } - - public boolean isActive() { - return outputStream != null; - } -} -- cgit v1.2.3