@ThreadSafe public class FileIntIDFactory extends AbstractPersistingIntIDFactory
File based persisting IIntIDFactory implementation.| Modifier and Type | Field and Description |
|---|---|
static Charset |
CHARSET_TO_USE
The charset to use for writing the file
|
static int |
DEFAULT_RESERVE_COUNT
The default number of values to reserve with a single IO action
|
m_aLock| Constructor and Description |
|---|
FileIntIDFactory(File aFile) |
FileIntIDFactory(File aFile,
int nReserveCount) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
File |
getFile() |
int |
hashCode() |
protected int |
readAndUpdateIDCounter(int nReserveCount)
Read the current ID from the device.
|
String |
toString() |
getNewID, getReserveCountpublic static final Charset CHARSET_TO_USE
public static final int DEFAULT_RESERVE_COUNT
public FileIntIDFactory(@Nonnull File aFile, @Nonnegative int nReserveCount)
@Nonnull public final File getFile()
File to write to, as provided in the constructor. Never
null.@MustBeLocked(value=WRITE) protected final int readAndUpdateIDCounter(@Nonnegative int nReserveCount)
AbstractPersistingIntIDFactory
protected int readAndUpdateIDCounter (int nReserveCount)
{
final int nRead = FileIO.read (file);
FileIO.write (file, nRead + nReserveCount);
return nRead;
}
readAndUpdateIDCounter in class AbstractPersistingIntIDFactorynReserveCount - the number that should be added to the read value. Always > 0.CGlobal.ILLEGAL_UINT in case of an
error.public boolean equals(Object o)
equals in class AbstractPersistingIntIDFactorypublic int hashCode()
hashCode in class AbstractPersistingIntIDFactorypublic String toString()
toString in class AbstractPersistingIntIDFactoryCopyright © 2014–2020 Philip Helger. All rights reserved.