class FilterHandler {

    public void serializeFilter(DataInputsType dataInputs, DataFilter filter, Geometry spatialFilter, String layerName)
    {
        if (filter != null || spatialFilter != null)
        {
            OGCFilterParameters parameters = new OGCFilterParameters();
            parameters.setUserFilter(filter);
            parameters.setRegion(spatialFilter);
            parameters.setGeometryTagName("GEOM");

            FilterType ogcFilter = OGCFilterGenerator.buildQuery(parameters, layerName);

            net.opengis.ogc._110.ObjectFactory ogcObjectFactory = new net.opengis.ogc._110.ObjectFactory();
            JAXBElement<FilterType> rootFilter = ogcObjectFactory.createFilter(ogcFilter);

            InputType input = new InputType();

            DataType data = new DataType();

            ComplexDataType complexData = new ComplexDataType();
            complexData.setMimeType("text/xml");
            complexData.getContent().add(rootFilter);

            data.setComplexData(complexData);

            CodeType codeType = new CodeType();
            codeType.setValue(StreamingConstants.LAYER_FILTER);
            input.setIdentifier(codeType);
            input.setData(data);

            dataInputs.getInput().add(input);
        }
    }

}