Another dilemma we'll have to resolve is whether metadata will be
type-based, instance-based or both.
Here's what I am talking about:
Let's say we have this class:
class Address {
public Object getStreet(){ return new String[]{"555", "Sole Pike"}; }
public Comparable getCity() { return "Chipsburg"; }
}
Type-based introspection (like java.beans.Introspector) will tell us
that "street" is a property of type "Object" and "city" has type
"Comparable".
Instance-based introspection will give us "String[]" and "String"
respectively.
Question: is "street" a collection (indexed) property? From the type's
prospective it is not, from the instance prospective it is.
Let's say we are looking at a DynaBean. The class of this object is,
say, WrapDynaBean. What properties does it have? We don't know 'till
we ask the _instance_ getDynaClass() and then interrogate the
DynaClass.
This distinction becomes even more apparent when we are dealing with
Maps. For maps, the only way to find out the type of a property is to
actually get the property value and look at it.
IMO, we should have both kinds of APIs. Something like this:
abstract class MetaDataProvider {
// Override this to return type-based metadata
PropertyMetaData getPropertyMetaDataForType(Object type, String
propertyName){
return null;
}
// Override this to return instance-based metadata
PropertyMetaData getPropertyMetaData(Object instance, String
propertyName){
return getPropertyMetaDataForType(instance.getClass());
}
}
What do you think?
- Dmitri
__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>