com.caucho.vfs
Class TempStream

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.vfs.TempStream
All Implemented Interfaces:
TempStreamApi, java.io.Serializable

public class TempStream
extends StreamImpl
implements java.io.Serializable, TempStreamApi

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Constructor Summary
TempStream()
           
 
Method Summary
 boolean canWrite()
          Returns true if this is a writable stream.
 void clearWrite()
          Clears any buffered values in the write.
 TempStream copy()
          Copies the temp stream;
 void destroy()
          Clean up the temp stream.
 void discard()
           
 void flush()
          Flushes the write output.
 java.lang.String getEncoding()
          Gets the encoding.
 TempBuffer getHead()
          Returns the head buffer.
 java.io.InputStream getInputStream()
          Returns an input stream to the contents, freeing the value automatically.
 int getLength()
          Returns the total length of the buffer's bytes
 byte[] getTail()
           
 java.io.InputStream openInputStream()
           
 ReadStream openRead()
          Opens a read stream to the buffer.
 void openRead(ReadStream rs)
          Opens a read stream to the buffer.
 ReadStream openReadAndSaveBuffer()
          Opens a read stream to the buffer.
 void openWrite()
          Initializes the temp stream for writing.
 void setEncoding(java.lang.String encoding)
          Sets the encoding.
 void write(byte[] buf, int offset, int length, boolean isEnd)
          Writes a chunk of data to the temp stream.
 void writeToStream(java.io.OutputStream os)
           
 
Methods inherited from class com.caucho.vfs.StreamImpl
canRead, close, closeWrite, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getAvailable, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, hasSkip, isClosed, isEof, read, readNonBlock, readTimeout, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TempStream

public TempStream()
Method Detail

openWrite

public void openWrite()
Initializes the temp stream for writing.


getTail

public byte[] getTail()

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding.


getEncoding

public java.lang.String getEncoding()
Gets the encoding.


canWrite

public boolean canWrite()
Description copied from class: StreamImpl
Returns true if this is a writable stream.

Overrides:
canWrite in class StreamImpl

write

public void write(byte[] buf,
                  int offset,
                  int length,
                  boolean isEnd)
           throws java.io.IOException
Writes a chunk of data to the temp stream.

Specified by:
write in interface TempStreamApi
Overrides:
write in class StreamImpl
Parameters:
buf - the byte array to write.
offset - the offset into the byte array.
length - the number of bytes to write.
isEnd - true when the write is flushing a close.
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from class: StreamImpl
Flushes the write output.

Overrides:
flush in class StreamImpl
Throws:
java.io.IOException

openRead

public ReadStream openRead()
                    throws java.io.IOException
Opens a read stream to the buffer.

Specified by:
openRead in interface TempStreamApi
Throws:
java.io.IOException

openReadAndSaveBuffer

public ReadStream openReadAndSaveBuffer()
                                 throws java.io.IOException
Opens a read stream to the buffer.

Parameters:
free - if true, frees the buffer as it's read
Throws:
java.io.IOException

openRead

public void openRead(ReadStream rs)
              throws java.io.IOException
Opens a read stream to the buffer.

Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream to the contents, freeing the value automatically.

Throws:
java.io.IOException

openInputStream

public java.io.InputStream openInputStream()
                                    throws java.io.IOException
Throws:
java.io.IOException

getHead

public TempBuffer getHead()
Returns the head buffer.


writeToStream

public void writeToStream(java.io.OutputStream os)
                   throws java.io.IOException
Throws:
java.io.IOException

getLength

public int getLength()
Returns the total length of the buffer's bytes


clearWrite

public void clearWrite()
Description copied from class: StreamImpl
Clears any buffered values in the write.

Overrides:
clearWrite in class StreamImpl

discard

public void discard()

copy

public TempStream copy()
Copies the temp stream;


destroy

public void destroy()
Clean up the temp stream.

Specified by:
destroy in interface TempStreamApi