public abstract class

CustomFilter

extends Filter
java.lang.Object
   ↳ com.pdftron.filters.Filter
     ↳ com.pdftron.filters.CustomFilter
Known Direct Subclasses

Class Overview

CustomFilter allows for customizing the reading and writing process. It is useful, for example, for users to write their own encryption and decryption methods.

Note that this is an abstract class.

Summary

Constants
int APPEND_MODE Filter is in append mode.
int READ_MODE Filter is in read mode.
int SEEK_CUR The offset is relative to the current position of the filter.
int SEEK_END The offset is relative to the end of the filter.
int SEEK_SET The offset is relative to the beginning of the filter.
String TAG
int WRITE_MODE Filter is in write mode.
Public Constructors
CustomFilter(int mode, Object user_object)
The constructor.
Public Methods
abstract void close()
void destroy()
Frees the native memory of the object.
String getName()
Gets the name of the filter.
Object getUserObject()
Gets the user data from CustomFilter(int, Object).
abstract long onCreateInputIterator(Object user_object)
abstract void onDestroy(Object user_object)
abstract long onFlush(Object user_object)
The abstract function in which the output data is flushed.
abstract long onRead(byte[] buf, Object user_object)
The abstract function in which the input data are read.
abstract long onSeek(long offset, int origin, Object user_object)
The abstract function in which the position indicator of the filter is set.
abstract long onTell(Object user_object)
The abstract function in which the position indicator of the filter is queried.
long onTruncate(long new_size, Object user_object)
The abstract function the size of the filter is set
abstract long onWrite(byte[] buf, Object user_object)
The abstract function in which the data are output.
[Expand]
Inherited Methods
From class com.pdftron.filters.Filter
From class java.lang.Object

Constants

public static final int APPEND_MODE

Filter is in append mode.

Constant Value: 2 (0x00000002)

public static final int READ_MODE

Filter is in read mode.

Constant Value: 0 (0x00000000)

public static final int SEEK_CUR

The offset is relative to the current position of the filter.

Constant Value: 1 (0x00000001)

public static final int SEEK_END

The offset is relative to the end of the filter.

Constant Value: 2 (0x00000002)

public static final int SEEK_SET

The offset is relative to the beginning of the filter.

Constant Value: 0 (0x00000000)

public static final String TAG

Constant Value: "save CustomFilter"

public static final int WRITE_MODE

Filter is in write mode.

Constant Value: 1 (0x00000001)

Public Constructors

public CustomFilter (int mode, Object user_object)

The constructor.

Parameters
mode The mode of the filter. Possible values are READ_MODE , WRITE_MODE, and APPEND_MODE.
user_object The user data that can will be passed back in the abstract functions.

Public Methods

public abstract void close ()

public void destroy ()

Frees the native memory of the object. This can be explicitly called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public String getName ()

Gets the name of the filter.

Returns
  • the descriptive name of the filter.

public Object getUserObject ()

Gets the user data from CustomFilter(int, Object).

public abstract long onCreateInputIterator (Object user_object)

public abstract void onDestroy (Object user_object)

public abstract long onFlush (Object user_object)

The abstract function in which the output data is flushed.

Parameters
user_object The user data from passed in via CustomFilter(int, Object).
Returns
  • If successful, the value is 0; otherwise, it is non-zero.

public abstract long onRead (byte[] buf, Object user_object)

The abstract function in which the input data are read.

Parameters
buf The buffer to contain the data to read, which has already been allocated.
user_object The user data from passed in via CustomFilter(int, Object).
Returns
  • The number of bytes read. It should return 0 if it fails or reaches the end of the input stream.

public abstract long onSeek (long offset, int origin, Object user_object)

The abstract function in which the position indicator of the filter is set.

Parameters
offset Number of bytes to offset from origin. A positive value implies the indicator is moved forward, and a negative value implies the indicator is moved backward.
origin Position from where offset is added. It is specified by one of the following: SEEK_SET, SEEK_CUR, SEEK_END.
user_object The user data from passed in via CustomFilter(int, Object).
Returns
  • The new position of the indicator set. If successful, the value is 0; otherwise, it is non-zero.

public abstract long onTell (Object user_object)

The abstract function in which the position indicator of the filter is queried.

Parameters
user_object The user data from passed in via CustomFilter(int, Object).
Returns
  • The position of the indicator.

public long onTruncate (long new_size, Object user_object)

The abstract function the size of the filter is set

Parameters
new_size number of bytes to resize the filter to.
user_object The user data from passed in via CustomFilter(int, Object).
Returns
  • The new size of the filter.

public abstract long onWrite (byte[] buf, Object user_object)

The abstract function in which the data are output.

Parameters
buf The buffer to contain the data to write out.
user_object The user data from passed in via CustomFilter(int, Object).
Returns
  • The number of bytes successfully written.