Class Template


  • public class Template
    extends Object
    This class defines a template, which is a pattern that may be used to generate entries. A template may be used either below a branch or below another template.
    • Constructor Detail

      • Template

        public Template​(TemplateFile templateFile,
                        String name,
                        AttributeType[] rdnAttributes,
                        String[] subordinateTemplateNames,
                        int[] numEntriesPerTemplate,
                        TemplateLine[] templateLines)
        Creates a new template with the provided information.
        Parameters:
        templateFile - The template file that contains this template.
        name - The name for this template.
        rdnAttributes - The set of attribute types that are used in the RDN for entries generated using this template.
        subordinateTemplateNames - The names of the subordinate templates below this template.
        numEntriesPerTemplate - The number of entries to create below each subordinate template.
        templateLines - The set of template lines for this template.
    • Method Detail

      • completeTemplateInitialization

        public void completeTemplateInitialization​(Map<String,​Template> templates)
                                            throws MakeLDIFException
        Performs any necessary processing to ensure that the template initialization is completed. In particular, it should make sure that all referenced subordinate templates actually exist in the template file, and that all of the RDN attributes are contained in the template lines.
        Parameters:
        templates - The set of templates defined in the template file.
        Throws:
        MakeLDIFException - If any of the subordinate templates are not defined in the template file.
      • getName

        public String getName()
        Retrieves the name for this template.
        Returns:
        The name for this template.
      • getRDNAttributes

        public AttributeType[] getRDNAttributes()
        Retrieves the set of attribute types that are used in the RDN for entries generated using this template.
        Returns:
        The set of attribute types that are used in the RDN for entries generated using this template.
      • getSubordinateTemplateNames

        public String[] getSubordinateTemplateNames()
        Retrieves the names of the subordinate templates used to generate entries below entries created by this template.
        Returns:
        The names of the subordinate templates used to generate entries below entries created by this template.
      • getSubordinateTemplates

        public Template[] getSubordinateTemplates()
        Retrieves the subordinate templates used to generate entries below entries created by this template.
        Returns:
        The subordinate templates used to generate entries below entries created by this template.
      • getNumEntriesPerTemplate

        public int[] getNumEntriesPerTemplate()
        Retrieves the number of entries that should be created for each subordinate template.
        Returns:
        The number of entries that should be created for each subordinate template.
      • getTemplateLines

        public TemplateLine[] getTemplateLines()
        Retrieves the set of template lines for this template.
        Returns:
        The set of template lines for this template.
      • addTemplateLine

        public void addTemplateLine​(TemplateLine line)
        Adds the provided template line to this template.
        Parameters:
        line - The template line to add to this template.
      • hasAttribute

        public boolean hasAttribute​(AttributeType attributeType)
        Indicates whether this template contains any template lines that reference the provided attribute type.
        Parameters:
        attributeType - The attribute type for which to make the determination.
        Returns:
        true if this template contains one or more template lines that reference the provided attribute type, or false if not.
      • writeEntries

        public TagResult writeEntries​(EntryWriter entryWriter,
                                      DN parentDN,
                                      int count)
                               throws IOException,
                                      MakeLDIFException
        Writes the entry for this template, as well as all appropriate subordinate entries.
        Parameters:
        entryWriter - The entry writer that will be used to write the entries.
        parentDN - The DN of the entry below which the subordinate entries should be generated.
        count - The number of entries to generate based on this template.
        Returns:
        The result that indicates whether processing should continue.
        Throws:
        IOException - If a problem occurs while attempting to write to the LDIF writer.
        MakeLDIFException - If some other problem occurs.