1 22 package org.jboss.naming; 23 24 import java.beans.PropertyEditor ; 25 26 import org.jboss.util.propertyeditor.PropertyEditors; 27 28 34 public class JNDIBinding 35 { 36 37 private String name; 38 39 private String text; 40 41 private String type; 42 43 private String editor; 44 45 private Object value; 46 47 private boolean trim; 48 49 53 public String getName() 54 { 55 return name; 56 } 57 58 public void setName(String name) 59 { 60 this.name = name; 61 } 62 63 67 public String getText() 68 { 69 return text; 70 } 71 78 public void setText(String text) 79 { 80 if( trim == true ) 81 text = text.trim(); 82 this.text = text; 83 } 84 85 90 public String getType() 91 { 92 return type; 93 } 94 98 public void setType(String type) 99 { 100 this.type = type; 101 } 102 103 107 public String getEditor() 108 { 109 return editor; 110 } 111 115 public void setEditor(String editor) 116 { 117 this.editor = editor; 118 } 119 120 131 public Object getValue() throws Exception 132 { 133 if( value == null && text != null ) 134 { 135 if( editor != null ) 137 { 138 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 139 Class editorClass = loader.loadClass(editor); 140 PropertyEditor pe = (PropertyEditor ) editorClass.newInstance(); 141 pe.setAsText(text); 142 value = pe.getValue(); 143 } 144 else if( type != null ) 145 { 146 PropertyEditor pe = PropertyEditors.getEditor(type); 147 pe.setAsText(text); 148 value = pe.getValue(); 149 } 150 else 151 { 152 value = text; 153 } 154 } 155 return value; 156 } 157 161 public void setValue(Object value) 162 { 163 this.value = value; 164 } 165 166 170 public boolean isTrim() 171 { 172 return trim; 173 } 174 178 public void setTrim(boolean trim) 179 { 180 this.trim = trim; 181 } 182 } 183 | Popular Tags |