org.opends.server.tools.makeldif
Class Template

java.lang.Object
  extended by org.opends.server.tools.makeldif.Template

public class Template
extends java.lang.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 Summary
Template(TemplateFile templateFile, java.lang.String name, AttributeType[] rdnAttributes, java.lang.String[] subordinateTemplateNames, int[] numEntriesPerTemplate)
          Creates a new template with the provided information.
Template(TemplateFile templateFile, java.lang.String name, AttributeType[] rdnAttributes, java.lang.String[] subordinateTemplateNames, int[] numEntriesPerTemplate, TemplateLine[] templateLines)
          Creates a new template with the provided information.
 
Method Summary
 void addTemplateLine(TemplateLine line)
          Adds the provided template line to this template.
 void completeTemplateInitialization(java.util.Map<java.lang.String,Template> templates)
          Performs any necessary processing to ensure that the template initialization is completed.
 java.lang.String getName()
          Retrieves the name for this template.
 int[] getNumEntriesPerTemplate()
          Retrieves the number of entries that should be created for each subordinate template.
 AttributeType[] getRDNAttributes()
          Retrieves the set of attribute types that are used in the RDN for entries generated using this template.
 java.lang.String[] getSubordinateTemplateNames()
          Retrieves the names of the subordinate templates used to generate entries below entries created by this template.
 Template[] getSubordinateTemplates()
          Retrieves the subordinate templates used to generate entries below entries created by this template.
 TemplateLine[] getTemplateLines()
          Retrieves the set of template lines for this template.
 boolean hasAttribute(AttributeType attributeType)
          Indicates whether this template contains any template lines that reference the provided attribute type.
 TagResult writeEntries(EntryWriter entryWriter, DN parentDN, int count)
          Writes the entry for this template, as well as all appropriate subordinate entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Template

public Template(TemplateFile templateFile,
                java.lang.String name,
                AttributeType[] rdnAttributes,
                java.lang.String[] subordinateTemplateNames,
                int[] numEntriesPerTemplate)
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.

Template

public Template(TemplateFile templateFile,
                java.lang.String name,
                AttributeType[] rdnAttributes,
                java.lang.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(java.util.Map<java.lang.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 java.lang.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 java.lang.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 java.io.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:
java.io.IOException - If a problem occurs while attempting to write to the LDIF writer.
MakeLDIFException - If some other problem occurs.