Class ClassDescData


  • public class ClassDescData
    extends Object

    A simple data class for managing the components needed for a class description.

    A couple of tags of the di builder need to create ClassDescription objects. This class encapsulates the functionality required for this purpose. It defines properties for the supported components and provides validation methods.

    Version:
    $Id: ClassDescData.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • ClassDescData

        public ClassDescData()
    • Method Detail

      • getTargetClass

        public Class<?> getTargetClass()
        Returns the target class for the class description.
        Returns:
        the target class
      • setTargetClass

        public void setTargetClass​(Class<?> targetClass)
        Sets the target class of the class description.
        Parameters:
        targetClass - the target class
      • getTargetClassName

        public String getTargetClassName()
        Returns the name of the target class for the class description.
        Returns:
        the name of the target class
      • setTargetClassName

        public void setTargetClassName​(String targetClassName)
        Sets the name of the target class for the class description.
        Parameters:
        targetClassName - the name of the target class
      • getClassLoaderName

        public String getClassLoaderName()
        Returns the name of the class loader to be used.
        Returns:
        the name of the class loader
      • setClassLoaderName

        public void setClassLoaderName​(String classLoaderName)
        Sets the name of the class loader to be used.
        Parameters:
        classLoaderName - the name of the class loader to be used
      • isDefined

        public boolean isDefined()
        Checks whether all required data for constructing a class description is available.
        Returns:
        a flag whether enough information for constructing a class description is available
      • isValid

        public boolean isValid()
        Checks whether the properties of this object are valid. This implementation checks whether either a target class or a class name is set. If both are set, they must specify the same class. This implementation expects that the properties are defined, i.e. isDefined() has returned true.
        Returns:
        a flag whether the properties are valid
      • createClassDescription

        public ClassDescription createClassDescription()
                                                throws org.apache.commons.jelly.JellyTagException
        Creates a ClassDescription object from the internal data. If not all required properties are set or if they contain invalid values, an exception will be thrown.
        Returns:
        a ClassDescription object corresponding to the values of the properties
        Throws:
        org.apache.commons.jelly.JellyTagException - if not all required properties are set or some properties are invalid
      • getOptionalClassDescription

        public ClassDescription getOptionalClassDescription()
                                                     throws org.apache.commons.jelly.JellyTagException
        Returns a ClassDescription object from the internal data or null if no data is defined. This is a convenience method. If data of a class is defined, isValid() is called for checking the validity of the entered data. If this fails, an exception is thrown. If the class is undefined, simply null is returned. This functionality is frequently needed when a class definition is optional: if one is provided, it must be valid; otherwise null can be returned.
        Returns:
        a ClassDescription object corresponding to the values of the properties or null if no class is defined
        Throws:
        org.apache.commons.jelly.JellyTagException - if the class definition is not valid
      • resolveClass

        public Class<?> resolveClass​(ClassLoaderProvider clProvider)
                              throws org.apache.commons.jelly.JellyTagException
        A convenience method for resolving the class specified by this data object. This method creates the corresponding ClassDescription and obtains the target class for it. No caching is performed, so this method should only be used if resolving happens once.
        Parameters:
        clProvider - the ClassLoaderProvider to be used for class loading
        Returns:
        the class specified by this description object
        Throws:
        org.apache.commons.jelly.JellyTagException - if an error occurs during resolving
        See Also:
        createClassDescription(), ClassDescription.getTargetClass(ClassLoaderProvider)