javax.beans.binding.ext
Class PropertyDelegateProvider

java.lang.Object
  extended by javax.beans.binding.ext.PropertyDelegateProvider
Direct Known Subclasses:
SwingPropertyDelegateProvider

public abstract class PropertyDelegateProvider
extends java.lang.Object

PropertyDelegateProvider is responsible for providing a property delegate. A property delegate is an Object that supplies a named property for another class. For example, JList does not provide an "elements" property. The following illustrates a property delegate provider for JList's "elements" property:

   // The property delegate must be public, and it must expose the
   // property it was obtained from.
   public class JListProvider {
       public void setElements(List<?> elements) { ... }
       public List<?> getElements() { ... }
   }

   // The PropertyDelegateProvider must be public, and override the
   // necessary methods.
   public class MyPropertyDelegateProvider extends PropertyDelegateProvider {
       public Object getPropertyDelegate(Object source, String property) {
           return new JListProvider();
       }
       public Class getPropertyDelegate(Object source, String property) {
           return JListProvider.class;
       }
       public boolean providesDelegate(Class type, String property) {
           return (JList.class.isAssignableFrom(type) && 
                   "elements".equals(type));
       }
   };
 
The set of PropertyDelegateProviders are obtained using the ServiceLoader class, see it for details on how to register a provider.

See Also:
PropertyDelegateFactory

Field Summary
static java.lang.String PREFERRED_BINDING_PROPERTY
          Used to identify if a particular FeatureDescriptor is a preferred property for binding.
 
Constructor Summary
PropertyDelegateProvider()
           
 
Method Summary
abstract  java.lang.Object createPropertyDelegate(java.lang.Object source, java.lang.String property)
          Returns the property delegate for the specified object.
abstract  java.lang.Class<?> getPropertyDelegateClass(java.lang.Class<?> type)
          Returns the class the property delegate creates for the specified class.
abstract  boolean providesDelegate(java.lang.Class<?> type, java.lang.String property)
          Returns whether this PropertyDelegateProvider provides a delegate for the Class and property pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFERRED_BINDING_PROPERTY

public static final java.lang.String PREFERRED_BINDING_PROPERTY
Used to identify if a particular FeatureDescriptor is a preferred property for binding. If a FeatureDescriptor has a value for this (featureDescriptor.getValue(PREFERRED_BINDING_PROPERTY) is non-null), and the value is true, then the descriptor identifies a preferred binding property. A class may, and often times does, have more than one preferred binding property.

See Also:
Introspector, FeatureDescriptor, Constant Field Values
Constructor Detail

PropertyDelegateProvider

public PropertyDelegateProvider()
Method Detail

providesDelegate

public abstract boolean providesDelegate(java.lang.Class<?> type,
                                         java.lang.String property)
Returns whether this PropertyDelegateProvider provides a delegate for the Class and property pair.

Parameters:
type - the Class
property - the property

createPropertyDelegate

public abstract java.lang.Object createPropertyDelegate(java.lang.Object source,
                                                        java.lang.String property)
Returns the property delegate for the specified object. PropertyDelegateFactory only invokes this method once for a particular provider and object pair. For example, consider the following:
   PropertyDelegateProvider myProvider = createProvider();
   PropertyDelegateFactory.registerPropertyDelegateProvider(
       Foo.class, "foo", myProvider);
   PropertyDelegateFactory.registerPropertyDelegateProvider(
       Foo.class, "value", myProvider);
 
Then createPropertyDelegate is only invoked once for each unique instance of Foo.

Parameters:
source - the source to return the property delegate for
property - the property
Returns:
the property delegate, or null if the pair does not identify a legal property delegate
Throws:
java.lang.NullPointerException - if source or property are null

getPropertyDelegateClass

public abstract java.lang.Class<?> getPropertyDelegateClass(java.lang.Class<?> type)
Returns the class the property delegate creates for the specified class.

Parameters:
type - the class to obtain the delegate class for
Returns:
the class of the property delegate
Throws:
java.lang.NullPointerException - if type is null