com.caucho.quercus.lib.file
Class WrappedStream

java.lang.Object
  extended by com.caucho.quercus.lib.file.WrappedStream
All Implemented Interfaces:
BinaryInput, BinaryOutput, BinaryStream

public class WrappedStream
extends java.lang.Object
implements BinaryInput, BinaryOutput

A stream that has its operations mediated by a Quercus object.


Field Summary
 
Fields inherited from interface com.caucho.quercus.lib.file.BinaryStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
WrappedStream(Env env, QuercusClass qClass, StringValue path, StringValue mode, LongValue options)
           
 
Method Summary
 StringValue appendTo(StringValue builder)
          Appends to a string builder.
 void close()
          Closes the stream.
 void closeRead()
          Closes the stream for reading
 void closeWrite()
          Closes the stream for writing
 void flush()
          Flushes the output
 java.io.InputStream getInputStream()
          Returns an InputStream to the input.
 java.io.OutputStream getOutputStream()
          Returns an OutputStream.
 long getPosition()
          Tells the position in the stream
 boolean isEOF()
          Returns true if end-of-file has been reached
 BinaryInput openCopy()
          Opens a new copy.
 void print(char v)
          Prints a string to a file.
 void print(java.lang.String v)
          Prints a string to a file.
 int read()
          Reads a character from a file, returning -1 on EOF.
 int read(byte[] buffer, int offset, int length)
          Reads into a buffer, returning -1 on eof.
 int read(char[] buffer, int offset, int length)
           
 StringValue read(int length)
          Reads a Binary string.
 StringValue readLine(long length)
          Reads a line from a file, returning null on EOF.
 boolean readOptionalLinefeed()
          Reads the optional linefeed character from a \r\n
 long seek(long offset, int whence)
          Seek according to offset and whence.
 void setEncoding(java.lang.String encoding)
          Sets the current read encoding.
 boolean setPosition(long offset)
          Sets the position.
 Value stat()
          Returns an array filled with stat information.
 void unread()
          Unread a character.
 void write(byte[] buffer, int offset, int length)
          Writes a buffer.
 int write(java.io.InputStream is, int length)
          Writes to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrappedStream

public WrappedStream(Env env,
                     QuercusClass qClass,
                     StringValue path,
                     StringValue mode,
                     LongValue options)
Method Detail

getInputStream

public java.io.InputStream getInputStream()
Description copied from interface: BinaryInput
Returns an InputStream to the input.

Specified by:
getInputStream in interface BinaryInput

getOutputStream

public java.io.OutputStream getOutputStream()
Description copied from interface: BinaryOutput
Returns an OutputStream.

Specified by:
getOutputStream in interface BinaryOutput

openCopy

public BinaryInput openCopy()
                     throws java.io.IOException
Opens a new copy.

Specified by:
openCopy in interface BinaryInput
Throws:
java.io.IOException

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.io.UnsupportedEncodingException
Sets the current read encoding. The encoding can either be a Java encoding name or a mime encoding.

Parameters:
encoding - name of the read encoding
Throws:
java.io.UnsupportedEncodingException

closeRead

public void closeRead()
Description copied from interface: BinaryInput
Closes the stream for reading

Specified by:
closeRead in interface BinaryInput

closeWrite

public void closeWrite()
Description copied from interface: BinaryOutput
Closes the stream for writing

Specified by:
closeWrite in interface BinaryOutput

close

public void close()
Description copied from interface: BinaryInput
Closes the stream.

Specified by:
close in interface BinaryInput
Specified by:
close in interface BinaryOutput
Specified by:
close in interface BinaryStream

read

public int read()
         throws java.io.IOException
Reads a character from a file, returning -1 on EOF.

Specified by:
read in interface BinaryInput
Throws:
java.io.IOException

unread

public void unread()
            throws java.io.IOException
Unread a character.

Specified by:
unread in interface BinaryInput
Throws:
java.io.IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
Description copied from interface: BinaryInput
Reads into a buffer, returning -1 on eof.

Specified by:
read in interface BinaryInput

read

public int read(char[] buffer,
                int offset,
                int length)

appendTo

public StringValue appendTo(StringValue builder)
Appends to a string builder.

Specified by:
appendTo in interface BinaryInput

read

public StringValue read(int length)
                 throws java.io.IOException
Reads a Binary string.

Specified by:
read in interface BinaryInput
Throws:
java.io.IOException

readOptionalLinefeed

public boolean readOptionalLinefeed()
                             throws java.io.IOException
Reads the optional linefeed character from a \r\n

Specified by:
readOptionalLinefeed in interface BinaryInput
Throws:
java.io.IOException

readLine

public StringValue readLine(long length)
                     throws java.io.IOException
Reads a line from a file, returning null on EOF.

Specified by:
readLine in interface BinaryInput
Throws:
java.io.IOException

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from interface: BinaryOutput
Writes a buffer.

Specified by:
write in interface BinaryOutput
Throws:
java.io.IOException

write

public int write(java.io.InputStream is,
                 int length)
Writes to a stream.

Specified by:
write in interface BinaryOutput

print

public void print(char v)
           throws java.io.IOException
Prints a string to a file.

Specified by:
print in interface BinaryOutput
Throws:
java.io.IOException

print

public void print(java.lang.String v)
           throws java.io.IOException
Prints a string to a file.

Specified by:
print in interface BinaryOutput
Throws:
java.io.IOException

isEOF

public boolean isEOF()
Returns true if end-of-file has been reached

Specified by:
isEOF in interface BinaryStream

getPosition

public long getPosition()
Tells the position in the stream

Specified by:
getPosition in interface BinaryInput
Specified by:
getPosition in interface BinaryStream

setPosition

public boolean setPosition(long offset)
Sets the position.

Specified by:
setPosition in interface BinaryInput
Specified by:
setPosition in interface BinaryStream

seek

public long seek(long offset,
                 int whence)
Description copied from interface: BinaryStream
Seek according to offset and whence. For fseek() compatibility in wrapped streams.

Specified by:
seek in interface BinaryStream

flush

public void flush()
           throws java.io.IOException
Description copied from interface: BinaryOutput
Flushes the output

Specified by:
flush in interface BinaryOutput
Throws:
java.io.IOException

stat

public Value stat()
Description copied from interface: BinaryStream
Returns an array filled with stat information. Mainly for wrapped stream functionality.

Specified by:
stat in interface BinaryStream