`
shangjava
  • 浏览: 1257059 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

提供静态方法访问单例对象中的方法

阅读更多
  1. PropertyUtils 就是此列
  2. /*
  3. *LicensedtotheApacheSoftwareFoundation(ASF)underoneormore
  4. *contributorlicenseagreements.SeetheNOTICEfiledistributedwith
  5. *thisworkforadditionalinformationregardingcopyrightownership.
  6. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0
  7. *(the"License");youmaynotusethisfileexceptincompliancewith
  8. *theLicense.YoumayobtainacopyoftheLicenseat
  9. *
  10. *http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. *Unlessrequiredbyapplicablelaworagreedtoinwriting,software
  13. *distributedundertheLicenseisdistributedonan"ASIS"BASIS,
  14. *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
  15. *SeetheLicenseforthespecificlanguagegoverningpermissionsand
  16. *limitationsundertheLicense.
  17. */
  18. packageorg.apache.commons.beanutils;
  19. importjava.beans.PropertyDescriptor;
  20. importjava.lang.reflect.InvocationTargetException;
  21. importjava.lang.reflect.Method;
  22. importjava.util.Map;
  23. importorg.apache.commons.collections.FastHashMap;
  24. /**
  25. *<p>UtilitymethodsforusingJavaReflectionAPIstofacilitategeneric
  26. *propertygetterandsetteroperationsonJavaobjects.</p>
  27. *
  28. *<p>Theimplementationsforthesemethodsareprovidedby<code>PropertyUtilsBean</code>.
  29. *Formoredetailssee{@linkPropertyUtilsBean}.</p>
  30. *
  31. *@authorCraigR.McClanahan
  32. *@authorRalphSchaer
  33. *@authorChrisAudley
  34. *@authorReyFrancois
  35. *@authorGregorRayman
  36. *@authorJanSorensen
  37. *@authorScottSanders
  38. *@version$Revision:644137$$Date:2008-04-0303:30:23+0100(Thu,03Apr2008)$
  39. *@seePropertyUtilsBean
  40. *@seeorg.apache.commons.beanutils.expression.Resolver
  41. */
  42. publicclass
  43. {
  44. //-----------------------------------------------------ManifestConstants
  45. /**
  46. *Thedelimiterthatpreceedsthezero-relativesubscriptforan
  47. *indexedreference.
  48. *
  49. *@deprecatedThenotationusedforpropertynameexpressionsisnow
  50. *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
  51. *implementationbeingused.
  52. */
  53. publicstaticfinalcharINDEXED_DELIM='[';
  54. /**
  55. *Thedelimiterthatfollowsthezero-relativesubscriptforan
  56. *indexedreference.
  57. *
  58. *@deprecatedThenotationusedforpropertynameexpressionsisnow
  59. *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
  60. *implementationbeingused.
  61. */
  62. publicstaticfinalcharINDEXED_DELIM2=']';
  63. /**
  64. *Thedelimiterthatpreceedsthekeyofamappedproperty.
  65. *
  66. *@deprecatedThenotationusedforpropertynameexpressionsisnow
  67. *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
  68. *implementationbeingused.
  69. */
  70. publicstaticfinalcharMAPPED_DELIM='(';
  71. /**
  72. *Thedelimiterthatfollowsthekeyofamappedproperty.
  73. *
  74. *@deprecatedThenotationusedforpropertynameexpressionsisnow
  75. *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
  76. *implementationbeingused.
  77. */
  78. publicstaticfinalcharMAPPED_DELIM2=')';
  79. /**
  80. *Thedelimiterthatseparatesthecomponentsofanestedreference.
  81. *
  82. *@deprecatedThenotationusedforpropertynameexpressionsisnow
  83. *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
  84. *implementationbeingused.
  85. */
  86. publicstaticfinalcharNESTED_DELIM='.';
  87. //-------------------------------------------------------StaticVariables
  88. /**
  89. *Thedebuggingdetaillevelforthiscomponent.
  90. *
  91. *Notethatthisstaticvariablewillhaveunexpectedside-effectsif
  92. *thisclassisdeployedinasharedclassloaderwithinacontainer.
  93. *Howeverasitisactuallycompletelyignoredbythisclassduetoits
  94. *deprecatedstatus,itdoesn'tdoanyactualharm.
  95. *
  96. *@deprecatedThe<code>debug</code>staticpropertyisnolongerused
  97. */
  98. privatestaticintdebug=0;
  99. /**
  100. *The<code>debug</code>staticpropertyisnolongerused
  101. *@returndebugproperty
  102. *@deprecatedThe<code>debug</code>staticpropertyisnolongerused
  103. */
  104. publicstaticintgetDebug(){
  105. return(debug);
  106. }
  107. /**
  108. *The<code>debug</code>staticpropertyisnolongerused
  109. *@paramnewDebugdebugproperty
  110. *@deprecatedThe<code>debug</code>staticpropertyisnolongerused
  111. */
  112. publicstaticvoidsetDebug(intnewDebug){
  113. debug=newDebug;
  114. }
  115. //---------------------------------------------------------PublicMethods
  116. /**
  117. *Clearanycachedpropertydescriptorsinformationforallclasses
  118. *loadedbyanyclassloaders.Thisisusefulincaseswhereclass
  119. *loadersarethrownawaytoimplementclassreloading.
  120. *
  121. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  122. *
  123. *@seePropertyUtilsBean#clearDescriptors
  124. */
  125. publicstaticvoidclearDescriptors(){
  126. PropertyUtilsBean.getInstance().clearDescriptors();
  127. }
  128. /**
  129. *<p>Copypropertyvaluesfromthe"origin"beantothe"destination"bean
  130. *forallcaseswherethepropertynamesarethesame(eventhoughthe
  131. *actualgetterandsettermethodsmighthavebeencustomizedvia
  132. *<code>BeanInfo</code>classes).</p>
  133. *
  134. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  135. *
  136. *@paramdestDestinationbeanwhosepropertiesaremodified
  137. *@paramorigOriginbeanwhosepropertiesareretrieved
  138. *
  139. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  140. *accesstothepropertyaccessormethod
  141. *@exceptionIllegalArgumentExceptionifthe<code>dest</code>or
  142. *<code>orig</code>argumentisnull
  143. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  144. *throwsanexception
  145. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  146. *propetycannotbefound
  147. *@seePropertyUtilsBean#copyProperties
  148. */
  149. publicstaticvoidcopyProperties(Objectdest,Objectorig)
  150. throwsIllegalAccessException,InvocationTargetException,
  151. NoSuchMethodException{
  152. PropertyUtilsBean.getInstance().copyProperties(dest,orig);
  153. }
  154. /**
  155. *<p>Returntheentiresetofpropertiesforwhichthespecifiedbean
  156. *providesareadmethod.</p>
  157. *
  158. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  159. *
  160. *@parambeanBeanwhosepropertiesaretobeextracted
  161. *@returnThesetofpropertiesforthebean
  162. *
  163. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  164. *accesstothepropertyaccessormethod
  165. *@exceptionIllegalArgumentExceptionif<code>bean</code>isnull
  166. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  167. *throwsanexception
  168. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  169. *propetycannotbefound
  170. *@seePropertyUtilsBean#describe
  171. */
  172. publicstaticMapdescribe(Objectbean)
  173. throwsIllegalAccessException,InvocationTargetException,
  174. NoSuchMethodException{
  175. return(PropertyUtilsBean.getInstance().describe(bean));
  176. }
  177. /**
  178. *<p>Returnthevalueofthespecifiedindexedpropertyofthespecified
  179. *bean,withnotypeconversions.</p>
  180. *
  181. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  182. *
  183. *@parambeanBeanwhosepropertyistobeextracted
  184. *@paramname<code>propertyname[index]</code>ofthepropertyvalue
  185. *tobeextracted
  186. *@returntheindexedpropertyvalue
  187. *
  188. *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
  189. *isoutsidethevalidrangefortheunderlyingproperty
  190. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  191. *accesstothepropertyaccessormethod
  192. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  193. *<code>name</code>isnull
  194. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  195. *throwsanexception
  196. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  197. *propetycannotbefound
  198. *@seePropertyUtilsBean#getIndexedProperty(Object,String)
  199. */
  200. publicstaticObjectgetIndexedProperty(Objectbean,Stringname)
  201. throwsIllegalAccessException,InvocationTargetException,
  202. NoSuchMethodException{
  203. return(PropertyUtilsBean.getInstance().getIndexedProperty(bean,name));
  204. }
  205. /**
  206. *<p>Returnthevalueofthespecifiedindexedpropertyofthespecified
  207. *bean,withnotypeconversions.</p>
  208. *
  209. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  210. *
  211. *@parambeanBeanwhosepropertyistobeextracted
  212. *@paramnameSimplepropertynameofthepropertyvaluetobeextracted
  213. *@paramindexIndexofthepropertyvaluetobeextracted
  214. *@returntheindexedpropertyvalue
  215. *
  216. *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
  217. *isoutsidethevalidrangefortheunderlyingproperty
  218. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  219. *accesstothepropertyaccessormethod
  220. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  221. *<code>name</code>isnull
  222. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  223. *throwsanexception
  224. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  225. *propetycannotbefound
  226. *@seePropertyUtilsBean#getIndexedProperty(Object,String,int)
  227. */
  228. publicstaticObjectgetIndexedProperty(Objectbean,
  229. Stringname,intindex)
  230. throwsIllegalAccessException,InvocationTargetException,
  231. NoSuchMethodException{
  232. return(PropertyUtilsBean.getInstance().getIndexedProperty(bean,name,index));
  233. }
  234. /**
  235. *<p>Returnthevalueofthespecifiedmappedpropertyofthe
  236. *specifiedbean,withnotypeconversions.</p>
  237. *
  238. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  239. *
  240. *@parambeanBeanwhosepropertyistobeextracted
  241. *@paramname<code>propertyname(key)</code>ofthepropertyvalue
  242. *tobeextracted
  243. *@returnthemappedpropertyvalue
  244. *
  245. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  246. *accesstothepropertyaccessormethod
  247. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  248. *throwsanexception
  249. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  250. *propetycannotbefound
  251. *@seePropertyUtilsBean#getMappedProperty(Object,String)
  252. */
  253. publicstaticObjectgetMappedProperty(Objectbean,Stringname)
  254. throwsIllegalAccessException,InvocationTargetException,
  255. NoSuchMethodException{
  256. return(PropertyUtilsBean.getInstance().getMappedProperty(bean,name));
  257. }
  258. /**
  259. *<p>Returnthevalueofthespecifiedmappedpropertyofthespecified
  260. *bean,withnotypeconversions.</p>
  261. *
  262. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  263. *
  264. *@parambeanBeanwhosepropertyistobeextracted
  265. *@paramnameMappedpropertynameofthepropertyvaluetobeextracted
  266. *@paramkeyKeyofthepropertyvaluetobeextracted
  267. *@returnthemappedpropertyvalue
  268. *
  269. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  270. *accesstothepropertyaccessormethod
  271. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  272. *throwsanexception
  273. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  274. *propetycannotbefound
  275. *@seePropertyUtilsBean#getMappedProperty(Object,String,String)
  276. */
  277. publicstaticObjectgetMappedProperty(Objectbean,
  278. Stringname,Stringkey)
  279. throwsIllegalAccessException,InvocationTargetException,
  280. NoSuchMethodException{
  281. returnPropertyUtilsBean.getInstance().getMappedProperty(bean,name,key);
  282. }
  283. /**
  284. *<p>Returnthemappedpropertydescriptorsforthisbeanclass.</p>
  285. *
  286. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  287. *
  288. *@parambeanClassBeanclasstobeintrospected
  289. *@returnthemappedpropertydescriptors
  290. *@seePropertyUtilsBean#getMappedPropertyDescriptors(Class)
  291. *@deprecatedThismethodshouldnotbeexposed
  292. */
  293. publicstaticFastHashMapgetMappedPropertyDescriptors(ClassbeanClass){
  294. returnPropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass);
  295. }
  296. /**
  297. *<p>Returnthemappedpropertydescriptorsforthisbean.</p>
  298. *
  299. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  300. *
  301. *@parambeanBeantobeintrospected
  302. *@returnthemappedpropertydescriptors
  303. *@seePropertyUtilsBean#getMappedPropertyDescriptors(Object)
  304. *@deprecatedThismethodshouldnotbeexposed
  305. */
  306. publicstaticFastHashMapgetMappedPropertyDescriptors(Objectbean){
  307. returnPropertyUtilsBean.getInstance().getMappedPropertyDescriptors(bean);
  308. }
  309. /**
  310. *<p>Returnthevalueofthe(possiblynested)propertyofthespecified
  311. *name,forthespecifiedbean,withnotypeconversions.</p>
  312. *
  313. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  314. *
  315. *@parambeanBeanwhosepropertyistobeextracted
  316. *@paramnamePossiblynestednameofthepropertytobeextracted
  317. *@returnthenestedpropertyvalue
  318. *
  319. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  320. *accesstothepropertyaccessormethod
  321. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  322. *<code>name</code>isnull
  323. *@exceptionNestedNullExceptionifanestedreferencetoa
  324. *propertyreturnsnull
  325. *@exceptionInvocationTargetException
  326. *ifthepropertyaccessormethodthrowsanexception
  327. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  328. *propetycannotbefound
  329. *@seePropertyUtilsBean#getNestedProperty
  330. */
  331. publicstaticObjectgetNestedProperty(Objectbean,Stringname)
  332. throwsIllegalAccessException,InvocationTargetException,
  333. NoSuchMethodException{
  334. returnPropertyUtilsBean.getInstance().getNestedProperty(bean,name);
  335. }
  336. /**
  337. *<p>Returnthevalueofthespecifiedpropertyofthespecifiedbean,
  338. *nomatterwhichpropertyreferenceformatisused,withno
  339. *typeconversions.</p>
  340. *
  341. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  342. *
  343. *@parambeanBeanwhosepropertyistobeextracted
  344. *@paramnamePossiblyindexedand/ornestednameoftheproperty
  345. *tobeextracted
  346. *@returnthepropertyvalue
  347. *
  348. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  349. *accesstothepropertyaccessormethod
  350. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  351. *<code>name</code>isnull
  352. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  353. *throwsanexception
  354. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  355. *propetycannotbefound
  356. *@seePropertyUtilsBean#getProperty
  357. */
  358. publicstaticObjectgetProperty(Objectbean,Stringname)
  359. throwsIllegalAccessException,InvocationTargetException,
  360. NoSuchMethodException{
  361. return(PropertyUtilsBean.getInstance().getProperty(bean,name));
  362. }
  363. /**
  364. *<p>Retrievethepropertydescriptorforthespecifiedpropertyofthe
  365. *specifiedbean,orreturn<code>null</code>ifthereisnosuch
  366. *descriptor.</p>
  367. *
  368. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  369. *
  370. *@parambeanBeanforwhichapropertydescriptorisrequested
  371. *@paramnamePossiblyindexedand/ornestednameofthepropertyfor
  372. *whichapropertydescriptorisrequested
  373. *@returnthepropertydescriptor
  374. *
  375. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  376. *accesstothepropertyaccessormethod
  377. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  378. *<code>name</code>isnull
  379. *@exceptionIllegalArgumentExceptionifanestedreferencetoa
  380. *propertyreturnsnull
  381. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  382. *throwsanexception
  383. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  384. *propetycannotbefound
  385. *@seePropertyUtilsBean#getPropertyDescriptor
  386. */
  387. publicstaticPropertyDescriptorgetPropertyDescriptor(Objectbean,
  388. Stringname)
  389. throwsIllegalAccessException,InvocationTargetException,
  390. NoSuchMethodException{
  391. returnPropertyUtilsBean.getInstance().getPropertyDescriptor(bean,name);
  392. }
  393. /**
  394. *<p>Retrievethepropertydescriptorsforthespecifiedclass,
  395. *introspectingandcachingthemthefirsttimeaparticularbeanclass
  396. *isencountered.</p>
  397. *
  398. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  399. *
  400. *@parambeanClassBeanclassforwhichpropertydescriptorsarerequested
  401. *@returnthepropertydescriptors
  402. *@exceptionIllegalArgumentExceptionif<code>beanClass</code>isnull
  403. *@seePropertyUtilsBean#getPropertyDescriptors(Class)
  404. */
  405. publicstaticPropertyDescriptor[]
  406. getPropertyDescriptors(ClassbeanClass){
  407. returnPropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass);
  408. }
  409. /**
  410. *<p>Retrievethepropertydescriptorsforthespecifiedbean,
  411. *introspectingandcachingthemthefirsttimeaparticularbeanclass
  412. *isencountered.</p>
  413. *
  414. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  415. *
  416. *@parambeanBeanforwhichpropertydescriptorsarerequested
  417. *@returnthepropertydescriptors
  418. *@exceptionIllegalArgumentExceptionif<code>bean</code>isnull
  419. *@seePropertyUtilsBean#getPropertyDescriptors(Object)
  420. */
  421. publicstaticPropertyDescriptor[]getPropertyDescriptors(Objectbean){
  422. returnPropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
  423. }
  424. /**
  425. *<p>ReturntheJavaClassrepesentingthepropertyeditorclassthathas
  426. *beenregisteredforthisproperty(ifany).</p>
  427. *
  428. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  429. *
  430. *@parambeanBeanforwhichapropertydescriptorisrequested
  431. *@paramnamePossiblyindexedand/ornestednameofthepropertyfor
  432. *whichapropertydescriptorisrequested
  433. *@returnthepropertyeditorclass
  434. *
  435. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  436. *accesstothepropertyaccessormethod
  437. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  438. *<code>name</code>isnull
  439. *@exceptionIllegalArgumentExceptionifanestedreferencetoa
  440. *propertyreturnsnull
  441. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  442. *throwsanexception
  443. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  444. *propetycannotbefound
  445. *@seePropertyUtilsBean#getPropertyEditorClass(Object,String)
  446. */
  447. publicstaticClassgetPropertyEditorClass(Objectbean,Stringname)
  448. throwsIllegalAccessException,InvocationTargetException,
  449. NoSuchMethodException{
  450. returnPropertyUtilsBean.getInstance().getPropertyEditorClass(bean,name);
  451. }
  452. /**
  453. *<p>ReturntheJavaClassrepresentingthepropertytypeofthespecified
  454. *property,or<code>null</code>ifthereisnosuchpropertyforthe
  455. *specifiedbean.</p>
  456. *
  457. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  458. *
  459. *@parambeanBeanforwhichapropertydescriptorisrequested
  460. *@paramnamePossiblyindexedand/ornestednameofthepropertyfor
  461. *whichapropertydescriptorisrequested
  462. *@returnThepropertytype
  463. *
  464. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  465. *accesstothepropertyaccessormethod
  466. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  467. *<code>name</code>isnull
  468. *@exceptionIllegalArgumentExceptionifanestedreferencetoa
  469. *propertyreturnsnull
  470. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  471. *throwsanexception
  472. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  473. *propetycannotbefound
  474. *@seePropertyUtilsBean#getPropertyType(Object,String)
  475. */
  476. publicstaticClassgetPropertyType(Objectbean,Stringname)
  477. throwsIllegalAccessException,InvocationTargetException,
  478. NoSuchMethodException{
  479. returnPropertyUtilsBean.getInstance().getPropertyType(bean,name);
  480. }
  481. /**
  482. *<p>Returnanaccessiblepropertygettermethodforthisproperty,
  483. *ifthereisone;otherwisereturn<code>null</code>.</p>
  484. *
  485. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  486. *
  487. *@paramdescriptorPropertydescriptortoreturnagetterfor
  488. *@returnThereadmethod
  489. *@seePropertyUtilsBean#getReadMethod(PropertyDescriptor)
  490. */
  491. publicstaticMethodgetReadMethod(PropertyDescriptordescriptor){
  492. return(PropertyUtilsBean.getInstance().getReadMethod(descriptor));
  493. }
  494. /**
  495. *<p>Returnthevalueofthespecifiedsimplepropertyofthespecified
  496. *bean,withnotypeconversions.</p>
  497. *
  498. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  499. *
  500. *@parambeanBeanwhosepropertyistobeextracted
  501. *@paramnameNameofthepropertytobeextracted
  502. *@returnThepropertyvalue
  503. *
  504. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  505. *accesstothepropertyaccessormethod
  506. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  507. *<code>name</code>isnull
  508. *@exceptionIllegalArgumentExceptionifthepropertyname
  509. *isnestedorindexed
  510. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  511. *throwsanexception
  512. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  513. *propetycannotbefound
  514. *@seePropertyUtilsBean#getSimpleProperty
  515. */
  516. publicstaticObjectgetSimpleProperty(Objectbean,Stringname)
  517. throwsIllegalAccessException,InvocationTargetException,
  518. NoSuchMethodException{
  519. returnPropertyUtilsBean.getInstance().getSimpleProperty(bean,name);
  520. }
  521. /**
  522. *<p>Returnanaccessiblepropertysettermethodforthisproperty,
  523. *ifthereisone;otherwisereturn<code>null</code>.</p>
  524. *
  525. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  526. *
  527. *@paramdescriptorPropertydescriptortoreturnasetterfor
  528. *@returnThewritemethod
  529. *@seePropertyUtilsBean#getWriteMethod(PropertyDescriptor)
  530. */
  531. publicstaticMethodgetWriteMethod(PropertyDescriptordescriptor){
  532. returnPropertyUtilsBean.getInstance().getWriteMethod(descriptor);
  533. }
  534. /**
  535. *<p>Return<code>true</code>ifthespecifiedpropertynameidentifies
  536. *areadablepropertyonthespecifiedbean;otherwise,return
  537. *<code>false</code>.</p>
  538. *
  539. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  540. *
  541. *@parambeanBeantobeexamined(maybea{@linkDynaBean}
  542. *@paramnamePropertynametobeevaluated
  543. *@return<code>true</code>ifthepropertyisreadable,
  544. *otherwise<code>false</code>
  545. *
  546. *@exceptionIllegalArgumentExceptionif<code>bean</code>
  547. *or<code>name</code>is<code>null</code>
  548. *@seePropertyUtilsBean#isReadable
  549. *@sinceBeanUtils1.6
  550. */
  551. publicstaticbooleanisReadable(Objectbean,Stringname){
  552. returnPropertyUtilsBean.getInstance().isReadable(bean,name);
  553. }
  554. /**
  555. *<p>Return<code>true</code>ifthespecifiedpropertynameidentifies
  556. *awriteablepropertyonthespecifiedbean;otherwise,return
  557. *<code>false</code>.</p>
  558. *
  559. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  560. *
  561. *@parambeanBeantobeexamined(maybea{@linkDynaBean}
  562. *@paramnamePropertynametobeevaluated
  563. *@return<code>true</code>ifthepropertyiswriteable,
  564. *otherwise<code>false</code>
  565. *
  566. *@exceptionIllegalArgumentExceptionif<code>bean</code>
  567. *or<code>name</code>is<code>null</code>
  568. *@seePropertyUtilsBean#isWriteable
  569. *@sinceBeanUtils1.6
  570. */
  571. publicstaticbooleanisWriteable(Objectbean,Stringname){
  572. returnPropertyUtilsBean.getInstance().isWriteable(bean,name);
  573. }
  574. /**
  575. *<p>Setsthevalueofthespecifiedindexedpropertyofthespecified
  576. *bean,withnotypeconversions.</p>
  577. *
  578. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  579. *
  580. *@parambeanBeanwhosepropertyistobemodified
  581. *@paramname<code>propertyname[index]</code>ofthepropertyvalue
  582. *tobemodified
  583. *@paramvalueValuetowhichthespecifiedpropertyelement
  584. *shouldbeset
  585. *
  586. *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
  587. *isoutsidethevalidrangefortheunderlyingproperty
  588. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  589. *accesstothepropertyaccessormethod
  590. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  591. *<code>name</code>isnull
  592. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  593. *throwsanexception
  594. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  595. *propetycannotbefound
  596. *@seePropertyUtilsBean#setIndexedProperty(Object,String,Object)
  597. */
  598. publicstaticvoidsetIndexedProperty(Objectbean,Stringname,
  599. Objectvalue)
  600. throwsIllegalAccessException,InvocationTargetException,
  601. NoSuchMethodException{
  602. PropertyUtilsBean.getInstance().setIndexedProperty(bean,name,value);
  603. }
  604. /**
  605. *<p>Setsthevalueofthespecifiedindexedpropertyofthespecified
  606. *bean,withnotypeconversions.</p>
  607. *
  608. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  609. *
  610. *@parambeanBeanwhosepropertyistobeset
  611. *@paramnameSimplepropertynameofthepropertyvaluetobeset
  612. *@paramindexIndexofthepropertyvaluetobeset
  613. *@paramvalueValuetowhichtheindexedpropertyelementistobeset
  614. *
  615. *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
  616. *isoutsidethevalidrangefortheunderlyingproperty
  617. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  618. *accesstothepropertyaccessormethod
  619. *@exceptionIllegalArgumentExceptionif<code>bean</code>or
  620. *<code>name</code>isnull
  621. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  622. *throwsanexception
  623. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  624. *propetycannotbefound
  625. *@seePropertyUtilsBean#setIndexedProperty(Object,String,Object)
  626. */
  627. publicstaticvoidsetIndexedProperty(Objectbean,Stringname,
  628. intindex,Objectvalue)
  629. throwsIllegalAccessException,InvocationTargetException,
  630. NoSuchMethodException{
  631. PropertyUtilsBean.getInstance().setIndexedProperty(bean,name,index,value);
  632. }
  633. /**
  634. *<p>Setsthevalueofthespecifiedmappedpropertyofthe
  635. *specifiedbean,withnotypeconversions.</p>
  636. *
  637. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  638. *
  639. *@parambeanBeanwhosepropertyistobeset
  640. *@paramname<code>propertyname(key)</code>ofthepropertyvalue
  641. *tobeset
  642. *@paramvalueThepropertyvaluetobeset
  643. *
  644. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  645. *accesstothepropertyaccessormethod
  646. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  647. *throwsanexception
  648. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  649. *propetycannotbefound
  650. *@seePropertyUtilsBean#setMappedProperty(Object,String,Object)
  651. */
  652. publicstaticvoidsetMappedProperty(Objectbean,Stringname,
  653. Objectvalue)
  654. throwsIllegalAccessException,InvocationTargetException,
  655. NoSuchMethodException{
  656. PropertyUtilsBean.getInstance().setMappedProperty(bean,name,value);
  657. }
  658. /**
  659. *<p>Setsthevalueofthespecifiedmappedpropertyofthespecified
  660. *bean,withnotypeconversions.</p>
  661. *
  662. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  663. *
  664. *@parambeanBeanwhosepropertyistobeset
  665. *@paramnameMappedpropertynameofthepropertyvaluetobeset
  666. *@paramkeyKeyofthepropertyvaluetobeset
  667. *@paramvalueThepropertyvaluetobeset
  668. *
  669. *@exceptionIllegalAccessExceptionifthecallerdoesnothave
  670. *accesstothepropertyaccessormethod
  671. *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
  672. *throwsanexception
  673. *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
  674. *propetycannotbefound
  675. *@seePropertyUtilsBean#setMappedProperty(Object,String,String,Object)
  676. */
  677. publicstaticvoidsetMappedProperty(Objectbean,Stringname,
  678. Stringkey,Objectvalue)
  679. throwsIllegalAccessException,InvocationTargetException,
  680. NoSuchMethodException{
  681. PropertyUtilsBean.getInstance().setMappedProperty(bean,name,key,value);
  682. }
  683. /**
  684. *<p>Setsthevalueofthe(possiblynested)propertyofthespecified
  685. *name,forthespecifiedbean,withnotypeconversions.</p>
  686. *
  687. *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
  688. *
  689. *@parambeanBeanwhosepropertyistobemodified
  690. *@paramnamePossiblynestednameofthepropertytobemodified
  691. *@paramvalueValuetowhichthepropertyistobeset
  692. <li cl
    分享到:
    评论

相关推荐

    单例模式中声明静态自己类型的指针编译显示未定义处理

    单例模式是软件设计模式中的一种,用于控制类的实例化过程,确保一个类只有一个实例,并提供一个全局访问点。这种模式在系统中需要频繁创建和销毁的对象,或者需要共享资源的情况下非常有用。然而,实现单例模式时,...

    第5天static静态关键字和单例模式.pptx

    - 饿汉式(静态常量):类加载时创建单例对象。 - 枚举实现:简单高效,天然支持序列化机制。 通过上述介绍可以看出,`static`关键字和单例模式是Java编程中非常重要的两个概念。正确理解和使用它们能够帮助...

    43丨单例模式(下):如何设计实现一个集群环境下的分布式单例模式?1

    在单例模式中,类的构造函数是私有的,防止外部直接创建对象,而是通过静态方法获取该类的唯一实例。单例模式的唯一性通常是在进程范围内,即在同一个进程中,无论何时调用单例类的获取实例方法,都会返回相同的对象...

    QT静态单例管理信号和槽

    总结来说,QT静态单例管理信号和槽是通过限制类实例化次数,提供全局访问点,以确保在整个应用程序中对特定资源的统一管理和通信。这种方式既保证了资源的唯一性,又简化了代码的结构,是Qt开发中常用的一种设计策略...

    深入掌握Python中的类方法与静态方法:使用技巧与实践案例

    在Python编程中,类方法和静态方法是面向对象编程的重要组成部分。它们提供了不同的方式来实现代码的封装和复用。类方法至少需要一个类作为第一个参数,通常用于访问和修改类属性。静态方法则不需要任何隐式或显式的...

    单例模式的四种实现方法

    // 通过静态内部类访问单例对象 } } ``` **解析**: - **静态内部类**:这种方式利用了 Java 类加载机制来确保单例模式的实现,只有当首次调用 `getInstance()` 方法时才会加载静态内部类并初始化单例对象。 - **...

    单例模式与垃圾回收机制

    这是因为单例对象通常通过静态成员变量持有引用,而静态成员变量作为方法区的一部分,不会因普通对象的回收而被清除。具体来说,根据根搜索算法,只要静态变量还持有对单例对象的引用,那么该对象就仍然被认为是可达...

    JAVA单例模式的几种实现方法

    // 静态工厂方法,提供外部获取单例对象的唯一入口 public static Singleton1 getInstance() { return single; } } ``` **特点**: - **安全性高**:由于在类加载时就已完成实例化,因此不需要担心多线程环境下...

    Java中的静态变量静态方法静态块与静态类.docx

    在一个静态方法中,除了局部变量外,能够访问的外部变量也必须是静态的,能够访问的外部方法也必须是静态的,实例变量和实例方法均不能访问。 静态方法通常是 public 的,作为工具类的工具方法出现。 例如: ```...

    设计模式之单例模式(结合工厂模式)

    单例对象的创建可以在静态初始化块中完成,或者在getInstance方法中通过DCL模式实现。 在项目中,`src`目录可能包含了这些设计模式的源码示例,可以用来学习和理解如何实际应用单例模式和工厂模式。通过阅读和分析...

    Java中的五种实现方法【单例模式】

    在Java编程语言中,单例模式是一种常用的软件设计模式,它的主要目的是确保一个类只有一个实例,并提供一个全局访问点。这种模式在系统中需要频繁创建和销毁对象时,或者对象的创建过程比较昂贵时,特别有用。单例...

    php面对对象中static静态属性和静态方法的调用_.docx

    而当尝试在静态方法 `tell()` 中访问非静态属性 `$height` 时,会抛出错误,因为静态方法没有实例上下文,无法确定 `$this` 对应哪个实例。 总结一下 PHP 中 `static` 的关键点: 1. 静态属性可以在类的任何实例...

    OC单例模式讲解

    4. **提供获取实例的方法**:通常会提供一个静态方法或类方法来获取单例对象,这个方法会检查是否已经存在实例,如果不存在则创建一个新的实例并返回;如果已经存在,则直接返回已存在的实例。 5. **懒加载**:即在...

    java单例设计模式 4中实现方式,重点介绍了静态内部类的实现方式

    具体来说它将单例对象的创建延迟到静态内部类被加载时才执行,从而避免了多线程环境下的同步问题。下面是一个简单的示例代码: ```java public class SingletonDemo { private static Map, String&gt; idCodeMap = ...

    php单例模式实例

    3. 防止克隆:为了避免通过`clone`关键字复制单例对象,我们还需要封锁`__clone()`魔术方法。 ```php class Singleton { // ... private function __clone() {} } ``` 4. 防止序列化和反序列化:如果允许对象被...

    使用单例模式实现计数器

    在C#中,我们可以利用单例模式来创建一个计数器类,以确保在整个应用程序的生命周期内,计数器只存在一个实例,并且能够被多个对象安全地共享和访问。 首先,我们需要理解单例模式的基本原理。单例模式的关键在于...

    场景管理单例模式1

    场景管理单例模式1 单例模式(Singleton Pattern)是一种常用的设计...在 Unity3D 中,单例模式可以用来管理场景,提供了一个全局访问点来访问单例对象。这种模式可以提高性能,简化代码,并且可以确保只有一个实例。

    生成静态的方法

    总结来说,"静态"关键字在编程中提供了许多有用的特性,如简化代码、优化资源使用以及实现特定设计模式。理解并恰当运用静态方法、变量和类,是编写高效、可维护的代码的关键。然而,过度使用静态元素可能会导致代码...

    java:单例模式 作为对象的创建模式

    3. **全局访问点**:类提供一个全局的访问点,使得任何需要使用该类实例的地方,都可以通过这个公共的静态方法获取到唯一实例。 在Java中,常见的单例实现方式有两种:饿汉式(Eager Initialization)和懒汉式...

Global site tag (gtag.js) - Google Analytics