@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
|
| Constructor and Description |
|---|
FileIntIDFactory(File aFile) |
FileIntIDFactory(File aFile,
int nReserveCount) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
int |
hashCode() |
protected int |
readAndUpdateIDCounter(int nReserveCount)
Read the current ID from the device.
|
String |
toString() |
getNewID, getReserveCount@Nonnull public static final Charset CHARSET_TO_USE
@Nonnegative public static final int DEFAULT_RESERVE_COUNT
public FileIntIDFactory(@Nonnull File aFile, @Nonnegative int nReserveCount)
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 © 2006–2015 phloc systems. All rights reserved.