this overrides PDFTextStripper's flushText method: instead of writing to
output stream, we save the information in our own data structure


@throws IOException
If there is an error processing the page.
766030
@SuppressWarnings("unchecked")
    protected void flushText() throws IOException {
        ArrayList<TextPiece> wordsOfThisPage = new ArrayList<TextPiece>();

        for (int i = 0; i < charactersByArticle.size(); i++) {
            ArrayList<TextPosition> textList = (ArrayList<TextPosition>) charactersByArticle
                    .get(i);
            for (TextPosition t : textList) {

                // copy information

                TextPiece w = new TextPiece();
                w.setX(t.getX());
                w.setY(t.getY());

                /*
                 * 100: a simple step to fix the font size to the normal range,
                 * for those documents in unknown codes that PDFBox can not
                 * process now
                 */
                if (t.getFontSize() < 0.3 && t.getYScale() <= 1.0) {
                    w.setFontSize(t.getFontSize() * 100);
                    w.setHeight(Math.max(t.getYScale(), t.getFontSize()) * 100);
                    w.setXScale(t.getXScale());
                    w.setYScale(t.getYScale());
                } else {
                    if (t.getYScale() < 0.3 && t.getFontSize() <= 1.0) {
                        w.setYScale(t.getYScale() * 100);
                        w.setXScale(t.getXScale() * 100);
                        w.setHeight(Math.max(t.getYScale() * 100,
                                t.getFontSize()));
                    } else {
                        w.setFontSize(t.getFontSize());
                        w.setHeight(Math.max(t.getYScale(), t.getFontSize()));
                        w.setXScale(t.getXScale());
                        w.setYScale(t.getYScale());
                    }
                }

                // Width might be negative according to the PDF text extractors
                w.setWidth(Math.abs(t.getWidth()));
                w.setEndX(w.getX() + w.getWidth());

                // w.setHeight(Math.max(t.getYScale(), t.getFontSize()));
                w.setEndY(w.getY() + w.getHeight());

                w.setWidthOfSpace(t.getWidthOfSpace());
                w.setWordSpacing(t.getWordSpacing());

                w.setText(t.getCharacter());
                wordsOfThisPage.add(w);
            }
        }

        m_wordsByPage.add(wordsOfThisPage);
    }
584560
public final void clear() throws IOException {
        if ((bufferSize == 0) && (out != null))
            // clear() is illegal after any unbuffered output (JSP.5.5)
             throw new IllegalStateException("jsp.error.ise_on_clear");
        if (flushed)
            throw new IOException("jsp.error.attempt_to_clear_flushed_buffer");
        // defect 312981 begin
        //ensureOpen();
    	if (closed) {
    	    throw new IOException("Stream closed");
        }
        // defect 312981 end
        nextChar = 0;
    }
684437
public void writeOut(Writer out) throws IOException {
	    if (writer == null) {
	        out.write(strBuffer.toString()); // PK33136
	        // Flush not called as the writer passed could be a BodyContent and
	        // it doesn't allow to flush.
	    }
    }
63319
@Override
    public void flush() {

        PrintWriter out = null;
        try {
            try {
                out = new PrintWriter(Utils.createFile(dir, file), "UTF-8");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            String contents = getBuffer().toString();
            out.write(processor.apply(contents));
        } finally {
            closeQuietly(out);
        }
    }
10489
@Override
	public void write(final OutputStream output) throws IOException
	{
		initialize();
		if (content == null)
		{
			content = new byte[0];
		}
		output.write(content, 0, content.length);
		output.flush();
	}
785399
@Override
    public void flush() throws IOException {

        if (_callback != null) {
            if (!this._isReady) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Cannot flush stream , output not ready: " + this);
                }
                return;
            }
            else {
                validate();
                flushBuffers();
            }
        }
        else {
            super.flush();
        }

    }
232970
protected void flushBuffer() throws IOException {
		if (capacity == 0) {
			ostream.write(buffer);
			capacity = BITS_IN_BYTE;
			buffer = 0;
			len++;
		}
	}
476387
public synchronized void flush() throws IOException {
    this.inner.write(this.remainder.getBytes());
    this.inner.flush();
    this.remainder = Bits.NULL;
  }
869903
public void writeTo(OutputStream out) throws IOException {
        out.write(this.content);
        out.flush();
        out.close();
    }
