Class DefaultIntrospectionContext

java.lang.Object
org.apache.commons.beanutils.DefaultIntrospectionContext
All Implemented Interfaces:
IntrospectionContext

class DefaultIntrospectionContext extends Object implements IntrospectionContext

An implementation of the IntrospectionContext interface used by PropertyUtilsBean when doing introspection of a bean class.

This class implements the methods required by the IntrospectionContext interface in a straight-forward manner based on a map. It is used internally only. It is not thread-safe.

Since:
1.9
Version:
$Id$
  • Field Details

    • EMPTY_DESCRIPTORS

      private static final PropertyDescriptor[] EMPTY_DESCRIPTORS
      Constant for an empty array of property descriptors.
    • currentClass

      private final Class<?> currentClass
      The current class for introspection.
    • descriptors

      private final Map<String,PropertyDescriptor> descriptors
      A map for storing the already added property descriptors.
  • Constructor Details

    • DefaultIntrospectionContext

      public DefaultIntrospectionContext(Class<?> cls)
      Creates a new instance of DefaultIntrospectionContext and sets the current class for introspection.
      Parameters:
      cls - the current class
  • Method Details

    • getTargetClass

      public Class<?> getTargetClass()
      Description copied from interface: IntrospectionContext
      Returns the class that is subject of introspection.
      Specified by:
      getTargetClass in interface IntrospectionContext
      Returns:
      the current class
    • addPropertyDescriptor

      public void addPropertyDescriptor(PropertyDescriptor desc)
      Description copied from interface: IntrospectionContext
      Adds the given property descriptor to this context. This method is called by a BeanIntrospector during introspection for each detected property. If this context already contains a descriptor for the affected property, it is overridden.
      Specified by:
      addPropertyDescriptor in interface IntrospectionContext
      Parameters:
      desc - the property descriptor
    • addPropertyDescriptors

      public void addPropertyDescriptors(PropertyDescriptor[] descs)
      Description copied from interface: IntrospectionContext
      Adds an array of property descriptors to this context. Using this method multiple descriptors can be added at once.
      Specified by:
      addPropertyDescriptors in interface IntrospectionContext
      Parameters:
      descs - the array of descriptors to be added
    • hasProperty

      public boolean hasProperty(String name)
      Description copied from interface: IntrospectionContext
      Tests whether a descriptor for the property with the given name is already contained in this context. This method can be used for instance to prevent that an already existing property descriptor is overridden.
      Specified by:
      hasProperty in interface IntrospectionContext
      Parameters:
      name - the name of the property in question
      Returns:
      true if a descriptor for this property has already been added, false otherwise
    • getPropertyDescriptor

      public PropertyDescriptor getPropertyDescriptor(String name)
      Description copied from interface: IntrospectionContext
      Returns the descriptor for the property with the given name or null if this property is unknown.
      Specified by:
      getPropertyDescriptor in interface IntrospectionContext
      Parameters:
      name - the name of the property in question
      Returns:
      the descriptor for this property or null if this property is unknown
    • removePropertyDescriptor

      public void removePropertyDescriptor(String name)
      Description copied from interface: IntrospectionContext
      Removes the descriptor for the property with the given name.
      Specified by:
      removePropertyDescriptor in interface IntrospectionContext
      Parameters:
      name - the name of the affected property
    • propertyNames

      public Set<String> propertyNames()
      Description copied from interface: IntrospectionContext
      Returns a set with the names of all properties known to this context.
      Specified by:
      propertyNames in interface IntrospectionContext
      Returns:
      a set with the known property names
    • getPropertyDescriptors

      public PropertyDescriptor[] getPropertyDescriptors()
      Returns an array with all descriptors added to this context. This method is used to obtain the results of introspection.
      Returns:
      an array with all known property descriptors