1 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 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 _propertyName; 44 private String _propertyClass; 45 private ValueBinding _valueBinding; 46 private String _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 getPropertyName() 83 { 84 return _propertyName; 85 } 86 87 88 public void setPropertyName(String propertyName) 89 { 90 _propertyName = propertyName; 91 } 92 93 94 public String getPropertyClass() 95 { 96 return _propertyClass; 97 } 98 99 100 public void setPropertyClass(String 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 value) 119 { 120 _value = value; 121 _type = TYPE_VALUE; 122 } 123 124 125 public Object 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 getExpressionString() 143 { 144 throw new UnsupportedOperationException (); 145 } 146 147 public Class getType(FacesContext facesContext) 148 { 149 throw new UnsupportedOperationException (); 150 } 151 152 public Object getValue(FacesContext facesContext) 153 { 154 throw new UnsupportedOperationException (); 155 } 156 157 public boolean isReadOnly(FacesContext facesContext) 158 { 159 throw new UnsupportedOperationException (); 160 } 161 162 public void setValue(FacesContext facesContext, Object value) 163 { 164 throw new UnsupportedOperationException (); 165 } 166 } 167 } 168 | Popular Tags |