JavaBean 属性命名约定在哪里定义?
Spring Framework API 文档说:
根据 JavaBeans 属性命名规则,所使用的约定是返回类的非大写短名称:因此,com.myapp.Product 变为 Product; com.myapp.MyProduct 变为 myProduct; com.myapp.UKProduct 变为 UKProduct。
我在太阳队的网站上寻找定义,但没有找到。我想知道开头有多个大写字符的名称的规则。如果第二个字符也是大写,那么第一个字符也是大写的规则是吗?
背景是,我想根据对象的类型自动生成变量名称以在 HTML 模板中使用。示例: 类:SomeName -->对象:一些名称。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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
另外,直接链接到 (PDF) 规范 。
链接文档中的第 8.8 节标题为“推断名称的大写”,并简要概述了属性名称的派生方式。
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.
该功能的实现在此类中:
http://java.sun.com/javase/ 6/docs/api/java/beans/Introspector.html
the implementation of this functionality is in this class:
http://java.sun.com/javase/6/docs/api/java/beans/Introspector.html