org.kde.koala
Class KFilterDev

java.lang.Object
  extended by org.kde.qt.QIODevice
      extended by org.kde.koala.KFilterDev
All Implemented Interfaces:
org.kde.qt.QIODeviceInterface, org.kde.qt.QtSupport

public class KFilterDev
extends org.kde.qt.QIODevice

A class for reading and writing compressed data onto a device (e.g. file, but other usages are possible, like a buffer or a socket). To simply read/write compressed files, see deviceForFile.

Author:
David Faure

Field Summary
 
Fields inherited from class org.kde.qt.QIODevice
IO_AbortError, IO_Append, IO_Async, IO_Combined, IO_ConnectError, IO_Direct, IO_FatalError, IO_ModeMask, IO_Ok, IO_Open, IO_OpenError, IO_Raw, IO_ReadError, IO_ReadOnly, IO_ReadWrite, IO_ResourceError, IO_Sequential, IO_StateMask, IO_TimeOutError, IO_Translate, IO_Truncate, IO_TypeMask, IO_UnspecifiedError, IO_WriteError, IO_WriteOnly
 
Constructor Summary
protected KFilterDev(java.lang.Class dummy)
           
  KFilterDev(KFilterBase filter)
           
  KFilterDev(KFilterBase filter, boolean autoDeleteFilterBase)
          Constructs a KFilterDev for a given filter (e.g.
 
Method Summary
 long at()
           
 boolean at(long arg1)
          That one can be quite slow, when going back.
 boolean atEnd()
           
 void close()
          Close after reading or writing.
static org.kde.qt.QIODeviceInterface device(org.kde.qt.QIODeviceInterface inDevice, java.lang.String mimetype)
          Creates an i/o device that is able to read from the QIODevice inDevice, whether the data is compressed or not.
static org.kde.qt.QIODeviceInterface device(org.kde.qt.QIODeviceInterface inDevice, java.lang.String mimetype, boolean autoDeleteInDevice)
          Creates an i/o device that is able to read from the QIODevice inDevice, whether the data is compressed or not.
static org.kde.qt.QIODeviceInterface deviceForFile(java.lang.String fileName)
           
static org.kde.qt.QIODeviceInterface deviceForFile(java.lang.String fileName, java.lang.String mimetype)
           
static org.kde.qt.QIODeviceInterface deviceForFile(java.lang.String fileName, java.lang.String mimetype, boolean forceFilter)
          Creates an i/o device that is able to read from fileName, whether it's compressed or not.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected  void finalize()
          Deletes the wrapped C++ instance
 void flush()
           
 int getch()
           
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 boolean open(int mode)
          Open for reading or writing.
 int putch(int arg1)
           
 long readBlock(java.lang.StringBuffer data, long maxlen)
           
 void setOrigFileName(java.lang.String fileName)
          For writing gzip compressed files only: set the name of the original file, to be used in the gzip header.
 void setSkipHeaders()
          Call this let this device skip the gzip headers when reading/writing.
 long size()
           
 int ungetch(int arg1)
           
 long writeBlock(java.lang.String data, long len)
           
 
Methods inherited from class org.kde.qt.QIODevice
flags, isAsynchronous, isBuffered, isCombinedAccess, isDirectAccess, isInactive, isOpen, isRaw, isReadable, isReadWrite, isSequentialAccess, isSynchronous, isTranslated, isWritable, mode, readAll, readLine, reset, resetStatus, state, status, writeBlock
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KFilterDev

protected KFilterDev(java.lang.Class dummy)

KFilterDev

public KFilterDev(KFilterBase filter,
                  boolean autoDeleteFilterBase)
Constructs a KFilterDev for a given filter (e.g. gzip, bzip2 etc.).

Parameters:
filter - the KFilterBase to use
autoDeleteFilterBase - when true this object will become the owner of filter.

KFilterDev

public KFilterDev(KFilterBase filter)
Method Detail

open

public boolean open(int mode)
Open for reading or writing. If the KFilterBase's device is not opened, it will be opened.

Specified by:
open in interface org.kde.qt.QIODeviceInterface
Overrides:
open in class org.kde.qt.QIODevice

close

public void close()
Close after reading or writing. If the KFilterBase's device was opened by open(), it will be closed.

Specified by:
close in interface org.kde.qt.QIODeviceInterface
Overrides:
close in class org.kde.qt.QIODevice

flush

public void flush()
Specified by:
flush in interface org.kde.qt.QIODeviceInterface
Overrides:
flush in class org.kde.qt.QIODevice

setOrigFileName

public void setOrigFileName(java.lang.String fileName)
For writing gzip compressed files only: set the name of the original file, to be used in the gzip header.

Parameters:
fileName - the name of the original file

setSkipHeaders

public void setSkipHeaders()
Call this let this device skip the gzip headers when reading/writing. This way KFilterDev (with gzip filter) can be used as a direct wrapper around zlib - this is used by KZip.


size

public long size()
Specified by:
size in interface org.kde.qt.QIODeviceInterface
Overrides:
size in class org.kde.qt.QIODevice

at

public long at()
Specified by:
at in interface org.kde.qt.QIODeviceInterface
Overrides:
at in class org.kde.qt.QIODevice

at

public boolean at(long arg1)
That one can be quite slow, when going back. Use with care.

Specified by:
at in interface org.kde.qt.QIODeviceInterface
Overrides:
at in class org.kde.qt.QIODevice

atEnd

public boolean atEnd()
Specified by:
atEnd in interface org.kde.qt.QIODeviceInterface
Overrides:
atEnd in class org.kde.qt.QIODevice

readBlock

public long readBlock(java.lang.StringBuffer data,
                      long maxlen)
Specified by:
readBlock in interface org.kde.qt.QIODeviceInterface
Overrides:
readBlock in class org.kde.qt.QIODevice

writeBlock

public long writeBlock(java.lang.String data,
                       long len)
Specified by:
writeBlock in interface org.kde.qt.QIODeviceInterface
Overrides:
writeBlock in class org.kde.qt.QIODevice

getch

public int getch()
Specified by:
getch in interface org.kde.qt.QIODeviceInterface
Overrides:
getch in class org.kde.qt.QIODevice

putch

public int putch(int arg1)
Specified by:
putch in interface org.kde.qt.QIODeviceInterface
Overrides:
putch in class org.kde.qt.QIODevice

ungetch

public int ungetch(int arg1)
Specified by:
ungetch in interface org.kde.qt.QIODeviceInterface
Overrides:
ungetch in class org.kde.qt.QIODevice

deviceForFile

public static org.kde.qt.QIODeviceInterface deviceForFile(java.lang.String fileName,
                                                          java.lang.String mimetype,
                                                          boolean forceFilter)
Creates an i/o device that is able to read from fileName, whether it's compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used. The compression filter to be used is determined from the fileName if mimetype is empty. Pass "application/x-gzip" or "application/x-bzip2" to force the corresponding decompression filter, if available. Warning: application/x-bzip2 may not be available. In that case a QFile opened on the compressed data will be returned ! Use KFilterBase.findFilterByMimeType and code similar to what deviceForFile is doing, to better control what's happening. The returned QIODevice has to be deleted after using.

Parameters:
fileName - the name of the file to filter
mimetype - the mime type of the file to filter, or null if unknown
forceFilter - if true, the function will either find a compression filter, or return 0. If false, it will always return a QIODevice. If no filter is available it will return a simple QFile. This can be useful if the file is usable without a filter.
Returns:
if a filter has been found, the QIODevice for the filter. If the filter does not exist, the return value depends on forceFilter. The returned QIODevice has to be deleted after using.

deviceForFile

public static org.kde.qt.QIODeviceInterface deviceForFile(java.lang.String fileName,
                                                          java.lang.String mimetype)

deviceForFile

public static org.kde.qt.QIODeviceInterface deviceForFile(java.lang.String fileName)

device

public static org.kde.qt.QIODeviceInterface device(org.kde.qt.QIODeviceInterface inDevice,
                                                   java.lang.String mimetype)
Creates an i/o device that is able to read from the QIODevice inDevice, whether the data is compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used. The compression filter to be used is determined mimetype . Pass "application/x-gzip" or "application/x-bzip2" to use the corresponding decompression filter. Warning: application/x-bzip2 may not be available. In that case 0 will be returned ! The returned QIODevice has to be deleted after using.

Parameters:
inDevice - input device, becomes owned by this device! Automatically deleted!
mimetype - the mime type for the filter
Returns:
a QIODevice that filters the original stream. Must be deleted after using

device

public static org.kde.qt.QIODeviceInterface device(org.kde.qt.QIODeviceInterface inDevice,
                                                   java.lang.String mimetype,
                                                   boolean autoDeleteInDevice)
Creates an i/o device that is able to read from the QIODevice inDevice, whether the data is compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used. The compression filter to be used is determined mimetype . Pass "application/x-gzip" or "application/x-bzip2" to use the corresponding decompression filter. Warning: application/x-bzip2 may not be available. In that case 0 will be returned ! The returned QIODevice has to be deleted after using.

Parameters:
inDevice - input device. Won't be deleted if autoDeleteInDevice = false
mimetype - the mime type for the filter
autoDeleteInDevice - if true, inDevice will be deleted automatically
Returns:
a QIODevice that filters the original stream. Must be deleted after using

finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?