Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions irc/src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,46 +47,40 @@ public class OutputQueue {
/** Thread for the sending queue. */
private QueueHandler queueHandler;
/** The QueueHandlerFactory for this OutputQueue. */
private QueueHandlerFactory queueHandlerFactory = PriorityQueueHandler.getFactory();
private final QueueHandlerFactory queueHandlerFactory;

/**
* Set the output stream for this queue.
*
* @param outputStream Output Stream to use.
* Creates a new output queue using the default handler.
*/
public void setOutputStream(final OutputStream outputStream) {
this.out = new PrintWriter(outputStream, true);
public OutputQueue() {
this(PriorityQueueHandler.getFactory());
}

/**
* Is output queueing enabled?
* Creates a new output queue using a handler from the given factory.
*
* @return true if output queueing is enabled.
* @param queueHandlerFactory The factory to use to create {@link QueueHandler}s.
*/
public boolean isQueueEnabled() {
return queueEnabled;
public OutputQueue(final QueueHandlerFactory queueHandlerFactory) {
this.queueHandlerFactory = queueHandlerFactory;
}

/**
* Set the QueueHandlerFactory.
* Changing this will not change an existing QueueHandler unless queueing is
* disabled and reenabled.
* If this is called before the first lien of output is queued then there is
* no need to disable and reenable the queue.
* Set the output stream for this queue.
*
* @param factory New QueueHandlerFactory to use.
* @param outputStream Output Stream to use.
*/
public void setQueueHandlerFactory(final QueueHandlerFactory factory) {
queueHandlerFactory = factory;
public void setOutputStream(final OutputStream outputStream) {
this.out = new PrintWriter(outputStream, true);
}

/**
* Get the QueueHandlerFactory.
* Is output queueing enabled?
*
* @return The current QueueHandlerFactory.
* @return true if output queueing is enabled.
*/
public QueueHandlerFactory getQueueHandlerFactory() {
return queueHandlerFactory;
public boolean isQueueEnabled() {
return queueEnabled;
}

/**
Expand Down