- 浏览: 1257059 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
fangliangkx:
道讯分销系统,订货会系统
服装ERP应用(15):ERP帮助代理商合理订货 -
xlfzj:
刚毕业四个月,我的想想接下来两年咋渡过
一名学过2年编程的菜鸟 . -
jyjava:
不知道我两年后会在哪里,但是我起码知道,我现在该做些什么,该做 ...
一名学过2年编程的菜鸟 . -
Mybeautiful:
想到某年某大公司电话邀请面试,当我说“7年java工作经历,主 ...
一名学过2年编程的菜鸟 . -
wingsrao:
支持楼主的看法,但是还是希望楼主做的如说的!
一名学过2年编程的菜鸟 .
- PropertyUtils 就是此列
- /*
- *LicensedtotheApacheSoftwareFoundation(ASF)underoneormore
- *contributorlicenseagreements.SeetheNOTICEfiledistributedwith
- *thisworkforadditionalinformationregardingcopyrightownership.
- *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0
- *(the"License");youmaynotusethisfileexceptincompliancewith
- *theLicense.YoumayobtainacopyoftheLicenseat
- *
- *http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unlessrequiredbyapplicablelaworagreedtoinwriting,software
- *distributedundertheLicenseisdistributedonan"ASIS"BASIS,
- *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
- *SeetheLicenseforthespecificlanguagegoverningpermissionsand
- *limitationsundertheLicense.
- */
- packageorg.apache.commons.beanutils;
- importjava.beans.PropertyDescriptor;
- importjava.lang.reflect.InvocationTargetException;
- importjava.lang.reflect.Method;
- importjava.util.Map;
- importorg.apache.commons.collections.FastHashMap;
- /**
- *<p>UtilitymethodsforusingJavaReflectionAPIstofacilitategeneric
- *propertygetterandsetteroperationsonJavaobjects.</p>
- *
- *<p>Theimplementationsforthesemethodsareprovidedby<code>PropertyUtilsBean</code>.
- *Formoredetailssee{@linkPropertyUtilsBean}.</p>
- *
- *@authorCraigR.McClanahan
- *@authorRalphSchaer
- *@authorChrisAudley
- *@authorReyFrancois
- *@authorGregorRayman
- *@authorJanSorensen
- *@authorScottSanders
- *@version$Revision:644137$$Date:2008-04-0303:30:23+0100(Thu,03Apr2008)$
- *@seePropertyUtilsBean
- *@seeorg.apache.commons.beanutils.expression.Resolver
- */
- publicclass
- {
- //-----------------------------------------------------ManifestConstants
- /**
- *Thedelimiterthatpreceedsthezero-relativesubscriptforan
- *indexedreference.
- *
- *@deprecatedThenotationusedforpropertynameexpressionsisnow
- *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
- *implementationbeingused.
- */
- publicstaticfinalcharINDEXED_DELIM='[';
- /**
- *Thedelimiterthatfollowsthezero-relativesubscriptforan
- *indexedreference.
- *
- *@deprecatedThenotationusedforpropertynameexpressionsisnow
- *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
- *implementationbeingused.
- */
- publicstaticfinalcharINDEXED_DELIM2=']';
- /**
- *Thedelimiterthatpreceedsthekeyofamappedproperty.
- *
- *@deprecatedThenotationusedforpropertynameexpressionsisnow
- *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
- *implementationbeingused.
- */
- publicstaticfinalcharMAPPED_DELIM='(';
- /**
- *Thedelimiterthatfollowsthekeyofamappedproperty.
- *
- *@deprecatedThenotationusedforpropertynameexpressionsisnow
- *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
- *implementationbeingused.
- */
- publicstaticfinalcharMAPPED_DELIM2=')';
- /**
- *Thedelimiterthatseparatesthecomponentsofanestedreference.
- *
- *@deprecatedThenotationusedforpropertynameexpressionsisnow
- *dependantonthe{@linkorg.apache.commons.beanutils.expression.Resolver}
- *implementationbeingused.
- */
- publicstaticfinalcharNESTED_DELIM='.';
- //-------------------------------------------------------StaticVariables
- /**
- *Thedebuggingdetaillevelforthiscomponent.
- *
- *Notethatthisstaticvariablewillhaveunexpectedside-effectsif
- *thisclassisdeployedinasharedclassloaderwithinacontainer.
- *Howeverasitisactuallycompletelyignoredbythisclassduetoits
- *deprecatedstatus,itdoesn'tdoanyactualharm.
- *
- *@deprecatedThe<code>debug</code>staticpropertyisnolongerused
- */
- privatestaticintdebug=0;
- /**
- *The<code>debug</code>staticpropertyisnolongerused
- *@returndebugproperty
- *@deprecatedThe<code>debug</code>staticpropertyisnolongerused
- */
- publicstaticintgetDebug(){
- return(debug);
- }
- /**
- *The<code>debug</code>staticpropertyisnolongerused
- *@paramnewDebugdebugproperty
- *@deprecatedThe<code>debug</code>staticpropertyisnolongerused
- */
- publicstaticvoidsetDebug(intnewDebug){
- debug=newDebug;
- }
- //---------------------------------------------------------PublicMethods
- /**
- *Clearanycachedpropertydescriptorsinformationforallclasses
- *loadedbyanyclassloaders.Thisisusefulincaseswhereclass
- *loadersarethrownawaytoimplementclassreloading.
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@seePropertyUtilsBean#clearDescriptors
- */
- publicstaticvoidclearDescriptors(){
- PropertyUtilsBean.getInstance().clearDescriptors();
- }
- /**
- *<p>Copypropertyvaluesfromthe"origin"beantothe"destination"bean
- *forallcaseswherethepropertynamesarethesame(eventhoughthe
- *actualgetterandsettermethodsmighthavebeencustomizedvia
- *<code>BeanInfo</code>classes).</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@paramdestDestinationbeanwhosepropertiesaremodified
- *@paramorigOriginbeanwhosepropertiesareretrieved
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionifthe<code>dest</code>or
- *<code>orig</code>argumentisnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#copyProperties
- */
- publicstaticvoidcopyProperties(Objectdest,Objectorig)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- PropertyUtilsBean.getInstance().copyProperties(dest,orig);
- }
- /**
- *<p>Returntheentiresetofpropertiesforwhichthespecifiedbean
- *providesareadmethod.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertiesaretobeextracted
- *@returnThesetofpropertiesforthebean
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>isnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#describe
- */
- publicstaticMapdescribe(Objectbean)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- return(PropertyUtilsBean.getInstance().describe(bean));
- }
- /**
- *<p>Returnthevalueofthespecifiedindexedpropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramname<code>propertyname[index]</code>ofthepropertyvalue
- *tobeextracted
- *@returntheindexedpropertyvalue
- *
- *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
- *isoutsidethevalidrangefortheunderlyingproperty
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getIndexedProperty(Object,String)
- */
- publicstaticObjectgetIndexedProperty(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- return(PropertyUtilsBean.getInstance().getIndexedProperty(bean,name));
- }
- /**
- *<p>Returnthevalueofthespecifiedindexedpropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramnameSimplepropertynameofthepropertyvaluetobeextracted
- *@paramindexIndexofthepropertyvaluetobeextracted
- *@returntheindexedpropertyvalue
- *
- *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
- *isoutsidethevalidrangefortheunderlyingproperty
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getIndexedProperty(Object,String,int)
- */
- publicstaticObjectgetIndexedProperty(Objectbean,
- Stringname,intindex)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- return(PropertyUtilsBean.getInstance().getIndexedProperty(bean,name,index));
- }
- /**
- *<p>Returnthevalueofthespecifiedmappedpropertyofthe
- *specifiedbean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramname<code>propertyname(key)</code>ofthepropertyvalue
- *tobeextracted
- *@returnthemappedpropertyvalue
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getMappedProperty(Object,String)
- */
- publicstaticObjectgetMappedProperty(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- return(PropertyUtilsBean.getInstance().getMappedProperty(bean,name));
- }
- /**
- *<p>Returnthevalueofthespecifiedmappedpropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramnameMappedpropertynameofthepropertyvaluetobeextracted
- *@paramkeyKeyofthepropertyvaluetobeextracted
- *@returnthemappedpropertyvalue
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getMappedProperty(Object,String,String)
- */
- publicstaticObjectgetMappedProperty(Objectbean,
- Stringname,Stringkey)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- returnPropertyUtilsBean.getInstance().getMappedProperty(bean,name,key);
- }
- /**
- *<p>Returnthemappedpropertydescriptorsforthisbeanclass.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanClassBeanclasstobeintrospected
- *@returnthemappedpropertydescriptors
- *@seePropertyUtilsBean#getMappedPropertyDescriptors(Class)
- *@deprecatedThismethodshouldnotbeexposed
- */
- publicstaticFastHashMapgetMappedPropertyDescriptors(ClassbeanClass){
- returnPropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass);
- }
- /**
- *<p>Returnthemappedpropertydescriptorsforthisbean.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeantobeintrospected
- *@returnthemappedpropertydescriptors
- *@seePropertyUtilsBean#getMappedPropertyDescriptors(Object)
- *@deprecatedThismethodshouldnotbeexposed
- */
- publicstaticFastHashMapgetMappedPropertyDescriptors(Objectbean){
- returnPropertyUtilsBean.getInstance().getMappedPropertyDescriptors(bean);
- }
- /**
- *<p>Returnthevalueofthe(possiblynested)propertyofthespecified
- *name,forthespecifiedbean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramnamePossiblynestednameofthepropertytobeextracted
- *@returnthenestedpropertyvalue
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionNestedNullExceptionifanestedreferencetoa
- *propertyreturnsnull
- *@exceptionInvocationTargetException
- *ifthepropertyaccessormethodthrowsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getNestedProperty
- */
- publicstaticObjectgetNestedProperty(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- returnPropertyUtilsBean.getInstance().getNestedProperty(bean,name);
- }
- /**
- *<p>Returnthevalueofthespecifiedpropertyofthespecifiedbean,
- *nomatterwhichpropertyreferenceformatisused,withno
- *typeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramnamePossiblyindexedand/ornestednameoftheproperty
- *tobeextracted
- *@returnthepropertyvalue
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getProperty
- */
- publicstaticObjectgetProperty(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- return(PropertyUtilsBean.getInstance().getProperty(bean,name));
- }
- /**
- *<p>Retrievethepropertydescriptorforthespecifiedpropertyofthe
- *specifiedbean,orreturn<code>null</code>ifthereisnosuch
- *descriptor.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanforwhichapropertydescriptorisrequested
- *@paramnamePossiblyindexedand/ornestednameofthepropertyfor
- *whichapropertydescriptorisrequested
- *@returnthepropertydescriptor
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionIllegalArgumentExceptionifanestedreferencetoa
- *propertyreturnsnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getPropertyDescriptor
- */
- publicstaticPropertyDescriptorgetPropertyDescriptor(Objectbean,
- Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- returnPropertyUtilsBean.getInstance().getPropertyDescriptor(bean,name);
- }
- /**
- *<p>Retrievethepropertydescriptorsforthespecifiedclass,
- *introspectingandcachingthemthefirsttimeaparticularbeanclass
- *isencountered.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanClassBeanclassforwhichpropertydescriptorsarerequested
- *@returnthepropertydescriptors
- *@exceptionIllegalArgumentExceptionif<code>beanClass</code>isnull
- *@seePropertyUtilsBean#getPropertyDescriptors(Class)
- */
- publicstaticPropertyDescriptor[]
- getPropertyDescriptors(ClassbeanClass){
- returnPropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass);
- }
- /**
- *<p>Retrievethepropertydescriptorsforthespecifiedbean,
- *introspectingandcachingthemthefirsttimeaparticularbeanclass
- *isencountered.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanforwhichpropertydescriptorsarerequested
- *@returnthepropertydescriptors
- *@exceptionIllegalArgumentExceptionif<code>bean</code>isnull
- *@seePropertyUtilsBean#getPropertyDescriptors(Object)
- */
- publicstaticPropertyDescriptor[]getPropertyDescriptors(Objectbean){
- returnPropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
- }
- /**
- *<p>ReturntheJavaClassrepesentingthepropertyeditorclassthathas
- *beenregisteredforthisproperty(ifany).</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanforwhichapropertydescriptorisrequested
- *@paramnamePossiblyindexedand/ornestednameofthepropertyfor
- *whichapropertydescriptorisrequested
- *@returnthepropertyeditorclass
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionIllegalArgumentExceptionifanestedreferencetoa
- *propertyreturnsnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getPropertyEditorClass(Object,String)
- */
- publicstaticClassgetPropertyEditorClass(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- returnPropertyUtilsBean.getInstance().getPropertyEditorClass(bean,name);
- }
- /**
- *<p>ReturntheJavaClassrepresentingthepropertytypeofthespecified
- *property,or<code>null</code>ifthereisnosuchpropertyforthe
- *specifiedbean.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanforwhichapropertydescriptorisrequested
- *@paramnamePossiblyindexedand/ornestednameofthepropertyfor
- *whichapropertydescriptorisrequested
- *@returnThepropertytype
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionIllegalArgumentExceptionifanestedreferencetoa
- *propertyreturnsnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getPropertyType(Object,String)
- */
- publicstaticClassgetPropertyType(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- returnPropertyUtilsBean.getInstance().getPropertyType(bean,name);
- }
- /**
- *<p>Returnanaccessiblepropertygettermethodforthisproperty,
- *ifthereisone;otherwisereturn<code>null</code>.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@paramdescriptorPropertydescriptortoreturnagetterfor
- *@returnThereadmethod
- *@seePropertyUtilsBean#getReadMethod(PropertyDescriptor)
- */
- publicstaticMethodgetReadMethod(PropertyDescriptordescriptor){
- return(PropertyUtilsBean.getInstance().getReadMethod(descriptor));
- }
- /**
- *<p>Returnthevalueofthespecifiedsimplepropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeextracted
- *@paramnameNameofthepropertytobeextracted
- *@returnThepropertyvalue
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionIllegalArgumentExceptionifthepropertyname
- *isnestedorindexed
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#getSimpleProperty
- */
- publicstaticObjectgetSimpleProperty(Objectbean,Stringname)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- returnPropertyUtilsBean.getInstance().getSimpleProperty(bean,name);
- }
- /**
- *<p>Returnanaccessiblepropertysettermethodforthisproperty,
- *ifthereisone;otherwisereturn<code>null</code>.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@paramdescriptorPropertydescriptortoreturnasetterfor
- *@returnThewritemethod
- *@seePropertyUtilsBean#getWriteMethod(PropertyDescriptor)
- */
- publicstaticMethodgetWriteMethod(PropertyDescriptordescriptor){
- returnPropertyUtilsBean.getInstance().getWriteMethod(descriptor);
- }
- /**
- *<p>Return<code>true</code>ifthespecifiedpropertynameidentifies
- *areadablepropertyonthespecifiedbean;otherwise,return
- *<code>false</code>.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeantobeexamined(maybea{@linkDynaBean}
- *@paramnamePropertynametobeevaluated
- *@return<code>true</code>ifthepropertyisreadable,
- *otherwise<code>false</code>
- *
- *@exceptionIllegalArgumentExceptionif<code>bean</code>
- *or<code>name</code>is<code>null</code>
- *@seePropertyUtilsBean#isReadable
- *@sinceBeanUtils1.6
- */
- publicstaticbooleanisReadable(Objectbean,Stringname){
- returnPropertyUtilsBean.getInstance().isReadable(bean,name);
- }
- /**
- *<p>Return<code>true</code>ifthespecifiedpropertynameidentifies
- *awriteablepropertyonthespecifiedbean;otherwise,return
- *<code>false</code>.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeantobeexamined(maybea{@linkDynaBean}
- *@paramnamePropertynametobeevaluated
- *@return<code>true</code>ifthepropertyiswriteable,
- *otherwise<code>false</code>
- *
- *@exceptionIllegalArgumentExceptionif<code>bean</code>
- *or<code>name</code>is<code>null</code>
- *@seePropertyUtilsBean#isWriteable
- *@sinceBeanUtils1.6
- */
- publicstaticbooleanisWriteable(Objectbean,Stringname){
- returnPropertyUtilsBean.getInstance().isWriteable(bean,name);
- }
- /**
- *<p>Setsthevalueofthespecifiedindexedpropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobemodified
- *@paramname<code>propertyname[index]</code>ofthepropertyvalue
- *tobemodified
- *@paramvalueValuetowhichthespecifiedpropertyelement
- *shouldbeset
- *
- *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
- *isoutsidethevalidrangefortheunderlyingproperty
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#setIndexedProperty(Object,String,Object)
- */
- publicstaticvoidsetIndexedProperty(Objectbean,Stringname,
- Objectvalue)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- PropertyUtilsBean.getInstance().setIndexedProperty(bean,name,value);
- }
- /**
- *<p>Setsthevalueofthespecifiedindexedpropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeset
- *@paramnameSimplepropertynameofthepropertyvaluetobeset
- *@paramindexIndexofthepropertyvaluetobeset
- *@paramvalueValuetowhichtheindexedpropertyelementistobeset
- *
- *@exceptionIndexOutOfBoundsExceptionifthespecifiedindex
- *isoutsidethevalidrangefortheunderlyingproperty
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionIllegalArgumentExceptionif<code>bean</code>or
- *<code>name</code>isnull
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#setIndexedProperty(Object,String,Object)
- */
- publicstaticvoidsetIndexedProperty(Objectbean,Stringname,
- intindex,Objectvalue)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- PropertyUtilsBean.getInstance().setIndexedProperty(bean,name,index,value);
- }
- /**
- *<p>Setsthevalueofthespecifiedmappedpropertyofthe
- *specifiedbean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeset
- *@paramname<code>propertyname(key)</code>ofthepropertyvalue
- *tobeset
- *@paramvalueThepropertyvaluetobeset
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#setMappedProperty(Object,String,Object)
- */
- publicstaticvoidsetMappedProperty(Objectbean,Stringname,
- Objectvalue)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- PropertyUtilsBean.getInstance().setMappedProperty(bean,name,value);
- }
- /**
- *<p>Setsthevalueofthespecifiedmappedpropertyofthespecified
- *bean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobeset
- *@paramnameMappedpropertynameofthepropertyvaluetobeset
- *@paramkeyKeyofthepropertyvaluetobeset
- *@paramvalueThepropertyvaluetobeset
- *
- *@exceptionIllegalAccessExceptionifthecallerdoesnothave
- *accesstothepropertyaccessormethod
- *@exceptionInvocationTargetExceptionifthepropertyaccessormethod
- *throwsanexception
- *@exceptionNoSuchMethodExceptionifanaccessormethodforthis
- *propetycannotbefound
- *@seePropertyUtilsBean#setMappedProperty(Object,String,String,Object)
- */
- publicstaticvoidsetMappedProperty(Objectbean,Stringname,
- Stringkey,Objectvalue)
- throwsIllegalAccessException,InvocationTargetException,
- NoSuchMethodException{
- PropertyUtilsBean.getInstance().setMappedProperty(bean,name,key,value);
- }
- /**
- *<p>Setsthevalueofthe(possiblynested)propertyofthespecified
- *name,forthespecifiedbean,withnotypeconversions.</p>
- *
- *<p>Formoredetailssee<code>PropertyUtilsBean</code>.</p>
- *
- *@parambeanBeanwhosepropertyistobemodified
- *@paramnamePossiblynestednameofthepropertytobemodified
- *@paramvalueValuetowhichthepropertyistobeset <li cl
相关推荐
单例模式是软件设计模式中的一种,用于控制类的实例化过程,确保一个类只有一个实例,并提供一个全局访问点。这种模式在系统中需要频繁创建和销毁的对象,或者需要共享资源的情况下非常有用。然而,实现单例模式时,...
- 饿汉式(静态常量):类加载时创建单例对象。 - 枚举实现:简单高效,天然支持序列化机制。 通过上述介绍可以看出,`static`关键字和单例模式是Java编程中非常重要的两个概念。正确理解和使用它们能够帮助...
在单例模式中,类的构造函数是私有的,防止外部直接创建对象,而是通过静态方法获取该类的唯一实例。单例模式的唯一性通常是在进程范围内,即在同一个进程中,无论何时调用单例类的获取实例方法,都会返回相同的对象...
总结来说,QT静态单例管理信号和槽是通过限制类实例化次数,提供全局访问点,以确保在整个应用程序中对特定资源的统一管理和通信。这种方式既保证了资源的唯一性,又简化了代码的结构,是Qt开发中常用的一种设计策略...
在Python编程中,类方法和静态方法是面向对象编程的重要组成部分。它们提供了不同的方式来实现代码的封装和复用。类方法至少需要一个类作为第一个参数,通常用于访问和修改类属性。静态方法则不需要任何隐式或显式的...
// 通过静态内部类访问单例对象 } } ``` **解析**: - **静态内部类**:这种方式利用了 Java 类加载机制来确保单例模式的实现,只有当首次调用 `getInstance()` 方法时才会加载静态内部类并初始化单例对象。 - **...
这是因为单例对象通常通过静态成员变量持有引用,而静态成员变量作为方法区的一部分,不会因普通对象的回收而被清除。具体来说,根据根搜索算法,只要静态变量还持有对单例对象的引用,那么该对象就仍然被认为是可达...
// 静态工厂方法,提供外部获取单例对象的唯一入口 public static Singleton1 getInstance() { return single; } } ``` **特点**: - **安全性高**:由于在类加载时就已完成实例化,因此不需要担心多线程环境下...
在一个静态方法中,除了局部变量外,能够访问的外部变量也必须是静态的,能够访问的外部方法也必须是静态的,实例变量和实例方法均不能访问。 静态方法通常是 public 的,作为工具类的工具方法出现。 例如: ```...
单例对象的创建可以在静态初始化块中完成,或者在getInstance方法中通过DCL模式实现。 在项目中,`src`目录可能包含了这些设计模式的源码示例,可以用来学习和理解如何实际应用单例模式和工厂模式。通过阅读和分析...
在Java编程语言中,单例模式是一种常用的软件设计模式,它的主要目的是确保一个类只有一个实例,并提供一个全局访问点。这种模式在系统中需要频繁创建和销毁对象时,或者对象的创建过程比较昂贵时,特别有用。单例...
而当尝试在静态方法 `tell()` 中访问非静态属性 `$height` 时,会抛出错误,因为静态方法没有实例上下文,无法确定 `$this` 对应哪个实例。 总结一下 PHP 中 `static` 的关键点: 1. 静态属性可以在类的任何实例...
4. **提供获取实例的方法**:通常会提供一个静态方法或类方法来获取单例对象,这个方法会检查是否已经存在实例,如果不存在则创建一个新的实例并返回;如果已经存在,则直接返回已存在的实例。 5. **懒加载**:即在...
具体来说它将单例对象的创建延迟到静态内部类被加载时才执行,从而避免了多线程环境下的同步问题。下面是一个简单的示例代码: ```java public class SingletonDemo { private static Map, String> idCodeMap = ...
3. 防止克隆:为了避免通过`clone`关键字复制单例对象,我们还需要封锁`__clone()`魔术方法。 ```php class Singleton { // ... private function __clone() {} } ``` 4. 防止序列化和反序列化:如果允许对象被...
在C#中,我们可以利用单例模式来创建一个计数器类,以确保在整个应用程序的生命周期内,计数器只存在一个实例,并且能够被多个对象安全地共享和访问。 首先,我们需要理解单例模式的基本原理。单例模式的关键在于...
场景管理单例模式1 单例模式(Singleton Pattern)是一种常用的设计...在 Unity3D 中,单例模式可以用来管理场景,提供了一个全局访问点来访问单例对象。这种模式可以提高性能,简化代码,并且可以确保只有一个实例。
总结来说,"静态"关键字在编程中提供了许多有用的特性,如简化代码、优化资源使用以及实现特定设计模式。理解并恰当运用静态方法、变量和类,是编写高效、可维护的代码的关键。然而,过度使用静态元素可能会导致代码...
3. **全局访问点**:类提供一个全局的访问点,使得任何需要使用该类实例的地方,都可以通过这个公共的静态方法获取到唯一实例。 在Java中,常见的单例实现方式有两种:饿汉式(Eager Initialization)和懒汉式...