资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
获得javaBean的所有属性及类型一、程序功能定义a) 获得javabean所有属性及类型b) 仅仅是获得,赋值还没想到怎么弄。二、目的a) 参考方法b) 目前还不知道有什么用。c) 本来想给javaBean 一次性赋值的,但是貌似吧得用反射才行,而反射挺费资源的, 那只好暂时搁一搁了。三、程序代码四、代码中公用到两个类a) getBea ns.java 与 pers on Bea n.java getBea ns.javaimportjava.bea ns.Bea nlnfo;importjava.bea ns.ln trospect ion Exceptio n;importjava.bea ns.ln trospector;import java.bea ns.PropertyDescriptor;public classgetBea ns * param args*/public static void main( Stri ng args) /TODO Auto-ge nerated method stubpers on Bea n pb=new pers on Bea n();PropertyDescriptorpr= getPropertyDescriptors(pb.getClass();=+pri.getPropertyType()for ( int i=1;ipr.length;i+)System. out .println(pri.getName()+ );publicstaticPropertyDescriptorgetPropertyDescriptors(Classclazz) Bea nlnfo bea nlnfo =n ull ;try (clazz);bea nlnfo = In trospector.getBea nlnfo catch(In trospecti on Excepti on e) e.pri ntStackTrace();return bea nln fo.getPropertyDescriptors();pers on Bea n.javapublic classperson Bean int id =0;Stri ngn ame = pheygirint she ngao =180; booleanmale =true ;public int getld() return id ;public void setld( int id) this . id = id;public String getName() retur n n ame;public void setName(Stri ng n ame) this . name = name;public int getShe ngao() returnshengao ;public void setShe ngao( int she ngao) this . shengao = shengao;publicboolea nisMale() return male ;public void setMale( boolea n male) this . male = male;仅供参考,还不知道有没有用。When you are old and grey and full of sleep,And no ddi ng by the fire, take down this book,And slowly read, and dream of the soft lookYour eyes had once, and of their shadows deep;How many loved your mome nts of glad grace,And loved your beauty with love false or true,But one man loved the pilgrim soul in you,And loved the sorrows of your cha nging face;And bending dow n beside the glow ing bars,Murmur, a little sadly, how love fledAnd paced upon the mountains overheadAnd hid his face amid a crowd of stars.The furthest dista nee in the worldIs not betwee n life and deathBut whe n I sta nd in front of youYet you dont know thatI love you.The furthest dista nee in the worldIs not whe n I sta nd in front of youYet you cant see my loveBut whe n un doubtedly knowing the love from bothYet cannot be together.The furthest dista nee in the worldIs not being apart while being in loveBut whe n I pla inly cannot resist the year ningYet prete nding you have n ever bee n in my heart.The furthest dista nee in the worldIs not struggli ng aga inst the tidesBut using on es in differe nt heartTo dig an un crossable riverFor the one who loves you.
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号