public final class EntryGenerator extends Object implements EntryReader
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 and Description |
---|
EntryGenerator()
Creates a generator using default values.
|
EntryGenerator(InputStream templateStream)
Creates a generator from the provided input stream.
|
EntryGenerator(List<String> templateLines)
Creates a generator from the provided template lines.
|
EntryGenerator(String... templateLines)
Creates a generator from the provided template lines.
|
EntryGenerator(String templatePath)
Creates a generator from the provided template path.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this entry reader if it is not already closed.
|
List<LocalizableMessage> |
getWarnings()
Returns the warnings generated by the parsing of template file.
|
boolean |
hasNext()
Returns
true if this reader contains another entry, blocking if
necessary until either the next entry is available or the end of the
stream is reached. |
boolean |
hasWarnings()
Checks if there are some warning(s) after parsing the template file.
|
Entry |
readEntry()
Reads the next entry, blocking if necessary until an entry is available.
|
EntryGenerator |
setConstant(String name,
Object value)
Sets a constant to use in template file.
|
EntryGenerator |
setGenerateBranches(boolean generateBranches)
Sets the flag which indicates whether branch entries should be generated.
|
EntryGenerator |
setRandomSeed(int seed)
Sets the random seed to use when generating entries.
|
EntryGenerator |
setResourcePath(String path)
Sets the resource path, used to looks for resources files like first
names, last names, or other custom resources.
|
EntryGenerator |
setSchema(Schema schema)
Sets the schema which should be when generating entries.
|
public EntryGenerator()
The default template file will be used to generate entries.
public EntryGenerator(String templatePath)
templatePath
- Path of the template file.public EntryGenerator(String... templateLines)
templateLines
- Lines defining the template file.public EntryGenerator(List<String> templateLines)
templateLines
- Lines defining the template file.public EntryGenerator(InputStream templateStream)
templateStream
- Input stream to read the template file.public EntryGenerator setRandomSeed(int seed)
seed
- The random seed to use.EntryGenerator
.public EntryGenerator setResourcePath(String path)
path
- The resource path.EntryGenerator
.public EntryGenerator setSchema(Schema schema)
schema
- The schema which should be used for generating entries.EntryGenerator
.public EntryGenerator setConstant(String name, Object value)
name
- The name of the constant.value
- The value of the constant.EntryGenerator
.public EntryGenerator setGenerateBranches(boolean generateBranches)
true
.generateBranches
- Indicates whether the branches DN entries has to be generated.EntryGenerator
.public boolean hasWarnings()
Warnings are available only after the first call to hasNext()
or
readEntry()
methods.
true
if there is at least one warning.public List<LocalizableMessage> getWarnings()
Warnings are available only after the first call to hasNext()
or
readEntry()
methods.
public void close()
EntryReader
EntryReader.readEntry()
has returned null
.close
in interface Closeable
close
in interface AutoCloseable
close
in interface EntryReader
public boolean hasNext() throws IOException
EntryReader
true
if this reader contains another entry, blocking if
necessary until either the next entry is available or the end of the
stream is reached.hasNext
in interface EntryReader
true
if this reader contains another entry.IOException
- If an unexpected IO error occurred.public Entry readEntry() throws IOException
EntryReader
readEntry
in interface EntryReader
IOException
- If an unexpected IO error occurred while reading the entry.Copyright 2010-2022 ForgeRock AS.