KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > config > impl > digester > elements > ManagedProperty


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.config.impl.digester.elements;
17
18 import javax.faces.context.FacesContext;
19 import javax.faces.el.ValueBinding;
20 import javax.faces.webapp.UIComponentTag;
21
22 import org.apache.myfaces.config.impl.digester.elements.ListEntries;
23
24
25 /**
26  * @author <a HREF="mailto:oliver@rossmueller.com">Oliver Rossmueller</a> (latest modification by $Author: matze $)
27  * @author Anton Koinov
28  *
29  * @version $Revision: 1.3 $ $Date: 2004/10/13 11:51:00 $
30  * $Log: ManagedProperty.java,v $
31  * Revision 1.3 2004/10/13 11:51:00 matze
32  * renamed packages to org.apache
33  *
34  * Revision 1.2 2004/10/05 22:34:21 dave0000
35  * bug 1021656 with related improvements
36  *
37  */

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