1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.config.impl.digester.elements;
20
21 import java.io.Serializable;
22
23 import javax.faces.context.FacesContext;
24 import javax.faces.el.ValueBinding;
25
26 import org.apache.myfaces.config.impl.digester.elements.ListEntries;
27 import org.apache.myfaces.util.ContainerUtils;
28
29
30
31
32
33
34
35
36 public class ManagedProperty extends org.apache.myfaces.config.element.ManagedProperty implements Serializable
37 {
38 private static final ValueBinding DUMMY_VB = new DummyValueBinding();
39
40 private int _type = TYPE_UNKNOWN;
41 private String _propertyName;
42 private String _propertyClass;
43 private ValueBinding _valueBinding;
44 private String _value;
45 private org.apache.myfaces.config.element.MapEntries _mapEntries;
46 private org.apache.myfaces.config.element.ListEntries _listEntries;
47
48 public int getType()
49 {
50 return _type;
51 }
52
53 public org.apache.myfaces.config.element.MapEntries getMapEntries()
54 {
55 return _mapEntries;
56 }
57
58 public void setMapEntries(org.apache.myfaces.config.element.MapEntries mapEntries)
59 {
60 _mapEntries = mapEntries;
61 _type = TYPE_MAP;
62 }
63
64 public org.apache.myfaces.config.element.ListEntries getListEntries()
65 {
66 return _listEntries;
67 }
68
69 public void setListEntries(ListEntries listEntries)
70 {
71 _listEntries = listEntries;
72 _type = TYPE_LIST;
73 }
74
75 public String getPropertyName()
76 {
77 return _propertyName;
78 }
79
80 public void setPropertyName(String propertyName)
81 {
82 _propertyName = propertyName;
83 }
84
85 public String getPropertyClass()
86 {
87 return _propertyClass;
88 }
89
90 public void setPropertyClass(String propertyClass)
91 {
92 _propertyClass = propertyClass;
93 }
94
95 public boolean isNullValue()
96 {
97 return _type == TYPE_NULL;
98 }
99
100 public void setNullValue()
101 {
102 _type = TYPE_NULL;
103 }
104
105 public void setValue(String value)
106 {
107 _value = value;
108 _type = TYPE_VALUE;
109 }
110
111 public String getValue()
112 {
113 return _value;
114 }
115
116 public Object getRuntimeValue(FacesContext facesContext)
117 {
118 getValueBinding(facesContext);
119
120 return (_valueBinding == DUMMY_VB)
121 ? _value : _valueBinding.getValue(facesContext);
122 }
123
124 public ValueBinding getValueBinding(FacesContext facesContext)
125 {
126 if (_valueBinding == null)
127 {
128 _valueBinding =
129 isValueReference()
130 ? facesContext.getApplication().createValueBinding(_value)
131 : DUMMY_VB;
132 }
133 return _valueBinding;
134 }
135
136 public boolean isValueReference()
137 {
138 return ContainerUtils.isValueReference(_value);
139 }
140
141 private static class DummyValueBinding extends ValueBinding
142 {
143 @Override
144 public String getExpressionString()
145 {
146 throw new UnsupportedOperationException();
147 }
148
149 @Override
150 public Class<?> getType(FacesContext facesContext)
151 {
152 throw new UnsupportedOperationException();
153 }
154
155 @Override
156 public Object getValue(FacesContext facesContext)
157 {
158 throw new UnsupportedOperationException();
159 }
160
161 @Override
162 public boolean isReadOnly(FacesContext facesContext)
163 {
164 throw new UnsupportedOperationException();
165 }
166
167 @Override
168 public void setValue(FacesContext facesContext, Object value)
169 {
170 throw new UnsupportedOperationException();
171 }
172 }
173 }