I have a question about the JavaBeans Property Naming Rules used in B&K book.
This rule explain that: (pag 9)
"Getter method signatures must be marked public, take no arguments, and have a return type that matches the argument type of the setter method for that property."
But in the Java APIs, this JavaBeans property is not observed.
1)In the Java URL class (java.net package) a getter has this signature:
public final Object getContent(Class classes) //it takes an array argument
2)In the Integer class (java.lang package) three getters don't have standard signatures:
public static Integer getInteger(String nm)
public static Integer getInteger(String nm, int val)
public static Integer getInteger(String nm, Integer val)
and in other classes of other packages have this not standard JavaBeans behavior.
I will use this rule, but why in the Java API is not all the time respected?
Is it a issue/compatibility with the past?
URL and Integer are not JavaBean components - they are not conforming JavaBean rules.
JavaBean components are objects that can be visually manipulated in the IDE,
for example in a Swing form buillder in NetBeans you can drag and drop JavaBean components from a palette
and place them on a form (button, editbox, menu etc.), launch a property editor on placed component,
set some components' properties using the property editor etc. - without writing any line of code.
You can create your own JavaBean components and add them to the palette.
To create such component, you must create a java class that MUST conform JavaBean specification.
If it doesn't conform JavaBean rules - it is not JavaBean and it can't be used in this way.
Here you can find more information about JavaBeans:
http://en.wikipedia.org/wiki/JavaBean http://www.oracle.com/technetwork/java/javase/tech/index-jsp-138795.html http://wiki.netbeans.org/NetBeansJavaBeansTutorial