01: /*
02: Copyright (C) Etymon Systems, Inc. <http://www.etymon.com/>
03: */
04:
05: package com.etymon.pjx;
06:
07: /**
08: A filtering function that allows examining and modifying PDF
09: objects recursively. {@link PdfObject#filter(PdfObjectFilter)
10: PdfObject.filter(PdfObjectFilter)} passes each object through
11: {@link #preFilter(PdfObject) preFilter(PdfObject)} before
12: descending recursively into the object's contents (if it is a
13: container such as {@link PdfArray PdfArray} or {@link PdfDictionary
14: PdfDictionary}). It then passes the (possibly modified) object
15: through {@link #postFilter(PdfObject) postFilter(PdfObject)} for a
16: second opportunity to examine or modify the object. The modified
17: object is not required to be of the same type as the original
18: object.
19: @author Nassib Nassar
20: */
21: public interface PdfObjectFilter {
22:
23: /**
24: Examines a PDF object and optionally returns a modified
25: object. This method should return the original object or a
26: modified replacement. If no modifications are desired, it
27: should return the original object. This method may also
28: return <code>null</code> in order to discard the object;
29: however, this will cause {@link #postFilter(PdfObject)
30: postFilter(PdfObject)} to be called with a
31: <code>null</code> value as its parameter. A {@link
32: PdfArray PdfArray} or {@link PdfDictionary PdfDictionary}
33: object is considered to be a container, and this method
34: filters the container as a whole before filtering each
35: element within it (assuming the elements are still present
36: in the modified object). When this method receives a
37: container, that container's contents will not yet have been
38: filtered by this method.
39: @param obj the object to examine.
40: @return the "filtered" object.
41: @throws PdfFormatException
42: */
43: public PdfObject preFilter(PdfObject obj) throws PdfFormatException;
44:
45: /**
46: Examines a PDF object and optionally returns a modified
47: object. This method should return the original object or a
48: modified replacement. If no modifications are desired, it
49: should return the original object. This method may also
50: return <code>null</code> in order to discard the object. A
51: {@link PdfArray PdfArray} or {@link PdfDictionary
52: PdfDictionary} object is considered to be a container, and
53: this method filters each element within it before filtering
54: the container as a whole. When this method receives a
55: container, that container's contents will have already been
56: filtered by this method.
57: @param obj the object to examine.
58: @return the "filtered" object.
59: @throws PdfFormatException
60: */
61: public PdfObject postFilter(PdfObject obj)
62: throws PdfFormatException;
63:
64: }
|