最近更新   设为主页   初用apache.commons.beanutils.BeanUtils 加入收藏  
计算机基础教程网 本站招聘  
 [投稿登 陆]    [问题求解或论坛登 陆]
ITWEN首页操作系统网络冲浪办公软件网页设计图形图象认证考试程序设计数据库其它文章交流论坛  
  当前位置:ITWen >>  Java语言  >>  初用apache.commons.beanutils.BeanUtils
初用apache.commons.beanutils.BeanUtils
作者:ItWen收集整理    来源:www.itwen.com    更新时间:2006-10-27
[ 收藏此页到: 天天 | 和讯 | 博采 | ViVi | 狐摘 | 我摘 ]  
  

引言
该class提供了一系列的静态方法操作业已存在的符合JavaBean规范定义的Java Class.这里强调的JavaBean规范,简单来说就是一个Java Class通过一系列getter和setter的方法向外界展示其内在的成员变量(属性).通过BeanUtils的静态方法,我们可以:复制一个JavaBean的实例--BeanUtils.cloneBean();在一个JavaBean的两个实例之间复制属性--BeanUtils.copyProperties(),BeanUtils.copyProperty();为一个JavaBean的实例设置成员变量(属性)值--BeanUtils.populate(),BeanUtils.setProperty();从一个一个JavaBean的实例中读取成员变量(属性)的值--BeanUtils.getArrayProperty(),BeanUtils.getIndexedProperty(),BeanUtils.getMappedProperty(),BeanUtils.getNestedProperty(),BeanUtils.getSimpleProperty(),BeanUtils.getProperty(),BeanUtils.describe();
总的来看BeanUtils类提供了两大类的功能:读,写成员变量.准备工作
下面逐一分析使用方法.首先我们建立两个JavaBean,名位SampleObject和SampleObjectA,具体如下:
package beanutil;
import java.util.HashMap;import java.util.Map;
/** * @author samepoint * * SampleObject contains some types of member varaibles:String,int,Array,Map,Object(self defined),just for test usaged of apache.commons.beanutils.BeanUtils */public class SampleObject { String name = null; String display = null; int num = -1; char[] words = {'a','b','c','d'}; boolean tag = false; Map map = new HashMap(); SampleObjectA sample = null;

/** * default constructor. initialized members of map and sample. */ public SampleObject() { this.map.put("home","localhost"); this.map.put("port","80"); }
//the following is getters and setters /** * @return Returns the display. */ public String getDisplay() { return display; } /** * @param display The display to set. */ public void setDisplay(String display) { this.display = display; } /** * @return Returns the name. */ public String getName() { return name; } /** * @param name The name to set. */ public void setName(String name) { this.name = name; } /** * @return Returns the num. */ public int getNum() { return num; } /** * @param num The num to set. */ public void setNum(int num) { this.num = num; } /** * @return Returns the words. */ public char[] getWords() { return words; } /** * @param words The words to set. */ public void setWords(char[] words) { this.words = words; } /** * @return Returns the tag. */ public boolean isTag() { return tag; } /** * @param tag The tag to set. */ public void setTag(boolean tag) { this.tag = tag; } /** * @return Returns the map. */ public Map getMap() { return map; } /** * @param map The map to set. */ public void setMap(Map map) { this.map = map; } /** * @return Returns the sample. */ public SampleObject getSample() { return sample; } /** * @param sample The sample to set. */ public void setSample(SampleObject sample) { this.sample = sample; }}package beanutil;


   本篇文章共5页,此页为首页   下一页


  引用提示:
  内容页面:初用apache.commons.beanutils.BeanUtils --- Java语言
  作者:ItWen收集整理
  来源:www.ITWEN.com 计算机基础教程网
  

  版权申明:
  本网站所有内容,未经注明的,版权一律属于计算机基础教程网(ITWEN.com)制作署所有。转载引用本网站的原创文章,请务必注明信息来源,标明“计算机基础教程网(ITWEN.com)”字样。
  计算机基础教程网(ITWEN.com)依法保护知识产权,如果我们的文章有涉及或侵犯您的有关权益,请即时与我们联系, 注明网址及文章,我们会即时处理或删除, 感谢您的合作!   


】 【返回站点首页】【打印本页】【关闭本页
     资料搜索
     热门文章
·照片纪录的中国2003---200
·Tomcat中文手册1_转
·Java和ASP的交互一
·记录下一些关于测试工具NUNIT的
·高级表单验证-针对多次提交表单
·CSS2参考之十一<完>
·ASPX保存远程图片到本地的两种方
·Javascript实例教程3探测
·用表格增强WPS2000的分栏功能
·中文Excel2000速成教程1.
·xp风格菜单
·使用新的用户权限选项来访问终端服务
·Windows系统恢复光盘DIY
·第三层交换解决方案分析
·MadeinBorlandBorC
     前面文章
·string.substring;
·Tomcat性能调整
·WAREZ LESSONS FOR
·光纤与六类谁离你的目标近
·.NET什么ListView居然没
·不用操作--让Office 200
·聊天截图 MSN也行
·远程访问之ISDN学习笔记2
·关于JAVA的分页查询操作技术
·PHP中的DOM XML函数
·漫谈 Coreldraw 中的“复
·手把手ImageReady切片教程
·CCNP课堂---Cisco设备图
·昨日关注伴随着Web标准发展
·httpd.conf中文说明
·Autoselectinterne
·学习JAVA的第一方案
·Java Servlet和JSP教
·细细品味ASP.NET 二
·经常看见有人问能不能实现这个效果下

文章: 初用apache.commons.beanutils.BeanUtils 已经被浏览了 次。
免责声明 | 关于我们 | 广告联系 | 友情链接 | 帮助设置 | 网站导航 | 最近更新 | 共同合作
计算机基础教程网(www.ITwen.com) 版权所有
copyright 2005-2006,All Rights Reserved
计算机基础教程网