1 package org.rcfaces.core.internal.converter;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import javax.faces.FacesException;
7 import javax.faces.component.UIComponent;
8 import javax.faces.context.FacesContext;
9 import javax.faces.convert.Converter;
10
11 import org.rcfaces.core.model.AbstractConverter;
12
13
14
15
16
17 public class StrategyListenerConverter extends AbstractConverter {
18
19 public static final Converter SINGLETON = new StrategyListenerConverter();
20
21 private final static int NORMAL= 0x00;
22
23 private final static int DEFAULT= 0x02;
24
25 private final static int CLEAN_ALL= 0x02;
26
27 private final static int CLEAN_BY_CLASS = 0x04;
28
29 private final static int ADD_IF_NEW = 0x08;
30
31 private static final Map STRATEGY = new HashMap(8);
32 static {
33 STRATEGY.put("DEFAULT", new Integer(DEFAULT));
34 STRATEGY.put("NORMAL", new Integer(NORMAL));
35 STRATEGY.put("CLEAN_ALL", new Integer(CLEAN_ALL));
36 STRATEGY.put("CLEAN_BY_CLASS", new Integer(CLEAN_BY_CLASS));
37 STRATEGY.put("ADD_IF_NEW", new Integer(ADD_IF_NEW));
38 }
39
40 public Object getAsObject(FacesContext context, UIComponent component,
41 String value) {
42 if (value == null) {
43 return DEFAULT;
44 }
45
46 Integer strategy = (Integer) STRATEGY.get(value.trim().toUpperCase());
47
48 return strategy;
49 }
50
51 public String getAsString(FacesContext context, UIComponent component,
52 Object value) {
53 throw new FacesException("Not implemented !");
54 }
55 }