1 61 62 63 package com.opensymphony.workflow.designer.beanutils; 64 65 import java.beans.PropertyDescriptor ; 66 import java.lang.reflect.InvocationTargetException ; 67 import java.lang.reflect.Method ; 68 import java.util.Map ; 69 70 87 88 public class PropertyUtils { 89 90 91 93 94 98 public static final char INDEXED_DELIM = '['; 99 100 101 105 public static final char INDEXED_DELIM2 = ']'; 106 107 108 111 public static final char MAPPED_DELIM = '('; 112 113 114 117 public static final char MAPPED_DELIM2 = ')'; 118 119 120 123 public static final char NESTED_DELIM = '.'; 124 125 126 128 129 131 132 141 public static void clearDescriptors() { 142 143 PropertyUtilsBean.getInstance().clearDescriptors(); 144 145 } 146 147 148 158 public static void copyProperties(Object dest, Object orig) 159 throws IllegalAccessException , InvocationTargetException , 160 NoSuchMethodException { 161 162 PropertyUtilsBean.getInstance().copyProperties(dest, orig); 163 } 164 165 166 174 public static Map describe(Object bean) 175 throws IllegalAccessException , InvocationTargetException , 176 NoSuchMethodException { 177 178 return (PropertyUtilsBean.getInstance().describe(bean)); 179 180 } 181 182 183 191 public static Object getIndexedProperty(Object bean, String name) 192 throws IllegalAccessException , InvocationTargetException , 193 NoSuchMethodException { 194 195 return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name)); 196 197 } 198 199 200 208 public static Object getIndexedProperty(Object bean, 209 String name, int index) 210 throws IllegalAccessException , InvocationTargetException , 211 NoSuchMethodException { 212 213 return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name, index)); 214 } 215 216 217 225 public static Object getMappedProperty(Object bean, String name) 226 throws IllegalAccessException , InvocationTargetException , 227 NoSuchMethodException { 228 229 return (PropertyUtilsBean.getInstance().getMappedProperty(bean, name)); 230 231 } 232 233 234 242 public static Object getMappedProperty(Object bean, 243 String name, String key) 244 throws IllegalAccessException , InvocationTargetException , 245 NoSuchMethodException { 246 247 return PropertyUtilsBean.getInstance().getMappedProperty(bean, name, key); 248 249 } 250 251 252 259 public static Map getMappedPropertyDescriptors(Class beanClass) { 260 261 return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass); 262 263 } 264 265 266 273 public static Map getMappedPropertyDescriptors(Object bean) { 274 275 return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(bean); 276 277 } 278 279 280 288 public static Object getNestedProperty(Object bean, String name) 289 throws IllegalAccessException , InvocationTargetException , 290 NoSuchMethodException { 291 292 return PropertyUtilsBean.getInstance().getNestedProperty(bean, name); 293 294 } 295 296 297 306 public static Object getProperty(Object bean, String name) 307 throws IllegalAccessException , InvocationTargetException , 308 NoSuchMethodException { 309 310 return (PropertyUtilsBean.getInstance().getProperty(bean, name)); 311 312 } 313 314 315 324 public static PropertyDescriptor getPropertyDescriptor(Object bean, 325 String name) 326 throws IllegalAccessException , InvocationTargetException , 327 NoSuchMethodException { 328 329 return PropertyUtilsBean.getInstance().getPropertyDescriptor(bean, name); 330 331 } 332 333 334 343 public static PropertyDescriptor [] 344 getPropertyDescriptors(Class beanClass) { 345 346 return PropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass); 347 348 } 349 350 351 360 public static PropertyDescriptor [] getPropertyDescriptors(Object bean) { 361 362 return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean); 363 364 } 365 366 367 375 public static Class getPropertyEditorClass(Object bean, String name) 376 throws IllegalAccessException , InvocationTargetException , 377 NoSuchMethodException { 378 379 return PropertyUtilsBean.getInstance().getPropertyEditorClass(bean, name); 380 381 } 382 383 384 393 public static Class getPropertyType(Object bean, String name) 394 throws IllegalAccessException , InvocationTargetException , 395 NoSuchMethodException { 396 397 return PropertyUtilsBean.getInstance().getPropertyType(bean, name); 398 } 399 400 401 409 public static Method getReadMethod(PropertyDescriptor descriptor) { 410 411 return (PropertyUtilsBean.getInstance().getReadMethod(descriptor)); 412 413 } 414 415 416 424 public static Object getSimpleProperty(Object bean, String name) 425 throws IllegalAccessException , InvocationTargetException , 426 NoSuchMethodException { 427 428 return PropertyUtilsBean.getInstance().getSimpleProperty(bean, name); 429 430 } 431 432 433 441 public static Method getWriteMethod(PropertyDescriptor descriptor) { 442 443 return PropertyUtilsBean.getInstance().getWriteMethod(descriptor); 444 445 } 446 447 448 458 public static boolean isReadable(Object bean, String name) { 459 460 return PropertyUtilsBean.getInstance().isReadable(bean, name); 461 } 462 463 464 474 public static boolean isWriteable(Object bean, String name) { 475 476 return PropertyUtilsBean.getInstance().isWriteable(bean, name); 477 } 478 479 480 488 public static void setIndexedProperty(Object bean, String name, 489 Object value) 490 throws IllegalAccessException , InvocationTargetException , 491 NoSuchMethodException { 492 493 PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, value); 494 495 } 496 497 498 506 public static void setIndexedProperty(Object bean, String name, 507 int index, Object value) 508 throws IllegalAccessException , InvocationTargetException , 509 NoSuchMethodException { 510 511 PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, index, value); 512 } 513 514 515 523 public static void setMappedProperty(Object bean, String name, 524 Object value) 525 throws IllegalAccessException , InvocationTargetException , 526 NoSuchMethodException { 527 528 PropertyUtilsBean.getInstance().setMappedProperty(bean, name, value); 529 } 530 531 532 540 public static void setMappedProperty(Object bean, String name, 541 String key, Object value) 542 throws IllegalAccessException , InvocationTargetException , 543 NoSuchMethodException { 544 545 PropertyUtilsBean.getInstance().setMappedProperty(bean, name, key, value); 546 } 547 548 549 557 public static void setNestedProperty(Object bean, 558 String name, Object value) 559 throws IllegalAccessException , InvocationTargetException , 560 NoSuchMethodException { 561 562 PropertyUtilsBean.getInstance().setNestedProperty(bean, name, value); 563 } 564 565 566 575 public static void setProperty(Object bean, String name, Object value) 576 throws IllegalAccessException , InvocationTargetException , 577 NoSuchMethodException { 578 579 PropertyUtilsBean.getInstance().setProperty(bean, name, value); 580 581 } 582 583 584 592 public static void setSimpleProperty(Object bean, 593 String name, Object value) 594 throws IllegalAccessException , InvocationTargetException , 595 NoSuchMethodException { 596 597 PropertyUtilsBean.getInstance().setSimpleProperty(bean, name, value); 598 } 599 600 601 } 602 | Popular Tags |