@ThreadSafe public class FileLongIDFactory extends AbstractPersistingLongIDFactory
File based persisting ILongIDFactory 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 |
|---|
FileLongIDFactory(File aFile) |
FileLongIDFactory(File aFile,
int nReserveCount) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
int |
hashCode() |
protected long |
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 FileLongIDFactory(@Nonnull File aFile, @Nonnegative int nReserveCount)
protected final long readAndUpdateIDCounter(@Nonnegative int nReserveCount)
AbstractPersistingLongIDFactory
protected long readAndUpdateIDCounter (int nReserveCount)
{
final long nRead = FileIO.read (file);
FileIO.write (file, nRead + nReserveCount);
return nRead;
}
readAndUpdateIDCounter in class AbstractPersistingLongIDFactorynReserveCount - the number that should be added to the read value. Always > 0.CGlobal.ILLEGAL_ULONG in case of an
error.public boolean equals(Object o)
equals in class AbstractPersistingLongIDFactorypublic int hashCode()
hashCode in class AbstractPersistingLongIDFactorypublic String toString()
toString in class AbstractPersistingLongIDFactoryCopyright © 2006–2014 phloc systems. All rights reserved.