Class ExternalResourceMillisecondStoreDataProvider
- All Implemented Interfaces:
MillisecondStoreDataProvider
- Direct Known Subclasses:
FileMillisecondStoreDataProvider
,HttpMillisecondStoreDataProvider
A MillisecondStoreDataProvider
needs to provide three things: the unix epoch offset, the milliseconds of the years and the milliseconds of the days.
Please see the javadoc of MillisecondStoreDataProvider
for more details.
An ExternalResourceMillisecondStoreDataProvider
requires a base location and three extensions, one for each method of @MillisecondStoreDataProvider
.
It then loads the required values by combining the base location with each extension. The base location can, for example, be a directory or a url. The
extensions then point to individual files at that base location. The base location should always end with a path separator, because the extensions are
added to the base location as is.
Default values are given for the extensions corresponding to the three things that need to be provided by the MillisecondStoreDataProvider
. Implementations
that use these defaults then only need to specify the base location.
Loading of the milliseconds is done by loading 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.
The actual mechanism for loading the binary stream is left to subclasses of this class, so that various implementations can provide functionality for loading the
milliseconds from various kinds of external resources, such as files, http urls, etc. See loadMilliseconds(String)
for details.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExternalResourceMillisecondStoreDataProvider
(String baseLocation) Creates anExternalResourceMillisecondStoreDataProvider
that loads arrays of milliseconds from the specified base location, using the default extensions.ExternalResourceMillisecondStoreDataProvider
(String baseLocation, String unixEpochOffsetExtension, String yearEpochMillisecondsExtension, String dayEpochMillisecondsExtension) Creates anExternalResourceMillisecondStoreDataProvider
that loads arrays of milliseconds from the specified base location and extensions. -
Method Summary
Modifier and TypeMethodDescriptionlong[]
loadDayEpochMilliseconds
(long[] yearEpochMilliseconds) protected abstract byte[]
loadMillisecondsByteArray
(String location) Loads an array of bytes from the specified location.long
long[]
-
Field Details
-
DEFAULT_UNIX_EPOCH_OFFSET_EXTENSION
- See Also:
-
DEFAULT_YEAR_EPOCH_MILLISECONDS_EXTENSION
- See Also:
-
DEFAULT_DAY_EPOCH_MILLISECONDS_EXTENSION
- See Also:
-
-
Constructor Details
-
ExternalResourceMillisecondStoreDataProvider
public ExternalResourceMillisecondStoreDataProvider(String baseLocation, String unixEpochOffsetExtension, String yearEpochMillisecondsExtension, String dayEpochMillisecondsExtension) Creates anExternalResourceMillisecondStoreDataProvider
that loads arrays of milliseconds from the specified base location and extensions. The base location should always end with a path separator, because the extensions are added to the base location as is. -
ExternalResourceMillisecondStoreDataProvider
Creates anExternalResourceMillisecondStoreDataProvider
that loads arrays of milliseconds from the specified base location, using the default extensions. The base location should always end with a path separator, because the extensions are added to the base location as is.
-
-
Method Details
-
loadUnixEpochOffsetMilliseconds
public long loadUnixEpochOffsetMilliseconds()- Specified by:
loadUnixEpochOffsetMilliseconds
in interfaceMillisecondStoreDataProvider
-
loadYearEpochMilliseconds
public long[] loadYearEpochMilliseconds()- Specified by:
loadYearEpochMilliseconds
in interfaceMillisecondStoreDataProvider
-
loadDayEpochMilliseconds
public long[] loadDayEpochMilliseconds(long[] yearEpochMilliseconds) - Specified by:
loadDayEpochMilliseconds
in interfaceMillisecondStoreDataProvider
-
loadMillisecondsByteArray
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.
- Throws:
Exception
-