protected void sendEvent(XMLEvent event) throws XMLStreamException { synchronized (pipe) { if (pipe.readEndClosed) { // if read end is closed, throw away event return; } if (pipe.capacity > 0) { while (pipe.eventQueue.size() >= pipe.capacity) { try { pipe.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } pipe.eventQueue.add(event); if (pipe.eventQueue.size() == 1) { pipe.notifyAll(); } if (event.isEndDocument()) { close(); } } }
/** * Returns the write end of the pipe, whose events will be available from * the read end of this pipe. * * @return The write end of the pipe. */ public synchronized XMLEventWriter getWriteEnd() { if (writeEnd == null) { writeEnd = new PipedXMLEventWriter(this); } return writeEnd; }