• Post Reply Bookmark Topic Watch Topic
  • New Topic

Covert all bean String properties to uppercase  RSS feed

 
aditee sharma
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is it possible to covert all String properties in a bean to uppercase ?
I mean something like BeanUtilsBean from apache.
Just feed the Bean to some method and you get all the properties converted to uppercase, without having to do it manually.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use reflection. Look for all methods that start with "get", return a String and have a matching method that starts with "set".

Class.getField(s) will be the first step.
 
Ramon Garcia
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've made this
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

you should always use code tags; since you are new I added them and broke the long lines. I am always suspicious of anything with instanceof in. It suggests taking the details of a class outside itself. Could you use prop.toString().toUpperCase()?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!