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