Package org.apache.cxf.io
Class CachedWriter
- java.lang.Object
-
- java.io.Writer
-
- org.apache.cxf.io.CachedWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
- Direct Known Subclasses:
XSLTOutInterceptor.XSLTCachedWriter
public class CachedWriter extends Writer
-
-
Field Summary
Fields Modifier and Type Field Description protected Writer
currentStream
protected boolean
outputLocked
-
Constructor Summary
Constructors Constructor Description CachedWriter()
CachedWriter(long threshold)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
deregisterCallback(CachedWriterCallback cb)
protected void
doClose()
Perform any actions required on stream closure (handle response etc.)protected void
doFlush()
Perform any actions required on stream flush (freeze headers, reset output stream ... etc.)boolean
equals(Object obj)
void
flush()
List<CachedWriterCallback>
getCallbacks()
char[]
getChars()
Writer
getOut()
Reader
getReader()
File
getTempFile()
int
hashCode()
void
holdTempFile()
void
lockOutputStream()
Locks the output stream to prevent additional writes, but maintains a pointer to it so an InputStream can be obtainedprotected void
onWrite()
protected void
postClose()
Perform any actions required after stream closure (close the other related stream etc.)void
registerCallback(CachedWriterCallback cb)
void
releaseTempFileHold()
void
resetOut(Writer out, boolean copyOldContent)
Replace the original stream with the new one, optionally copying the content of the old one into the new one.void
setCipherTransformation(String cipherTransformation)
static void
setDefaultCipherTransformation(String n)
static void
setDefaultMaxSize(long l)
static void
setDefaultThreshold(int i)
void
setMaxSize(long maxSize)
void
setOutputDir(File outputDir)
void
setThreshold(long threshold)
long
size()
String
toString()
void
write(char[] cbuf, int off, int len)
void
writeCacheTo(Writer out)
void
writeCacheTo(StringBuilder out)
void
writeCacheTo(StringBuilder out, long limit)
-
-
-
Field Detail
-
outputLocked
protected boolean outputLocked
-
currentStream
protected Writer currentStream
-
-
Method Detail
-
holdTempFile
public void holdTempFile()
-
releaseTempFileHold
public void releaseTempFileHold()
-
registerCallback
public void registerCallback(CachedWriterCallback cb)
-
deregisterCallback
public void deregisterCallback(CachedWriterCallback cb)
-
getCallbacks
public List<CachedWriterCallback> getCallbacks()
-
doFlush
protected void doFlush() throws IOException
Perform any actions required on stream flush (freeze headers, reset output stream ... etc.)- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
doClose
protected void doClose() throws IOException
Perform any actions required on stream closure (handle response etc.)- Throws:
IOException
-
postClose
protected void postClose() throws IOException
Perform any actions required after stream closure (close the other related stream etc.)- Throws:
IOException
-
lockOutputStream
public void lockOutputStream() throws IOException
Locks the output stream to prevent additional writes, but maintains a pointer to it so an InputStream can be obtained- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
resetOut
public void resetOut(Writer out, boolean copyOldContent) throws IOException
Replace the original stream with the new one, optionally copying the content of the old one into the new one. When with Attachment, needs to replace the xml writer stream with the stream used by AttachmentSerializer or copy the cached output stream to the "real" output stream, i.e. onto the wire.- Parameters:
out
- the new output streamcopyOldContent
- flag indicating if the old content should be copied- Throws:
IOException
-
size
public long size()
-
getChars
public char[] getChars() throws IOException
- Throws:
IOException
-
writeCacheTo
public void writeCacheTo(Writer out) throws IOException
- Throws:
IOException
-
writeCacheTo
public void writeCacheTo(StringBuilder out, long limit) throws IOException
- Throws:
IOException
-
writeCacheTo
public void writeCacheTo(StringBuilder out) throws IOException
- Throws:
IOException
-
getOut
public Writer getOut()
- Returns:
- the underlying output stream
-
onWrite
protected void onWrite() throws IOException
- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
getTempFile
public File getTempFile()
-
getReader
public Reader getReader() throws IOException
- Throws:
IOException
-
setOutputDir
public void setOutputDir(File outputDir) throws IOException
- Throws:
IOException
-
setThreshold
public void setThreshold(long threshold)
-
setMaxSize
public void setMaxSize(long maxSize)
-
setCipherTransformation
public void setCipherTransformation(String cipherTransformation)
-
setDefaultMaxSize
public static void setDefaultMaxSize(long l)
-
setDefaultThreshold
public static void setDefaultThreshold(int i)
-
setDefaultCipherTransformation
public static void setDefaultCipherTransformation(String n)
-
-