File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Instrospection and properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Instrospection and properties" Watch "Instrospection and properties" New topic

Instrospection and properties

Rick DeBay
Ranch Hand

Joined: Jul 11, 2003
Posts: 70
I have a class:

public class Foo
long ndc;
long largerNdc;
public long getLargerNdc()
return largerNdc;
public void setLargerNdc(byte b)
if ( b > 99 || b < 0 )
throw new IllegalArgumentException("Larger NDC suffix must be from 0 through 99");
largerNdc = (getNdc_9() * 100) + b;
public long getNdc_9()
return ndc / 100;

When I get the property descriptors, I get null for the write method:

Granted the 'byte' type of the setter is probably confusing Instrospector.getBeanInfo(), but I can't find anything in the API saying this could be a problem.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

The return type of the getter and the argument type of the setter have to match; otherwise the getter is interpreted as a read-only property of its return type.

[Jess in Action][AskingGoodQuestions]
subject: Instrospection and properties