com.caucho.quercus.lib.file
Class HttpInputOutput

java.lang.Object
  extended by java.io.OutputStream
      extended by com.caucho.quercus.lib.file.AbstractBinaryOutput
          extended by com.caucho.quercus.lib.file.HttpInputOutput
All Implemented Interfaces:
EnvCleanup, BinaryInput, BinaryOutput, BinaryStream, LockableStream, java.io.Closeable, java.io.Flushable

public class HttpInputOutput
extends AbstractBinaryOutput
implements BinaryInput, BinaryOutput, LockableStream, EnvCleanup


Field Summary
 
Fields inherited from interface com.caucho.quercus.lib.file.BinaryStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
HttpInputOutput(Env env, Path path, StreamContextResource context)
           
 
Method Summary
 StringValue appendTo(StringValue builder)
          Appends to a string builder.
 void cleanup()
           
 void close()
          Closes the file.
 void closeRead()
          Closes the file for reading.
 java.io.InputStream getInputStream()
          Returns the read stream.
 boolean isEOF()
          Returns true on the EOF.
 boolean lock(boolean shared, boolean block)
          Lock the shared advisory lock.
 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 a Binary string.
 StringValue readLine(long length)
          Reads a line from the buffer.
 boolean readOptionalLinefeed()
          Reads the optional linefeed character from a \r\n
 void setEncoding(java.lang.String encoding)
          Sets the current read encoding.
 java.lang.String toString()
           
 boolean unlock()
          Unlock the advisory lock.
 void unread()
          Unread a character.
 void write(int ch)
           
 
Methods inherited from class com.caucho.quercus.lib.file.AbstractBinaryOutput
closeWrite, flush, getOutputStream, getPosition, getResourceType, print, print, seek, setPosition, stat, write
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.caucho.quercus.lib.file.BinaryInput
getPosition, setPosition
 
Methods inherited from interface com.caucho.quercus.lib.file.BinaryOutput
closeWrite, flush, getOutputStream, print, print, write, write
 
Methods inherited from interface com.caucho.quercus.lib.file.BinaryStream
seek, stat
 

Constructor Detail

HttpInputOutput

public HttpInputOutput(Env env,
                       Path path,
                       StreamContextResource context)
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

write

public void write(int ch)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

appendTo

public StringValue appendTo(StringValue builder)
                     throws java.io.IOException
Appends to a string builder.

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

getInputStream

public java.io.InputStream getInputStream()
Returns the read 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

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

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
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 a Binary string.

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

readLine

public StringValue readLine(long length)
                     throws java.io.IOException
Reads a line from the buffer.

Specified by:
readLine 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

isEOF

public boolean isEOF()
Returns true on the EOF.

Specified by:
isEOF in interface BinaryStream
Overrides:
isEOF in class AbstractBinaryOutput

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

unread

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

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

lock

public boolean lock(boolean shared,
                    boolean block)
Description copied from interface: LockableStream
Lock the shared advisory lock. This method will create a shared "read" lock when the shared argument is true and an exclusive "write" lock when the shared argument is false. If the block argument is false then this call will not block if the lock can't be obtained.

Specified by:
lock in interface LockableStream

unlock

public boolean unlock()
Description copied from interface: LockableStream
Unlock the advisory lock. Return true if a lock was held, false otherwise.

Specified by:
unlock in interface LockableStream

closeRead

public void closeRead()
Closes the file 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 BinaryOutput
Specified by:
close in interface BinaryStream
Specified by:
close in interface java.io.Closeable
Overrides:
close in class AbstractBinaryOutput

cleanup

public void cleanup()
Specified by:
cleanup in interface EnvCleanup

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object