1140774
@FFDCIgnore({ IOException.class })
    private void flushAsyncBuffers() throws IOException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Flushing Async buffers: " + this);
        }
        if (!this.isc.getResponse().isCommitted()) {
            if ((obs != null) && !this.WCheadersWritten) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "obs  ->" + obs);
                }
                obs.alertOSFirstFlush();
            }

            this.isc.getResponse().setCommitted();
        }

        if (this.ignoreFlush) {
            this.ignoreFlush = false;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Ignoring first flush attempt");
            }
            return;
        }

        final boolean writingBody = (hasBufferedContent());
        // flip the last buffer for the write...
        if (writingBody && null != this.output[this.outputIndex]) {
            this.output[this.outputIndex].flip();
        }
        try {
            WsByteBuffer[] content = (writingBody) ? this.output : null;
            if (isClosed() || this.isClosing) {
                if (!hasFinished) { //if we've already called finishResponseMessage - don't call again
                    // on a closed stream, use the final write api
                    this.isc.finishResponseMessage(content); // check if this also needs to be async
                    this.isClosing = false;
                    this.hasFinished = true;
                }
            } else {
                // else use the partial body api
                // Add the async option.               
                vc = this.isc.sendResponseBody(content, _callback, false);
                if (vc == null) { // then we will have to wait for data to be written, async write in progress
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "wait for data to be written, async write in progress, set ready to false");
                    }
                    synchronized (this._writeReadyLockObj) {
                        this.setWriteReady(false);
                        this.set_internalReady(false);
                    }
                }
                else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "able to write out, no callback required, vc -->" + vc);
                    }
                }
            }
        } catch (MessageSentException mse) {
            FFDCFilter.processException(mse, getClass().getName(),
                                        "flushAsyncBuffers", new Object[] { this, this.isc });
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Invalid state, message-sent-exception received; " + this.isc);
            }
            this.error = new IOException("Invalid state");
            throw this.error;
        } catch (IOException ioe) {
            // no FFDC required
            this.error = ioe;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Received exception during write: " + ioe);
            }
            throw ioe;
        } finally {
            this.bytesWritten += this.bufferedCount;
            if (this.contentLengthSet) {
                this.bytesRemaining -= this.bufferedCount;
            }
            this.bufferedCount = 0;
            this.outputIndex = 0;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "finally, this " + this + " ,bytesRemaining -->" + this.bytesRemaining + ", bytesWritten -->" + this.bytesWritten);
            }
            if (writingBody && vc != null) {
                clearBuffersAfterWrite();
            }
        }
    }
611901
void flush(Writer out)
         throws IOException
    {
        if (nest!=null)
            nest.flush(out);
        else
        {
            write(out);
            elements.clear();
        }
    }
440553
public void flush()
        throws IOException
    {
        try
        {
            if (!_commited)
            {
                _commited=true;
                if (_commitObserver!=null)
                    _commitObserver.outputNotify(this,OutputObserver.__COMMITING,null);
            }
            
            wrapBuffer();
            
            // Add headers
            if (_httpMessageWriter.size()>0)
            {
                prewrite(_httpMessageWriter.getBuf(),0,_httpMessageWriter.size());
                _httpMessageWriter.resetWriter();
            }
            
            if (size()>0)
                writeTo(_out);
        }
        catch (IOException e)
        {
            throw new EOFException(e);
        }
        finally
        {
            reset(_preReserve);
        }
    }
115722
public function flushBuffer() {
        $content = $this->format($this->buffer->flush());

        if ( ! $this->is(OutputVerbosity::SILENT)) {
            fwrite($this->getOutputStream(), $content);
        }
    }
883072
public void flushBuffer()
    throws IOException
    {
        if (logger.isLoggable(Level.FINER)) logger.entering(className, "flushBuffer()");

        if (this.osWriter != null)
        {
            this.osWriter.flush();
        }

        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "flushBuffer()");
    }
231616
@Override
    public synchronized void flush() throws IOException {
        ensureOpen();
        if (decodedBuf.position() > 0) {
            decodedBuf.flip();
            String contents = decodedBuf.toString();
            String filtered = contentFilter.filter(contents);
            out.write(filtered.getBytes(charset));
            decodedBuf.clear();
        }
        out.flush();
    }
939367
@Override
  protected void flushAndSync(boolean durable) throws IOException {
    if (outputStream == null) {
      throw new IOException("Trying to use aborted output stream!");
    }
    if (doubleBuf.isFlushed()) {
      return;
    }
    // Under the covers, this invokes a method that does not return until
    // we have successfully persisted the buffer to a quorum of bookies.
    doubleBuf.flushTo(outputStream);
  }
863702
public void writeTo(OutputStream out) throws IOException {
        if (!(out instanceof DataOutput)) {
            out = new DataOutputStream(out);
        }

        writeTo((DataOutput)out);

        out.flush();
    }