Class FileLongIDFactory

    • Field Detail

      • CHARSET_TO_USE

        public static final Charset CHARSET_TO_USE
        The charset to use for writing the file
      • DEFAULT_RESERVE_COUNT

        public static final int DEFAULT_RESERVE_COUNT
        The default number of values to reserve with a single IO action
        See Also:
        Constant Field Values
    • Method Detail

      • getFile

        @Nonnull
        public final File getFile()
        Returns:
        The File to write to, as provided in the constructor. Never null.
      • readAndUpdateIDCounter

        protected final long readAndUpdateIDCounter​(@Nonnegative
                                                    int nReserveCount)
        Description copied from class: AbstractPersistingLongIDFactory
        Read the current ID from the device. In case the method is called for a non-initialized device, 0 should be returned.
        The update should write the read value plus the passed reserve count back to the device. This method should perform an atomic read and update to avoid that ID can be reused.
        Pseudo code:
         protected long readAndUpdateIDCounter (int nReserveCount)
         {
           final long nRead = FileIO.read (file);
           FileIO.write (file, nRead + nReserveCount);
           return nRead;
         }
         
        Specified by:
        readAndUpdateIDCounter in class AbstractPersistingLongIDFactory
        Parameters:
        nReserveCount - the number that should be added to the read value. Always > 0.
        Returns:
        0 if this method is called for a non-initialized device, the value read from the device otherwise or CGlobal.ILLEGAL_ULONG in case of an error.