com.caucho.quercus.lib.file
Class ReadStreamInput

java.lang.Object
  extended by java.io.InputStream
      extended by com.caucho.quercus.lib.file.ReadStreamInput
All Implemented Interfaces:
BinaryInput, BinaryStream, java.io.Closeable
Direct Known Subclasses:
FileInput, PopenInput, ProcOpenInput, ZipEntryInputStream, ZlibInputStream

public class ReadStreamInput
extends java.io.InputStream
implements BinaryInput

Represents a Quercus file open for reading


Field Summary
 
Fields inherited from interface com.caucho.quercus.lib.file.BinaryStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
  ReadStreamInput(Env env)
           
  ReadStreamInput(Env env, java.io.InputStream is)
           
protected ReadStreamInput(Env env, LineReader lineReader)
           
protected ReadStreamInput(Env env, LineReader lineReader, ReadStream is)
           
 
Method Summary
 StringValue appendTo(StringValue builder)
          Appends to a string builder.
 void close()
          Closes the file.
 void closeRead()
          Closes the stream for reading.
 java.io.InputStream getInputStream()
          Returns the input stream.
 long getPosition()
          Returns the current location in the file.
 java.lang.String getResourceType()
           
 void init(ReadStream is)
           
 boolean isEOF()
          Returns true on the EOF.
 BinaryInput openCopy()
          Opens a copy.
 int read()
          Reads a character from a file, returning -1 on EOF.
 int read(byte[] buffer, int offset, int length)
          Reads a buffer from a file, returning -1 on EOF.
 int read(char[] buffer, int offset, int length)
          Reads a buffer from a file, returning -1 on EOF.
 StringValue read(int length)
          Reads into a binary builder.
 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)
           
 boolean setPosition(long offset)
          Returns the current location in the file.
 Value stat()
          Returns an array filled with stat information.
 java.lang.Object toJavaObject()
           
 java.lang.String toString()
          Converts to a string.
 void unread()
          Unreads the last byte.
 void writeToStream(java.io.OutputStream os, int length)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadStreamInput

public ReadStreamInput(Env env)

ReadStreamInput

public ReadStreamInput(Env env,
                       java.io.InputStream is)

ReadStreamInput

protected ReadStreamInput(Env env,
                          LineReader lineReader)

ReadStreamInput

protected ReadStreamInput(Env env,
                          LineReader lineReader,
                          ReadStream is)
Method Detail

init

public void init(ReadStream is)

getInputStream

public java.io.InputStream getInputStream()
Returns the input stream.

Specified by:
getInputStream in interface BinaryInput

openCopy

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

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

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

unread

public void unread()
            throws java.io.IOException
Description copied from interface: BinaryInput
Unreads the last byte.

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

read

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

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

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads a buffer from a file, returning -1 on EOF.

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

read

public int read(char[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads a buffer from a file, returning -1 on EOF.

Throws:
java.io.IOException

read

public StringValue read(int length)
                 throws java.io.IOException
Reads into a binary builder.

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

writeToStream

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

appendTo

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

Specified by:
appendTo in interface BinaryInput

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

isEOF

public boolean isEOF()
Returns true on the EOF.

Specified by:
isEOF in interface BinaryStream

getPosition

public long getPosition()
Returns the current location in the file.

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

setPosition

public boolean setPosition(long offset)
Returns the current location in the file.

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

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

closeRead

public void closeRead()
Closes the stream for reading.

Specified by:
closeRead in interface BinaryInput

close

public void close()
Closes the file.

Specified by:
close in interface BinaryInput
Specified by:
close in interface BinaryStream
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream

toJavaObject

public java.lang.Object toJavaObject()

getResourceType

public java.lang.String getResourceType()

toString

public java.lang.String toString()
Converts to a string.

Overrides:
toString in class java.lang.Object