Package ca.uhn.hl7v2.util.idgenerator
Class FileBasedGenerator
java.lang.Object
ca.uhn.hl7v2.util.idgenerator.IDGenerator.OrderedSupport
ca.uhn.hl7v2.util.idgenerator.InMemoryIDGenerator
ca.uhn.hl7v2.util.idgenerator.FileBasedGenerator
- All Implemented Interfaces:
IDGenerator,IDGenerator.Ordered
Replacement for
MessageIDGenerator. You should not use this class
directly, however, but wrap it into a DelegatingHiLoGenerator generator. Its primary
improvement over MessageIDGenerator is that you can set path and file
name.
Reading and writing to the file is thread-safe, however, you should not use the same file from different Java processes because no read/write locks are being checked.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ca.uhn.hl7v2.util.idgenerator.IDGenerator
IDGenerator.Ordered, IDGenerator.OrderedSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetID()Generates and returns a new ID.voidreset()voidsetDirectory(String directory) voidsetFileName(String fileName) voidsetMinimizeReads(boolean theMinimizeReads) If set totrue(default isfalse) the generator minimizes the number of disk reads by caching the last read value.voidsetNeverFail(boolean neverFail) If set tofalse(default istrue), retrieving a new ID may fail if the ID file in the home directory can not be written/read.Methods inherited from class ca.uhn.hl7v2.util.idgenerator.InMemoryIDGenerator
setMethods inherited from class ca.uhn.hl7v2.util.idgenerator.IDGenerator.OrderedSupport
getIncrement
-
Constructor Details
-
FileBasedGenerator
public FileBasedGenerator() -
FileBasedGenerator
-
-
Method Details
-
getID
Description copied from interface:IDGeneratorGenerates and returns a new ID. Note: This method must be implemented to be thread-safe.- Specified by:
getIDin interfaceIDGenerator- Overrides:
getIDin classInMemoryIDGenerator- Returns:
- a new ID.
- Throws:
IOException
-
setDirectory
-
setFileName
-
setMinimizeReads
If set totrue(default isfalse) the generator minimizes the number of disk reads by caching the last read value. This means one less disk read per X number of IDs generated, but also means that multiple instances of this generator may clobber each other's values. -
setNeverFail
If set tofalse(default istrue), retrieving a new ID may fail if the ID file in the home directory can not be written/read. If set to true, failures will be ignored, which means that IDs may be repeated after a JVM restart. -
reset
- Specified by:
resetin interfaceIDGenerator.Ordered- Overrides:
resetin classInMemoryIDGenerator
-