public class CodeGenerator extends Object
This class takes the configuration (from the package org.sw4j.tool.barcode.random.config) and uses this
configuration to generate encoded random numbers and barcodes.
This class is not thread safe.
| Constructor and Description |
|---|
CodeGenerator(GenerationConfig config,
CodeData codeData)
The constructor for a new
CodeGenerator. |
CodeGenerator(GenerationConfig config,
CodeData codeData,
Random random)
The constructor for a new
CodeGenerator. |
| Modifier and Type | Method and Description |
|---|---|
Set<IdentValue> |
convertCodes(Map<String,String> inputValues,
EncodingConfig encoding,
Set<EncodingConfig> encodings)
Create the encoded representation for all
inputValues. |
void |
createCodes()
Create the random numbers (and encoded representations) for the idents and writes the codes to the output csv
file.
|
Set<IdentValue> |
createCodes(Collection<String> inputValues,
Set<EncodingConfig> encodings)
Create random values for all
inputValues. |
public CodeGenerator(GenerationConfig config, CodeData codeData)
The constructor for a new CodeGenerator. The code generator is initialized with the random configuration
and a factory for the input and output streams.
The code generator is initialized with a SecureRandom random number generator.
config - the random number configuration.codeData - the factories for the input and output streams.public CodeGenerator(GenerationConfig config, CodeData codeData, Random random)
The constructor for a new CodeGenerator. The code generator is initialized with the random configuration
and a factory for the input and output streams.
The code generator uses the random number generator supplied during construction.
Attention: if you do not know the security issues involved with using your own random number generator
please use the constructor #CodeGenerator(RandomConfig,CodeData) which creates a secure random number
generator for you.
config - the random number configuration.codeData - the factories for the input and output streams.random - the random number generator to use.public void createCodes()
throws IOException
Create the random numbers (and encoded representations) for the idents and writes the codes to the output csv file.
IOException - if the reading or writing of the data fails.IllegalArgumentException - if a duplicate ident is found in the input.public Set<IdentValue> convertCodes(Map<String,String> inputValues, EncodingConfig encoding, Set<EncodingConfig> encodings)
Create the encoded representation for all inputValues.
This method is thread safe.
inputValues - the inputValues (idents) for which the random numbers should be created.encoding - the encoding of the source value.encodings - the encodings that should be created for the random numbers.RandomIdent instances with the random
numbers and the encoded random numbers.public Set<IdentValue> createCodes(Collection<String> inputValues, Set<EncodingConfig> encodings)
Create random values for all inputValues. Additionally the encoded representation for the random values
are created.
This method is thread safe.
inputValues - the inputValues (idents) for which the random numbers should be created.encodings - the encodings that should be created for the random numbers.RandomIdent instances with the random
numbers and the encoded random numbers.Copyright © 2020 sw4j.org. All rights reserved.