FILTER

The FILTER or FILTERCLASS keyword is used to specify the content filter class to be applied to the XML DOM document. The FILTER keyword value is used to lookup the filter classname specified by the filter.'value' property in the XMLBindFileService properties file. The filter classname can also be directly specified using the FILTERCLASS keyword.

Example

 

package com.acme.filter ;

 

import java.io.* ;

 

import java.util.HashMap ;

 

import org.w3c.dom.Document ;

 

import com.acme.jsm.JSMTrace ;

import com.acme.jsm.JSMCommand ;

import com.acme.jsm.JSMResource ;

 

public class SampleFilter implements com.acme.jsm.service.ContentFilter

{

    public Object filter ( HashMap properties, Object content )

    {

        if ( content == null )

        {

            return null ;

        }

 

        if ( !(content instanceof Document) )

        {

            throw new IllegalArgumentException ( "SampleFilter: unexpected content class: " + content.getClass().getName() ) ;

        }

 

        JSMTrace trace = (JSMTrace)properties.get ( "jsm.trace" ) ;

 

        JSMCommand command = (JSMCommand)properties.get ( "jsm.command" ) ;

 

        JSMResource resource = (JSMResource)properties.get ( "jsm.resource" ) ;

 

        if ( trace != null )

        {

            m_trace.println ( "Apply SampleFilter" ) ;

        }

 

        /*

            Modify or create new object

        */

 

        /*

            Return replacement or existing object

        */

 

        return content ;

    }

}