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