Content Pipeline Guide > Content Pipelines > Creating Filters and Filter Adapters
  
Creating Filters and Filter Adapters
At a basic level, a filter in a content pipeline is a Java object that implements at least one of the seven SAX2 interfaces. You can use the publishing framework to write custom filters. These filters must conform to the SAX2 interfaces.
You can use filters in a pipeline to perform a variety of processes. The following list describes primitive transformations that filters can perform. You can also combine these filters to create more powerful transformations.
Suppression or profiling — Filters out content that does not match certain criteria. The criteria may be imposed on elements, attribute values, or content. The output is a subset of the input.
Extraction — Retains data that matches certain criteria. The criteria can be based on markup or content. The output is a subset of the input.
Insertion or embellishing — Adds data to a document, and is driven by document content or external information. A data merge is an example of a database-driven insertion. The output is a superset of the input.
Aggregation — Assembles many documents into one document. Aggregation can be driven by a single document, called by a driver, or by external data.
Division or disassembly — Splits one document into components. Division can be driven by document markup or by size constraints on the resulting chunks.
Reordering — Moves data within a document from one location to another. You can reorder using markup to identify the data to move or content or attribute values to define target locations. Sorting is an example of reordering.
A filter needs an adapter object. An adapter is a Java object that implements the FilterAdapter interface. The FilterAdapter interface defines methods that allow the composer to query the SAX2 interfaces that the filter supports. It also defines methods that allow the composer to initialize and configure the filter.
An adapter is responsible for creating and destroying the filter. It knows which SAX2 interfaces the filter implements. Thus, when the composer queries the adapter for the filter’s SAX2 interfaces, it returns the filter or null.