Use PropertyUtils.describe()
to generate a Map
containing all of the readable bean properties from a
bean instance. Supply an instance of a bean and this method will return a Map
containing all readable bean properties. The code shown
here demonstrates the use of PropertyUtils.describe(
)
to describe a Person
bean:
import java.util.*;
import org.apache.commons.beanutils.PropertyUtils;
// Create a Person and a Book bean instance
Person person = new Person( );
person.setName( "Some Dude" );
Book book = new Book( );
book.setName( "Some Silly Computer Book" );
book.setAuthor( person );
// Describe both beans with a Map
Map bookMap = PropertyUtils.describe( book );
Map authorMap = PropertyUtils.describe( bookMap.get("book") );
System.out.println( "Book Name: " + bookMap.get( "name" ) );
System.out.println( "Author Name: " + authorMap.get( "name" ) );
The previous example involves a Book
bean with a
name
and author
property;
the author
property is a Person
bean with one property: name
. The two maps, bookMap
and
authorMap
, contain keys for every defined bean
property, and two of those properties are printed out:
Book Name: Some Silly Computer Book
Author Name: Some Dude
The map returned from PropertyUtils.describe( )
is a HashMap
that contains every property from the bean to be
described. Internally, PropertyUtils.describe()
uses
PropertyUtils.getPropertyDescriptors( )
to obtain the
list of properties to put into this map.
相关推荐
"Creating a Culture of Execution"这一主题,通过引用美国总统约翰·F·肯尼迪(JFK)的演讲,揭示了领导力与执行力之间的紧密联系。肯尼迪在对国会的讲话中提出登月计划,这不仅是一个大胆的愿景,更是执行力的...
Learning SQL and creating a draftable set of cards for a variety of Magic the Gathering experiences
在处理Web服务相关的Java应用程序时,可能会遇到一个名为“prefix cannot be 'null' when creating a QName”的异常。这个错误通常出现在尝试创建`QName`对象但提供的前缀为`null`的情况下。 ### 错误详情与解决...
Creating a Website The Missing Manual(4th) 英文epub 第4版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
_Journal of the Society for Information Display_, 14(3), 293-302. 通过以上内容,我们可以看出,从2D场景分类生成深度图是一项具有重要意义的技术研究。它不仅为图像处理领域带来了新的可能性,也为未来的三维...
Creating a World Without Poverty: Social Business and the Future of Capitalism By Muhammad Yunus Publisher: PublicAffairs Number Of Pages: 296 Publication Date: 2008-01-07 ISBN-10 / ASIN: ...
Creating a Dropbox in Moodle with Option of Feedback Document
《The Art of Midjourney AI: A Guide to Creating Images from Text》是一本专注于利用文本生成图像的AI技术的指南,作者通过深入探索Midjourney AI的潜力,分享了他在人工智能生成视觉内容领域的发现和经验。...
### 《Slide:Ology:The Art and Science of Creating Great Presentations》——打造卓越演示的艺术与科学 #### 核心知识点概述 《Slide:Ology:The Art and Science of Creating Great Presentations》是一本...
Error creating bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Initialization of bean failed;...
Creating a list of items 131 Creating a standard menu 134 Creating a context menu 137 Selecting options with checkboxes and radio buttons 139 Manipulating tab order and focus 141 Chapter 5: ...
程序员的事业指导手册,教你如何打造属于你自己的事业人生
Title: Game Design Workshop: A Playcentric Approach to Creating Innovative Games, 3rd Edition Author: Tracy Fullerton Length: 535 pages Edition: 3 Language: English Publisher: A K Peters/CRC Press ...
Creating a Class Factory with C# and .NET.doc