wood burning stoves 2.0*
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
Author

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:
propClass=long
writeMethod=null

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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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
 
Similar Threads
problem base64 encoding the 3 hex bytes E2 80 A9
Writing from a Text file to BLOB
Composite Id --- Error in Reading the mapping file
Need Help Reading/Writing an Image using Spring MVC
Mapping a Blob to a byte[] in hibernate 3