API / geotoolkit / data / DataObject / DataObject
data.DataObject.DataObject
Define base data object
↳
DataObject
Constructors
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
name | string | Name |
type | string | Type |
uri | string | Unique resource identifier |
Methods
▸ addChild(data): DataObject
Add a child object
| Name | Type | Description |
|---|---|---|
data | DataObject | DataObject[] | the child data to be added |
this
▸ addProperties(properties): DataObject
Add additional properties
| Name | Type | Description |
|---|---|---|
properties | Record<string, any> | additional properties of the dataobject |
this
▸ clearChildren(): DataObject
Remove all child data
this
▸ clone(copyData?): DataObject
All subclasses should override copyConstructor or provide custom implementation for this method
| Name | Type | Description |
|---|---|---|
Optional copyData | boolean | flag to copy data |
clone
▸ Protected copyConstructor(src): DataObject
Copy constructor function.
Function used as part of the cloning mechanism.
Implementations should copy the given instance state to this instance.
| Name | Type | Description |
|---|---|---|
src | DataObject | Source to copy from |
this
▸ dispose(): void
Dispose data object and all children. Clear all listeners
void
▸ getChild(i): DataObject
Return data by index
| Name | Type | Description |
|---|---|---|
i | number | index of the data |
child
▸ getChildren(filter?): Iterator<DataObject>
Return iterator by child data objects
| Name | Type | Description |
|---|---|---|
Optional filter | (data: DataObject) => boolean | a filter function. Returns all child data objects if the value is null. |
▸ getChildrenCount(): number
Return number of child data
number
▸ getClassName(): string
string
▸ getName(): string
Returns data object name
string
▸ getParent(): DataObject
Gets parent data item
▸ getProperties(): OptionsOut
Gets all the properties pertaining to this object
JSON options object
▸ getProperty(name): any
Gets property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
any
▸ getType(): string
Returns data type
string
▸ getUri(): string
Returns unique resource identifier
string
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
EventDispatcher.hasEventListener
▸ hasProperty(name): boolean
Returns whether data object contains specific property
| Name | Type | Description |
|---|---|---|
name | string | property name |
boolean
▸ indexOfChild(data): number
Return index of child data ( index of the specified child or -1 if data is not found)
| Name | Type | Description |
|---|---|---|
data | DataObject | data object to check index |
number
▸ insertChild(index, item, silent?): DataObject
Insert item by index
| Name | Type | Description |
|---|---|---|
index | number | specified index |
item | DataObject | node |
Optional silent | boolean | will not fire any events if true |
this
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): DataObject
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | DataObject | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(type?, callback?): DataObject
Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: DataObject, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): DataObject
Attach listener on event that will be called whenever the specified event is delivered to the target
If the callback function is already in the list of event listeners for this target, the function is not added a second time.
If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: DataObject, args: EventMap[E]) => void | to be called |
this
▸ onPropertyChanged(prop): DataObject
This method is called if property bag is changed using setProperty method
| Name | Type | Description |
|---|---|---|
prop | Object | property |
prop.name | string | |
prop.value | any |
this
▸ query(): QueryBuilder<any>
Query data item and child items by different conditions
Example
// Select by function
import {DataObject} from '@int/geotoolkit/data/DataObject';
const dataobject = new DataObject({'name': 'test', 'uri': 'testuri', 'type': 'testtype'});
const item1 = new DataObject({'name': 'item1', 'uri': 'item1', 'type': 'test'});
const item2 = new DataObject({'name': 'item2', 'uri': 'item2', 'type': 'test'});
dataobject.addChild([item1, item2]);
const item5 = new DataObject({'name': 'item5', 'uri': 'item5', 'type': 'test'});
item2.addChild(item5);
let founditem = null;
dataobject.query()
.where( (item: DataObject) => item.getParent() === dataobject)
.where( (item: DataObject) => item.getUri() === 'item2')
.select((item: DataObject) => {
founditem = item;
});Example
// Select by expression
dataobject.query()
.where( 'item => uri(item) == "item5"')
.select((item: DataObject) => {
founditem = item;
});QueryBuilder<any>
query object which has methods 'where' tp specify conditions, 'select' to run query, 'selectToArray' select results to array Expressions syntax: "item => expression", where expression:
- logical and arithmetic operators
- embedded functions: name(item) - gets name of the data object url(item) - gets url of the data object type(item) - gets type of the data object
▸ removeChild(data, silent?): DataObject
Remove child data object
| Name | Type | Description |
|---|---|---|
data | DataObject | data object to be removed |
Optional silent | boolean | will not fire any events if true |
this
▸ set(index, item): DataObject
Sets item by index
| Name | Type | Description |
|---|---|---|
index | number | index of the item |
item | DataObject | node |
▸ setName(name): DataObject
Sets data object name
| Name | Type | Description |
|---|---|---|
name | string | data object name |
this
▸ setParent(parent): DataObject
Sets parent data item
| Name | Type | Description |
|---|---|---|
parent | DataObject | parent data item |
this
▸ setProperties(properties?): DataObject
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | JSON options object |
this
▸ setProperty(name, value): DataObject
Sets property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
value | any | property value |
this
▸ setSilent(bool): DataObject
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ setType(type): DataObject
Sets data object type
| Name | Type | Description |
|---|---|---|
type | string | data type |
this
▸ setUri(uri): DataObject
Sets unique resource identifier
| Name | Type | Description |
|---|---|---|
uri | string | unique identifier |
this
▸ Static getClassName(): string
string