@Override public void close() throws IOException { buffer.close(); }
@Override public BufferResult getResult() throws IllegalStateException, IOException { return buffer.getResult(); } }
private void switchIfNeeded(long newLength) throws IOException { if(isInitialBuffer && newLength>=tempFileThreshold) { TempFile tempFile = tempFileList.createTempFile(); if(logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Switching to temp file: {0}", tempFile); buffer.close(); TempFileWriter tempFileWriter = new TempFileWriter(tempFile); buffer.getResult().writeTo(tempFileWriter); buffer = tempFileWriter; isInitialBuffer = false; } }
@Override public CharArrayBufferWriter append(char c) throws IOException { super.append(c); return this; }
@Override public long getLength() throws IOException { return buffer.getLength(); }
@Override public void flush() throws IOException { buffer.flush(); }
@Override public CharArrayBufferWriter append(CharSequence csq) throws IOException { super.append(csq); return this; }
@Override public long getLength() throws IOException { log.write("writer["); log.write(Long.toString(id)); log.write("].getLength();\n"); log.flush(); return wrapped.getLength(); }
@Override public void flush() throws IOException { log.write("writer["); log.write(Long.toString(id)); log.write("].flush();\n"); log.flush(); wrapped.flush(); }
@Override public void close() throws IOException { log.write("writer["); log.write(Long.toString(id)); log.write("].close();\n"); log.flush(); wrapped.close(); }
@Override public LoggingResult getResult() throws IllegalStateException, IOException { if(result==null) { result = new LoggingResult(wrapped.getResult(), log); log.write("result["); log.write(Long.toString(result.id)); log.write("] = writer["); log.write(Long.toString(id)); log.write("].getResult();\n"); log.flush(); } return result; } }
@Override public LoggingWriter append(CharSequence csq) throws IOException { log.write("writer["); log.write(Long.toString(id)); log.write("].append("); log(csq==null ? null : csq.toString()); log.write(");\n"); log.flush(); wrapped.append(csq); return this; }