Package org.forgerock.opendj.ldif
Class EntryGenerator
java.lang.Object
org.forgerock.opendj.ldif.EntryGenerator
- All Implemented Interfaces:
Closeable,AutoCloseable,EntryReader
A template driven entry generator, as used by the makeldif tool.
To build a generator with default values, including default template file, use the empty constructor:
generator = new EntryGenerator();
To build a generator with some custom values, use the non-empty constructor
and the set methods:
generator = new EntryGenerator(templatePath).setResourcePath(path).setSchema(schema)
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a generator using default values.EntryGenerator(InputStream templateStream) Creates a generator from the provided input stream.EntryGenerator(String templatePath) Creates a generator from the provided template path.EntryGenerator(String... templateLines) Creates a generator from the provided template lines.EntryGenerator(List<String> templateLines) Creates a generator from the provided template lines. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this entry reader if it is not already closed.Returns the warnings generated by the parsing of template file.booleanhasNext()Returnstrueif this reader contains another entry, blocking if necessary until either the next entry is available or the end of the stream is reached.booleanChecks if there are some warning(s) after parsing the template file.Reads the next entry, blocking if necessary until an entry is available.setConstant(String name, Object value) Sets a constant to use in template file.setGenerateBranches(boolean generateBranches) Sets the flag which indicates whether branch entries should be generated.setRandomSeed(int seed) Sets the random seed to use when generating entries.setResourcePath(String path) Sets the resource path, used to looks for resources files like first names, last names, or other custom resources.setResourcePath(Path path) Sets the resource path, used to looks for resources files like first names, last names, or other custom resources.Sets the schema which should be when generating entries.
-
Constructor Details
-
EntryGenerator
public EntryGenerator()Creates a generator using default values.The default template file will be used to generate entries.
-
EntryGenerator
Creates a generator from the provided template path.- Parameters:
templatePath- Path of the template file.
-
EntryGenerator
Creates a generator from the provided template lines.- Parameters:
templateLines- Lines defining the template file.
-
EntryGenerator
Creates a generator from the provided template lines.- Parameters:
templateLines- Lines defining the template file.
-
EntryGenerator
Creates a generator from the provided input stream.- Parameters:
templateStream- Input stream to read the template file.
-
-
Method Details
-
setRandomSeed
Sets the random seed to use when generating entries.- Parameters:
seed- The random seed to use.- Returns:
- A reference to this
EntryGenerator.
-
setResourcePath
Sets the resource path, used to looks for resources files like first names, last names, or other custom resources.- Parameters:
path- The resource path.- Returns:
- A reference to this
EntryGenerator.
-
setResourcePath
Sets the resource path, used to looks for resources files like first names, last names, or other custom resources.- Parameters:
path- The resource path.- Returns:
- A reference to this
EntryGenerator.
-
setSchema
Sets the schema which should be when generating entries. The default schema is used if no other is specified.- Parameters:
schema- The schema which should be used for generating entries.- Returns:
- A reference to this
EntryGenerator.
-
setConstant
Sets a constant to use in template file. It overrides the constant set in the template file.- Parameters:
name- The name of the constant.value- The value of the constant.- Returns:
- A reference to this
EntryGenerator.
-
setGenerateBranches
Sets the flag which indicates whether branch entries should be generated. The default istrue.- Parameters:
generateBranches- Indicates whether the branches DN entries has to be generated.- Returns:
- A reference to this
EntryGenerator.
-
hasWarnings
public boolean hasWarnings()Checks if there are some warning(s) after parsing the template file.Warnings are available only after the first call to
hasNext()orreadEntry()methods.- Returns:
trueif there is at least one warning.
-
getWarnings
Returns the warnings generated by the parsing of template file.Warnings are available only after the first call to
hasNext()orreadEntry()methods.- Returns:
- The list of warnings, which is empty if there are no warnings.
-
close
public void close()Description copied from interface:EntryReaderCloses this entry reader if it is not already closed. Note that this method does not need to be called if a previous call ofEntryReader.readEntry()has returnednull.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntryReader
-
hasNext
Description copied from interface:EntryReaderReturnstrueif this reader contains another entry, blocking if necessary until either the next entry is available or the end of the stream is reached.- Specified by:
hasNextin interfaceEntryReader- Returns:
trueif this reader contains another entry.- Throws:
IOException- If an unexpected IO error occurred.
-
readEntry
Description copied from interface:EntryReaderReads the next entry, blocking if necessary until an entry is available.- Specified by:
readEntryin interfaceEntryReader- Returns:
- The next entry.
- Throws:
IOException- If an unexpected IO error occurred while reading the entry.
-