Class SuppressPropertiesBeanIntrospector

  • All Implemented Interfaces:
    BeanIntrospector

    public class SuppressPropertiesBeanIntrospector
    extends java.lang.Object
    implements BeanIntrospector

    A specialized BeanIntrospector implementation which suppresses some properties.

    An instance of this class is passed a set with the names of the properties it should process. During introspection of a bean class it removes all these properties from the IntrospectionContext. So effectively, properties added by a different BeanIntrospector are removed again.

    Since:
    1.9.2
    Version:
    $Id: SuppressPropertiesBeanIntrospector.java 1597448 2014-05-25 17:12:16Z oheger $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Set<java.lang.String> propertyNames
      A set with the names of the properties to be suppressed.
      static SuppressPropertiesBeanIntrospector SUPPRESS_CLASS
      A specialized instance which is configured to suppress the special class properties of Java beans.
    • Constructor Summary

      Constructors 
      Constructor Description
      SuppressPropertiesBeanIntrospector​(java.util.Collection<java.lang.String> propertiesToSuppress)
      Creates a new instance of SuppressPropertiesBeanIntrospector and sets the names of the properties to be suppressed.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<java.lang.String> getSuppressedProperties()
      Returns a (unmodifiable) set with the names of the properties which are suppressed by this BeanIntrospector.
      void introspect​(IntrospectionContext icontext)
      Performs introspection on a Java class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SUPPRESS_CLASS

        public static final SuppressPropertiesBeanIntrospector SUPPRESS_CLASS
        A specialized instance which is configured to suppress the special class properties of Java beans. Unintended access to the property class (which is common to all Java objects) can be a security risk because it also allows access to the class loader. Adding this instance as BeanIntrospector to an instance of PropertyUtilsBean suppresses the class property; it can then no longer be accessed.
      • propertyNames

        private final java.util.Set<java.lang.String> propertyNames
        A set with the names of the properties to be suppressed.
    • Constructor Detail

      • SuppressPropertiesBeanIntrospector

        public SuppressPropertiesBeanIntrospector​(java.util.Collection<java.lang.String> propertiesToSuppress)
        Creates a new instance of SuppressPropertiesBeanIntrospector and sets the names of the properties to be suppressed.
        Parameters:
        propertiesToSuppress - the names of the properties to be suppressed (must not be null)
        Throws:
        java.lang.IllegalArgumentException - if the collection with property names is null
    • Method Detail

      • getSuppressedProperties

        public java.util.Set<java.lang.String> getSuppressedProperties()
        Returns a (unmodifiable) set with the names of the properties which are suppressed by this BeanIntrospector.
        Returns:
        a set with the names of the suppressed properties
      • introspect

        public void introspect​(IntrospectionContext icontext)
                        throws java.beans.IntrospectionException
        Performs introspection on a Java class. The current class to be inspected can be queried from the passed in IntrospectionContext object. A typical implementation has to obtain this class, determine its properties according to the rules it implements, and add them to the passed in context object. This implementation removes all properties from the given context it is configured for.
        Specified by:
        introspect in interface BeanIntrospector
        Parameters:
        icontext - the context object for interaction with the initiator of the introspection request
        Throws:
        java.beans.IntrospectionException - if an error occurs during introspection