Constructor
new DatumStreamMetadataRegistry(metasopt)
Constructor.
Name | Type | Attributes | Description |
---|---|---|---|
metas | Array.<DatumStreamMetadata> | <optional> | optional list of metadata to start with |
Methods
addMetadata(meta) → {DatumStreamMetadata}
Add metadata to the registry.
Name | Type | Description |
---|---|---|
meta | DatumStreamMetadata | the metadata to add to the registry |
this object
- Type:
- DatumStreamMetadata
indexOfMetadataStreamId(streamId) → {number}
Get the index of the metadata with a specific stream ID.
Name | Type | Description |
---|---|---|
streamId | string | the stream ID to get the index of |
the found index, or -1
if not found
- Type:
- number
metadataAt(index) → {DatumStreamMetadata}
Get the metadata at a specific index, based on insertion order.
Name | Type | Description |
---|---|---|
index | number | the index of the metadata to get |
the metadata at the given index, or undefined
- Type:
- DatumStreamMetadata
metadataForObjectSource(objectId, sourceId) → {DatumStreamMetadata}
Get the first available metadata for a given object and source ID combination.
Name | Type | Description |
---|---|---|
objectId | number | the object ID of the metadata to get |
sourceId | string | the source ID of the metadata to get |
the associated metadata, or undefined
if none available
- Type:
- DatumStreamMetadata
metadataForStreamId(streamId) → {DatumStreamMetadata}
Get the metadta for a given stream ID.
Name | Type | Description |
---|---|---|
streamId | string | the stream ID of the metadata to get |
the associated metadata, or undefined
if none available
- Type:
- DatumStreamMetadata
metadataStreamIds() → {Set.<string>}
Get a set of all available stream IDs.
all available metadata stream ID values
- Type:
- Set.<string>
metadataStreamIdsList() → {Array.<string>}
Get a list of all available stream IDs in insertion order.
all available metadata stream ID values in the same order as added to this registry
- Type:
- Array.<string>
toJsonEncoding() → {string}
Get this object as a standard JSON encoded string value.
The returned JSON is an array of the DatumStreamMetadata#toJsonEncoding() result of all metadata in the registry. An example result looks like this:
[
{
"streamId": "7714f762-2361-4ec2-98ab-7e96807b32a6",
"zone": "Pacific/Auckland",
"kind": "n",
"objectId": 123,
"sourceId": "/power/1",
"i": ["watts", "current", "voltage", "frequency"],
"a": ["wattHours"]
},
{
"streamId": "5514f762-2361-4ec2-98ab-7e96807b3255",
"zone": "America/New_York",
"kind": "n",
"objectId": 456,
"sourceId": "/irradiance/2",
"i": ["irradiance", "temperature"],
"a": ["irradianceHours"]
}
]
the JSON encoded string
- Type:
- string
(static) fromJsonEncoding(json) → {module:util~DatumStreamMetadataRegistry}
Parse a JSON string into a DatumStreamMetadataRegistry instance.
The JSON must be encoded the same way DatumStreamMetadataRegistry#toJsonEncoding() does.
Name | Type | Description |
---|---|---|
json | string | the JSON to parse |
the stream metadata registry instance
(static) fromJsonObject(data) → {module:util~DatumStreamMetadataRegistry}
Create a registry instance from an array parsed from a JSON string of datum stream metadata objects.
The array must be structured in the same way DatumStreamMetadataRegistry#toJsonEncoding() does.
Name | Type | Description |
---|---|---|
data | array | the array data to parse |
the stream metadata registry instance