View Javadoc

1   /*
2    * $Id: FilteredDataModel.java,v 1.18 2011/06/16 09:29:41 jbmeslin Exp $
3    * 
4    */
5   package org.rcfaces.core.internal.tools;
6   
7   import javax.faces.FacesException;
8   import javax.faces.model.ArrayDataModel;
9   import javax.faces.model.DataModel;
10  
11  import org.rcfaces.core.model.IFilterProperties;
12  
13  /**
14   * @author Olivier Oeuillot (latest modification by $Author: jbmeslin $)
15   * @version $Revision: 1.18 $ $Date: 2011/06/16 09:29:41 $
16   */
17  public class FilteredDataModel {
18      private static final String REVISION = "$Revision: 1.18 $";
19  
20      public static DataModel filter(DataModel dataModel,
21              IFilterProperties filters) {
22          if (filters == null || filters.size() < 1) {
23              return dataModel;
24          }
25  
26          if (dataModel instanceof ArrayDataModel) {
27              return dataModel;
28          }
29  
30          throw new FacesException("Can not filter dataModel '" + dataModel
31                  + "'.");
32      }
33  
34  }