Class ModelBuilder


  • public final class ModelBuilder
    extends java.lang.Object
    A model builder. This class performs the work of creating a class description model from a set of source files.
    • Field Detail

      • instance

        private static ModelBuilder instance
        The single instance.
      • handlerMapping

        private java.util.Properties handlerMapping
        The handler mapping.
    • Constructor Detail

      • ModelBuilder

        private ModelBuilder()
        Creates a single instance.
    • Method Detail

      • getInstance

        public static ModelBuilder getInstance()
        Returns the single instance of this class.
        Returns:
        the single instance of this class.
      • addAttributeHandlers

        public void addAttributeHandlers​(java.util.Properties p)
        Adds attribute handlers.
        Parameters:
        p - the handlers.
      • findElementTypes

        private java.lang.Class[] findElementTypes​(DescriptionModel model)
      • fillSuperClasses

        private void fillSuperClasses​(DescriptionModel model)
        Fills the super class for all object descriptions of the model. The super class is only filled, if the object's super class is contained in the model.
        Parameters:
        model - the model which should get its superclasses updated.
      • fillModel

        private java.lang.Class[] fillModel​(java.lang.Class[] classes,
                                            DescriptionModel model)
        Updates the model to contain the given classes.
        Parameters:
        classes - a list of classes which should be part of the model.
        model - the model which is updated
        Returns:
        A list of super classes which should also be contained in the model.
      • createClassDescription

        private ClassDescription createClassDescription​(java.beans.BeanInfo beanInfo,
                                                        ClassDescription parent)
        Creates a ClassDescription object for the specified bean info.
        Parameters:
        beanInfo - the bean info.
        parent - the parent class description.
        Returns:
        The class description.
      • isValidMethod

        public static boolean isValidMethod​(java.lang.reflect.Method method)
        Checks, whether the given method can be called from the generic object factory.
        Parameters:
        method - the method descriptor
        Returns:
        true, if the method is not null and public, false otherwise.
      • createSimplePropertyInfo

        public PropertyInfo createSimplePropertyInfo​(java.beans.PropertyDescriptor pd)
        Creates a PropertyInfo object from a PropertyDescriptor.
        Parameters:
        pd - the property descriptor.
        Returns:
        the property info (null possible).
      • isAttributeProperty

        private boolean isAttributeProperty​(java.lang.Class c)
        Checks, whether the given class can be handled as attribute. All primitive types can be attributes as well as all types which have a custom attribute handler defined.
        Parameters:
        c - the class which should be checked
        Returns:
        true, if the class can be handled as attribute, false otherwise.
      • getHandlerClass

        private java.lang.String getHandlerClass​(java.lang.Class c)
        Returns the class name for the attribute handler for a property of the specified class.
        Parameters:
        c - the class for which to search an attribute handler
        Returns:
        the handler class or null, if this class cannot be handled as attribute.
      • contains

        private boolean contains​(java.lang.Class[] cAll,
                                 java.lang.Class c)
        Checks, whether the class c is contained in the given class array.
        Parameters:
        cAll - the list of all classes
        c - the class to be searched
        Returns:
        true, if the class is contained in the array, false otherwise.