I’m looking for the following feature describe below.
The MessageFormat of the sun api doesn’t fit my need & the Spring El expression too maybe.
Assuming that we have a person Object with a name:
Person person = new Person();
person.setName("fredop");
person.setAge("25");
String messageFormat="My name is {Person.name}, i'm {Person.age} years old""
System.out.println(Translate(person,messageFormat);
In the translate method, i will pass ONLY one object.
This final line will print:
"My name is fred, i'm 25 years old"
Any idea of an actual api doing that?
Groovy, that is a Java language extension toward a ruby/python like language, allows you to easily embed variables inside strings: