Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the JavaBean property naming convention defined?

The Spring Framework API doc says:

The convention used is to return the uncapitalized short name of the Class, according to JavaBeans property naming rules: So, com.myapp.Product becomes product; com.myapp.MyProduct becomes myProduct; com.myapp.UKProduct becomes UKProduct.

I looked at Suns website to find a definition, but didn't find one. I wonder about a rule for names with more than one upper case character at the beginning. Is the rule that the first character is upper case if the second character is upper case too?

The background is, that I want to generate variable names automatically for use in HTML templates depending on the type of the object. Example: class: SomeName --> object: someName.

like image 461
deamon Avatar asked Jan 02 '10 11:01

deamon


People also ask

What is needed to define a property of a JavaBean?

A JavaBean is a Java object that satisfies certain programming conventions: The JavaBean class must implement either Serializable or Externalizable. The JavaBean class must have a no-arg constructor. All JavaBean properties must have public setter and getter methods.

What is a JavaBean property?

A JavaBean property is a named attribute that can be accessed by the user of the object. The attribute can be of any Java data type, including the classes that you define. A JavaBean property may be read, write, read only, or write only.


1 Answers

http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-138795.html

Also, a direct link to the (PDF) specification.

Section 8.8 in the linked document is entitled "Capitalization of inferred names" and briefly outlines how names of properties are derived.

like image 108
Carl Smotricz Avatar answered Nov 15 '22 22:11

Carl Smotricz