com.caucho.quercus.lib.zlib
Class Zlib

java.lang.Object
  extended by com.caucho.quercus.lib.zlib.Zlib

public class Zlib
extends java.lang.Object

Zlib object oriented API facade


Constructor Summary
Zlib(Env env, java.lang.String filename, java.lang.String mode, boolean useIncludePath)
          XXX: todo - implement additional read/write modes (a,etc) Creates and sets GZIP stream if mode is 'w' Also creates _fileValue.
 
Method Summary
protected  java.io.InputStream getGZIPInputStream()
          helper function to open file for reading when necessary
 boolean gzclose()
          Closes the gzip stream
 boolean gzeof()
           
 ArrayValue gzfile()
          helper function for ZlibModule.gzfile need to have created a Zlib before calling this
 Value gzgetc(Env env)
           
 StringValue gzgets(int length)
          Gets a (uncompressed) string of up to 'length' bytes read from the given file pointer.
 StringValue gzgetss(int length, StringValue allowedTags)
           
 int gzputs(Env env, java.io.InputStream is, int length)
          alias of gzwrite
 StringValue gzread(Env env, int length)
          same as gzgets but does not stop at '\n' or '\r'
 boolean gzrewind()
          resets to the beginning of the file stream.
 int gzwrite(Env env, java.io.InputStream is, int length)
          Reads from the input and writes to the gzip stream
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Zlib

public Zlib(Env env,
            java.lang.String filename,
            java.lang.String mode,
            boolean useIncludePath)
XXX: todo - implement additional read/write modes (a,etc) Creates and sets GZIP stream if mode is 'w' Also creates _fileValue. All write functions are wrappers around the _fileValue functions using the private class GZFileValueWriter to compress the byte stream.

Parameters:
fileName -
mode - (ie: "w9" or "r7f")
useIncludePath - is always on
Method Detail

gzwrite

public int gzwrite(Env env,
                   java.io.InputStream is,
                   int length)
Reads from the input and writes to the gzip stream

Parameters:
s -
length - # of bytes to compress
Returns:
# of uncompressed bytes

gzclose

public boolean gzclose()
Closes the gzip stream

Returns:
true if successful, false otherwise

gzputs

public int gzputs(Env env,
                  java.io.InputStream is,
                  int length)
alias of gzwrite

Parameters:
env -
s -
length -
Returns:
# of uncompressed bytes

gzgetc

public Value gzgetc(Env env)
Returns:
the next character or BooleanValue.FALSE

gzgets

public StringValue gzgets(int length)
Gets a (uncompressed) string of up to 'length' bytes read from the given file pointer. Reading ends when 'length' bytes have been read, on a newline, or on EOF (whichever comes first).

Parameters:
length -
Returns:
StringValue

gzfile

public ArrayValue gzfile()
helper function for ZlibModule.gzfile need to have created a Zlib before calling this

Returns:
array of uncompressed lines
Throws:
java.io.IOException
java.util.zip.DataFormatException

gzread

public StringValue gzread(Env env,
                          int length)
same as gzgets but does not stop at '\n' or '\r'

Parameters:
length -
Returns:
BinaryValue, an empty BinaryValue if no data read
Throws:
java.io.IOException
java.util.zip.DataFormatException

gzeof

public boolean gzeof()
Returns:
true if eof

gzgetss

public StringValue gzgetss(int length,
                           StringValue allowedTags)
Parameters:
length -
allowedTags -
Returns:
next line stripping tags
Throws:
java.io.IOException
java.util.zip.DataFormatException

gzrewind

public boolean gzrewind()
resets to the beginning of the file stream.

Returns:
always true
Throws:
java.io.IOException

getGZIPInputStream

protected java.io.InputStream getGZIPInputStream()
                                          throws java.io.IOException
helper function to open file for reading when necessary

Throws:
java.io.IOException

toString

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