Class FileMillisecondStoreDataProvider

java.lang.Object
org.lukashian.store.external.ExternalResourceMillisecondStoreDataProvider
org.lukashian.store.external.file.FileMillisecondStoreDataProvider
All Implemented Interfaces:
MillisecondStoreDataProvider

public class FileMillisecondStoreDataProvider extends ExternalResourceMillisecondStoreDataProvider
This implementation of ExternalResourceMillisecondStoreDataProvider loads binary streams of long values from a file.

Please see ExternalResourceMillisecondStoreDataProvider for more details regarding the external resource mechanism.

The FileMillisecondStoreDataProvider is useful for applications that want to load the numbers of milliseconds from the official lukashian.org server, but don't have access to the Internet. If you want to use this class to load the exact same numbers as the StandardEarthHttpMillisecondStoreDataProvider, then you can simply perform requests to the location specified in the StandardEarthHttpMillisecondStoreDataProvider, extended with the default locations specified in ExternalResourceMillisecondStoreDataProvider, for example:

     curl -L https://lukashian.org/millisecondstore/standardearth/unixEpochOffset -o unixEpochOffset
 
Alternatively, you can simply use a browser to obtain the file at the above example url.
  • Constructor Details

    • FileMillisecondStoreDataProvider

      public FileMillisecondStoreDataProvider(String basePath, String unixEpochOffsetPathExtension, String yearEpochMillisecondsPathExtension, String dayEpochMillisecondsPathExtension)
    • FileMillisecondStoreDataProvider

      public FileMillisecondStoreDataProvider(String basePath)
  • Method Details

    • loadMillisecondsByteArray

      protected byte[] loadMillisecondsByteArray(String path) throws IOException
      Description copied from class: ExternalResourceMillisecondStoreDataProvider
      Loads an array of bytes from the specified location. This location is a concatenation of the base location and one of the extensions, depending on which of the values needs loading.

      This method needs to return a binary stream from the specified location. This binary stream should encode the long values that represent the milliseconds. Each consecutive 8 bytes of the stream should correspond to an individual millisecond. This binary stream is then decoded into an array of longs. For the unix epoch offset, only a single long value (i.e. 8 bytes) should be returned in the binary stream.

      Specified by:
      loadMillisecondsByteArray in class ExternalResourceMillisecondStoreDataProvider
      Throws:
      IOException