Class PayloadEntry

java.lang.Object
com.digimarc.dis.utils.PayloadEntry

public class PayloadEntry extends Object
A helper class for tracking whether a new payload has been read. This class can be considered an extension of the ReaderResult.getNewPayloads() method. Where the ReaderResult method reports whether the payload differs from the last read of that specific detector (i.e. Digimarc Barcode, Barcode, etc.), this class reports whether the last image read matches a new one. In addition this class supports a timeout interval. This allows an app to treat a payload as a new read even if it was also the last payload read, as long as some number of seconds have passed since the last read.
  • Constructor Details

    • PayloadEntry

      public PayloadEntry(@NonNull Payload payload)
      Constructor. Stores the payload as well as setting a timestamp with the current time. The timeout interval will be set to 3 seconds.
      Parameters:
      payload - Payload.
    • PayloadEntry

      public PayloadEntry(@NonNull Payload payload, long timeoutInterval)
      Constructor. Stores the payload as well as setting a timestamp with the current time. The timeout interval will be set to the supplied value.
      Parameters:
      payload - Payload.
      timeoutInterval - Timeout interval. Pass in 0 to disable timeout functionality.
  • Method Details

    • isNewPayload

      public boolean isNewPayload(@NonNull Payload payload)
      Checks to see if 1) a payload is the same as the stored payload, and 2) if less than the timeout interval milliseconds have elapsed. If either of these are false then the payload is considered to be new. In the case that both conditions are true the timestamp will be updated to the current time, as a payload should not be considered new until it has not been read at all within the timeout interval.
      Parameters:
      payload - Payload to check for.
      Returns:
      True if the payload matches and the difference in timestamps is greater than the timeout interval. Returns false otherwise.