public class TemplateFile extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FIRST_NAME_FILE
The name of the file holding the list of first names.
|
static String |
LAST_NAME_FILE
The name of the file holding the list of last names.
|
Constructor and Description |
---|
TemplateFile(String resourcePath)
Creates a new, empty template file structure.
|
TemplateFile(String resourcePath,
Random random)
Creates a new, empty template file structure.
|
Modifier and Type | Method and Description |
---|---|
TagResult |
generateLDIF(EntryWriter entryWriter)
Generates the LDIF content and writes it to the provided LDIF writer.
|
Branch |
getBranch(DN branchDN)
Retrieves the branch registered with the specified DN.
|
Map<DN,Branch> |
getBranches()
Retrieves the set of branches defined in this template file.
|
String |
getConstant(String lowerName)
Retrieves the value of the constant with the specified name.
|
Map<String,String> |
getConstants()
Retrieves the set of constants defined for this template file.
|
File |
getFile(String path)
Retrieves a File object based on the provided path.
|
String[] |
getFileLines(File file)
Retrieves the lines of the specified file as a string array.
|
String |
getFirstName()
Retrieves the first name value that should be used for the current entry.
|
String |
getLastName()
Retrieves the last name value that should be used for the current entry.
|
Random |
getRandom()
Retrieves the random number generator for this template file.
|
Tag |
getTag(String lowerName)
Retrieves the tag with the specified name.
|
Map<String,Tag> |
getTags()
Retrieves the set of tags that have been registered.
|
Template |
getTemplate(String lowerName)
Retrieves the template with the specified name.
|
Map<String,Template> |
getTemplates()
Retrieves the set of templates defined in this template file.
|
void |
nextFirstAndLastNames()
Updates the first and last name indexes to choose new values.
|
void |
parse(InputStream inputStream,
List<LocalizableMessage> warnings)
Parses the data read from the provided input stream as a MakeLDIF template
file definition.
|
void |
parse(String[] lines,
List<LocalizableMessage> warnings)
Parses the provided data as a MakeLDIF template file definition.
|
void |
parse(String filename,
List<LocalizableMessage> warnings)
Parses the contents of the specified file as a MakeLDIF template file
definition.
|
void |
registerBranch(Branch branch)
Registers the provided branch in this template file.
|
void |
registerConstant(String name,
String value)
Registers the provided constant for use in the template.
|
void |
registerTag(String tagClass)
Registers the specified class as a tag that may be used in templates.
|
void |
registerTemplate(Template template)
Registers the provided template for use in this template file.
|
public static final String FIRST_NAME_FILE
public static final String LAST_NAME_FILE
public TemplateFile(String resourcePath)
resourcePath
- The path to the directory that may contain additional
resource files needed during the LDIF generation
process.public TemplateFile(String resourcePath, Random random)
resourcePath
- The path to the directory that may contain additional
resource files needed during the LDIF generation
process.random
- The random number generator for this template file.public Map<String,Tag> getTags()
public Tag getTag(String lowerName)
lowerName
- The name of the tag to retrieve, in all lowercase
characters.null
if no such tag has been
registered.public void registerTag(String tagClass) throws MakeLDIFException
tagClass
- The fully-qualified name of the class to register as a
tag.MakeLDIFException
- If a problem occurs while attempting to
register the specified tag.public Map<String,String> getConstants()
public String getConstant(String lowerName)
lowerName
- The name of the constant to retrieve, in all lowercase
characters.null
if there is no such constant.public void registerConstant(String name, String value)
name
- The name for the constant.value
- The value for the constant.public Map<DN,Branch> getBranches()
public Branch getBranch(DN branchDN)
branchDN
- The DN for which to retrieve the corresponding branch.null
if no such branch has
been registered.public void registerBranch(Branch branch)
branch
- The branch to be registered.public Map<String,Template> getTemplates()
public Template getTemplate(String lowerName)
lowerName
- The name of the template to retrieve, in all lowercase
characters.null
if there is no such
template.public void registerTemplate(Template template)
template
- The template to be registered.public Random getRandom()
public void nextFirstAndLastNames()
public String getFirstName()
public String getLastName()
public void parse(String filename, List<LocalizableMessage> warnings) throws IOException, InitializationException, MakeLDIFException
filename
- The name of the file containing the template data.warnings
- A list into which any warnings identified may be placed.IOException
- If a problem occurs while attempting to read data
from the specified file.InitializationException
- If a problem occurs while initializing
any of the MakeLDIF components.MakeLDIFException
- If any other problem occurs while parsing the
template file.public void parse(InputStream inputStream, List<LocalizableMessage> warnings) throws IOException, InitializationException, MakeLDIFException
inputStream
- The input stream from which to read the template file
data.warnings
- A list into which any warnings identified may be
placed.IOException
- If a problem occurs while attempting to read data
from the provided input stream.InitializationException
- If a problem occurs while initializing
any of the MakeLDIF components.MakeLDIFException
- If any other problem occurs while parsing the
template file.public void parse(String[] lines, List<LocalizableMessage> warnings) throws InitializationException, MakeLDIFException
lines
- The lines that make up the template file.warnings
- A list into which any warnings identified may be placed.InitializationException
- If a problem occurs while initializing
any of the MakeLDIF components.MakeLDIFException
- If any other problem occurs while parsing the
template file.public File getFile(String path)
path
- The path provided for the file.null
if
the specified file could not be found.public String[] getFileLines(File file) throws IOException
file
- The file for which to retrieve the contents.IOException
- If a problem occurs while reading the file.public TagResult generateLDIF(EntryWriter entryWriter) throws IOException, MakeLDIFException
entryWriter
- The entry writer that should be used to write the
entries.IOException
- If an error occurs while writing to the LDIF file.MakeLDIFException
- If some other problem occurs.Copyright © 2010-2016 ForgeRock AS. All Rights Reserved.