Class CreationTemplate

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class CreationTemplate
    extends Template
    Represents templates for creating objects in UMS. CreationTemplate is used to aid in creating objects in which it serves as reusable guidelines to instantiate UMS objects properly at runtime. The guidelines are used to instantiate objects in memory correctly so that subsequent storage in persistent storage can be done successfully. It is the intention that CreationTemplate allows applications to determine what is correct so that some control is given in the application for early detection of problems of UMS object creations. Reusability and flexibility are two desired goals of CreationTemplate.
    See Also:
    Template, SearchTemplate, Serialized Form
    • Constructor Detail

      • CreationTemplate

        public CreationTemplate()
        Default constructor for deserialization
      • CreationTemplate

        public CreationTemplate​(String name,
                                AttrSet required,
                                AttrSet optional,
                                ArrayList classes)
        Creates a template with required and optional attributes.
        Parameters:
        name - Template name
        required - Set of required attributes
        optional - Set of optional attributes
        classes - Array of classes that this CreationTemplate is associated with for object creation
      • CreationTemplate

        public CreationTemplate​(String name,
                                AttrSet required,
                                AttrSet optional,
                                Class cls)
        Creates a template with required and optional attributes.
        Parameters:
        name - Template name
        required - Set of required attributes
        optional - Set of optional attributes
        cls - Class that this CreationTemplate is associated with for object creation
      • CreationTemplate

        public CreationTemplate​(String name,
                                AttrSet required,
                                AttrSet optional)
        Creates a template with required and optional attributes.
        Parameters:
        name - Template name
        required - Set of required attributes
        optional - Set of optional attributes
    • Method Detail

      • getAttribute

        public Attr getAttribute​(String attributeName)
        Gets the value of a given attribute in the template.
        Parameters:
        attributeName - Name of attribute for which to return values
        Returns:
        The attribute with the specified name, or null if attributeName is null, or the attribute is not found.
      • getRequiredAttributeNames

        public String[] getRequiredAttributeNames()
        Gets a list of required attribute names defined in the object.
        Returns:
        Names of all required attributes defined
      • getOptionalAttributeNames

        public String[] getOptionalAttributeNames()
        Gets a list of optional attribute names defined in the object.
        Returns:
        Names of all optional attributes defined
      • getRequiredAttributeSet

        public AttrSet getRequiredAttributeSet()
        Gets the required attributes for object creation.
        Returns:
        set of required attributes
      • getOptionalAttributeSet

        public AttrSet getOptionalAttributeSet()
        Gets the optional attributes for object creation.
        Returns:
        set of optional attributes
      • getCreationClasses

        public ArrayList getCreationClasses()
        Get the classes that the CreationTemplate is associated with.
        Returns:
        classes associated with this template
      • getValidation

        public Enumeration getValidation​(String attrName)
        Gets enumeration of ValidationElement for the attribute name
        Parameters:
        attrName - Attribute name
        Returns:
        Enumeration of ValidationElement
      • getValidatedAttributeNames

        public String[] getValidatedAttributeNames()
        Gets a list of attribute names registered for validation.
        Returns:
        a list of attribute names registered for validation
      • getAttributes

        public Enumeration getAttributes()
        Gets enumeration of attributes for object creation.
        Returns:
        enumeration of required and optional attributes
      • setRequiredAttributeSet

        public void setRequiredAttributeSet​(AttrSet attrSet)
        Sets the required attributes.
        Parameters:
        attrSet - set of required attributes
      • setOptionalAttributeSet

        public void setOptionalAttributeSet​(AttrSet attrSet)
        Sets the optional attributes.
        Parameters:
        attrSet - set of optional attributes
      • setCreationClasses

        public void setCreationClasses​(ArrayList classes)
        Set the class that the CreationTemplate is associated with.
        Parameters:
        classes - Classes associated with this template
      • addRequiredAttribute

        public void addRequiredAttribute​(Attr attr)
        Adds the attribute to the required attributes.
        Parameters:
        attr - The attribute to be added
      • addOptionalAttribute

        public void addOptionalAttribute​(Attr attr)
        Adds the attribute to the optional attributes.
        Parameters:
        attr - The attribute to be added
      • addValidation

        public void addValidation​(String attrName,
                                  String validatorClass,
                                  String rule)
        Adds the validator and the rule for the attribute name.
        Parameters:
        attrName - Attribute name to validate.
        validatorClass - Validator class name used for validation.
        rule - The optional rule used by the validator.
      • removeValidation

        public void removeValidation​(String attrName)
        Removes all validations from the attribute.
        Parameters:
        attrName - attribute name of the validations to be removed
      • getNamingAttribute

        public String getNamingAttribute()
        Gets the naming attribute.
        Returns:
        the naming attribute
      • clone

        public Object clone()
        Returns a copy of the template.
        Overrides:
        clone in class Template
        Returns:
        a copy of the template
      • toString

        public String toString()
        Render the object.
        Overrides:
        toString in class Object
        Returns:
        The object in printable form