Class: Schedule

Schedule

new Schedule()

Schedule is used to manage the times when a member can access data using two sets of RepetitiveInterval as follows. whiteIntervalList is an ordered set for the times a member is allowed to access to data, and blackIntervalList is for the times a member is not allowed. Create a Schedule with one of these forms: Schedule() A Schedule with empty whiteIntervalList and blackIntervalList. Schedule(schedule). A copy of the given schedule.
Source:

Methods

(static) calculateIntervalResult_(list, timeStamp, positiveResult, negativeResult)

A helper function to calculate black interval results or white interval results.
Parameters:
Name Type Description
list Array The set of RepetitiveInterval, which can be the white list or the black list.
timeStamp number The time stamp as milliseconds since Jan 1, 1970 UTC.
positiveResult Interval The positive result which is updated.
negativeResult Interval The negative result which is updated.
Source:

(static) decodeRepetitiveInterval_(decoder) → {RepetitiveInterval}

Decode the input as an NDN-TLV RepetitiveInterval.
Parameters:
Name Type Description
decoder TlvDecoder The decoder with the input to decode.
Source:
Returns:
A new RepetitiveInterval with the decoded result.
Type
RepetitiveInterval

(static) encodeRepetitiveInterval_(repetitiveInterval, encoder)

Encode the RepetitiveInterval as NDN-TLV to the encoder.
Parameters:
Name Type Description
repetitiveInterval RepetitiveInterval The RepetitiveInterval to encode.
encoder TlvEncoder The TlvEncoder to receive the encoding.
Source:

(static) fromIsoString(timeString) → {number}

Convert an ISO time representation with the "T" in the middle to a UNIX timestamp.
Parameters:
Name Type Description
timeString string The ISO time representation.
Source:
Returns:
The timestamp as milliseconds since Jan 1, 1970 UTC.
Type
number

(static) sortedSetAdd_()

Insert element into the list, sorted using element.compare(). If it is a duplicate of an existing list element, don't add it.
Source:

(static) to2DigitString(x) → {string}

A private method to zero pad an integer to 2 digits.
Parameters:
Name Type Description
x number The number to pad. Assume it is a non-negative integer.
Source:
Returns:
The padded string.
Type
string

(static) toIsoString(msSince1970) → {string}

Convert a UNIX timestamp to ISO time representation with the "T" in the middle.
Parameters:
Name Type Description
msSince1970 number Timestamp as milliseconds since Jan 1, 1970 UTC.
Source:
Returns:
The string representation.
Type
string

addBlackInterval(repetitiveInterval) → {Schedule}

Add the repetitiveInterval to the blackIntervalList.
Parameters:
Name Type Description
repetitiveInterval RepetitiveInterval The RepetitiveInterval to add. If the list already contains the same RepetitiveInterval, this does nothing.
Source:
Returns:
This Schedule so you can chain calls to add.
Type
Schedule

addWhiteInterval(repetitiveInterval) → {Schedule}

Add the repetitiveInterval to the whiteIntervalList.
Parameters:
Name Type Description
repetitiveInterval RepetitiveInterval The RepetitiveInterval to add. If the list already contains the same RepetitiveInterval, this does nothing.
Source:
Returns:
This Schedule so you can chain calls to add.
Type
Schedule

getCoveringInterval(timeStamp) → {object}

Get the interval that covers the time stamp. This iterates over the two repetitive interval sets and find the shortest interval that allows a group member to access the data. If there is no interval covering the time stamp, this returns false for isPositive and a negative interval.
Parameters:
Name Type Description
timeStamp number The time stamp as milliseconds since Jan 1, 1970 UTC.
Source:
Returns:
An associative array with fields (isPositive, interval) where isPositive is true if the returned interval is positive or false if negative, and interval is the Interval covering the time stamp, or a negative interval if not found.
Type
object

wireDecode(input)

Decode the input and update this Schedule object.
Parameters:
Name Type Description
input Blob | Buffer The input buffer to decode. For Buffer, this reads from position() to limit(), but does not change the position.
Source:
Throws:
EncodingException For invalid encoding.

wireEncode() → {Blob}

Encode this Schedule.
Source:
Returns:
The encoded buffer.
Type
Blob