org.opends.server.tools.makeldif
Class Branch

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

public class Branch
extends java.lang.Object

This class defines a branch that should be included in the resulting LDIF. A branch may or may not have subordinate entries.


Constructor Summary
Branch(TemplateFile templateFile, DN branchDN)
          Creates a new branch with the provided information.
Branch(TemplateFile templateFile, DN branchDN, java.lang.String[] subordinateTemplateNames, int[] numEntriesPerTemplate, TemplateLine[] extraLines)
          Creates a new branch with the provided information.
 
Method Summary
 void addExtraLine(TemplateLine line)
          Adds the provided template line to the set of extra lines for this branch.
 void addSubordinateTemplate(java.lang.String name, int numEntries)
          Adds a new subordinate template to this branch.
 void completeBranchInitialization(java.util.Map<java.lang.String,Template> templates)
          Performs any necessary processing to ensure that the branch initialization is completed.
 DN getBranchDN()
          Retrieves the DN for this branch entry.
 TemplateLine[] getExtraLines()
          Retrieves the set of extra lines that should be included in this branch entry.
 int[] getNumEntriesPerTemplate()
          Retrieves the number of entries that should be created below this branch for each subordinate template.
 java.lang.String[] getSubordinateTemplateNames()
          Retrieves the names of the subordinate templates for this branch.
 Template[] getSubordinateTemplates()
          Retrieves the set of subordinate templates used to generate entries below this branch.
 boolean hasAttribute(AttributeType attributeType)
          Indicates whether this branch contains a reference to the specified attribute type, either in the RDN components of the DN or in the extra lines.
 TagResult writeEntries(EntryWriter entryWriter)
          Writes the entry for this branch, 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

Branch

public Branch(TemplateFile templateFile,
              DN branchDN)
Creates a new branch with the provided information.

Parameters:
templateFile - The template file in which this branch appears.
branchDN - The DN for this branch entry.

Branch

public Branch(TemplateFile templateFile,
              DN branchDN,
              java.lang.String[] subordinateTemplateNames,
              int[] numEntriesPerTemplate,
              TemplateLine[] extraLines)
Creates a new branch with the provided information.

Parameters:
templateFile - The template file in which this branch appears.
branchDN - The DN for this branch entry.
subordinateTemplateNames - The names of the subordinate templates used to generate entries below this branch.
numEntriesPerTemplate - The number of entries that should be created below this branch for each subordinate template.
extraLines - The set of extra lines that should be included in this branch entry.
Method Detail

completeBranchInitialization

public void completeBranchInitialization(java.util.Map<java.lang.String,Template> templates)
                                  throws MakeLDIFException
Performs any necessary processing to ensure that the branch initialization is completed. In particular, it should make sure that all referenced subordinate templates actually exist in the template file.

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.

getBranchDN

public DN getBranchDN()
Retrieves the DN for this branch entry.

Returns:
The DN for this branch entry.

getSubordinateTemplateNames

public java.lang.String[] getSubordinateTemplateNames()
Retrieves the names of the subordinate templates for this branch.

Returns:
The names of the subordinate templates for this branch.

getSubordinateTemplates

public Template[] getSubordinateTemplates()
Retrieves the set of subordinate templates used to generate entries below this branch. Note that the subordinate templates will not be available until the completeBranchInitialization method has been called.

Returns:
The set of subordinate templates used to generate entries below this branch.

getNumEntriesPerTemplate

public int[] getNumEntriesPerTemplate()
Retrieves the number of entries that should be created below this branch for each subordinate template.

Returns:
The number of entries that should be created below this branch for each subordinate template.

addSubordinateTemplate

public void addSubordinateTemplate(java.lang.String name,
                                   int numEntries)
Adds a new subordinate template to this branch. Note that this should not be used after completeBranchInitialization has been called.

Parameters:
name - The name of the template to use to generate the entries.
numEntries - The number of entries to create based on the template.

getExtraLines

public TemplateLine[] getExtraLines()
Retrieves the set of extra lines that should be included in this branch entry.

Returns:
The set of extra lines that should be included in this branch entry.

addExtraLine

public void addExtraLine(TemplateLine line)
Adds the provided template line to the set of extra lines for this branch.

Parameters:
line - The line to add to the set of extra lines for this branch.

hasAttribute

public boolean hasAttribute(AttributeType attributeType)
Indicates whether this branch contains a reference to the specified attribute type, either in the RDN components of the DN or in the extra lines.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the branch does contain the specified attribute type, or false if it does not.

writeEntries

public TagResult writeEntries(EntryWriter entryWriter)
                       throws java.io.IOException,
                              MakeLDIFException
Writes the entry for this branch, as well as all appropriate subordinate entries.

Parameters:
entryWriter - The entry writer to which the entries should be written.
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.