View Javadoc

1   /*
2    * $Id: FilterExpressionTools.java,v 1.18 2011/06/16 09:29:41 jbmeslin Exp $
3    * 
4    */
5   package org.rcfaces.core.internal.tools;
6   
7   import java.util.Collections;
8   import java.util.Map;
9   
10  import javax.faces.context.FacesContext;
11  
12  import org.apache.commons.logging.Log;
13  import org.apache.commons.logging.LogFactory;
14  import org.rcfaces.core.lang.FilterPropertiesMap;
15  import org.rcfaces.core.model.IFilterProperties;
16  
17  /**
18   * 
19   * @author Olivier Oeuillot (latest modification by $Author: jbmeslin $)
20   * @version $Revision: 1.18 $ $Date: 2011/06/16 09:29:41 $
21   */
22  public final class FilterExpressionTools {
23      private static final String REVISION = "$Revision: 1.18 $";
24  
25      private static final Log LOG = LogFactory
26              .getLog(FilterExpressionTools.class);
27  
28      private static final String[] STRING_EMPTY_ARRAY = new String[0];
29  
30      /**
31       * 
32       */
33      public static final IFilterProperties EMPTY = new IFilterProperties() {
34          private static final String REVISION = "$Revision: 1.18 $";
35  
36          private static final long serialVersionUID = -3817846186098661680L;
37  
38          public boolean containsKey(String propertyName) {
39              return false;
40          }
41  
42          public Object put(String filterName, Object value) {
43              throw new UnsupportedOperationException(
44                      "Not supported for EMPTY filtersMap !");
45          }
46  
47          public Object remove(String filterName) {
48              throw new UnsupportedOperationException(
49                      "Not supported for EMPTY filtersMap !");
50          }
51  
52          public String[] listNames() {
53              return STRING_EMPTY_ARRAY;
54          }
55  
56          public void clear() {
57              throw new UnsupportedOperationException(
58                      "Not supported for EMPTY filtersMap !");
59          }
60  
61          public boolean isEmpty() {
62              return true;
63          }
64  
65          public int size() {
66              return 0;
67          }
68  
69          public void putAll(Map map) {
70              throw new UnsupportedOperationException(
71                      "Not supported for EMPTY filtersMap !");
72          }
73  
74          public Map toMap() {
75              return Collections.EMPTY_MAP;
76          }
77  
78          public boolean isTransient() {
79              return false;
80          }
81  
82          public void restoreState(FacesContext context, Object state) {
83          }
84  
85          public Object saveState(FacesContext context) {
86              return null;
87          }
88  
89          public void setTransient(boolean newTransientValue) {
90          }
91  
92          public Object getProperty(String name) {
93              return null;
94          }
95  
96          public String getStringProperty(String name) {
97              return null;
98          }
99  
100         public String getStringProperty(String name, String defaultValue) {
101             return defaultValue;
102         }
103 
104         public boolean getBoolProperty(String name, boolean defaultValue) {
105             return defaultValue;
106         }
107 
108         public Boolean getBooleanProperty(String name) {
109             return null;
110         }
111 
112         public int getIntProperty(String name, int defaultValue) {
113             return defaultValue;
114         }
115 
116         public Number getNumberProperty(String name) {
117             return null;
118         }
119 
120         public int hashCode() {
121             return 31;
122         }
123 
124         public boolean equals(Object obj) {
125             if (this == obj) {
126                 return true;
127             }
128 
129             if (obj == null || getClass() != obj.getClass()) {
130                 return false;
131             }
132 
133             return true;
134         }
135 
136     };
137 
138     public static IFilterProperties create(Map map) {
139         return new FilterPropertiesMap(map);
140     }
141 }