Skip to main content

Pentaho+ documentation has moved!

The new product documentation portal is here. Check it out now at docs.hitachivantara.com

 

Hitachi Vantara Lumada and Pentaho Documentation

List

pentaho.type List

The base class of plural values.

A list is an ordered set of elements of a common, base type.

AMD Module

require(["pentaho/type/List"], function(List) { /* code goes here */ });

See also: pentaho.type.Element , pentaho.type.spec.IList , pentaho.type.spec.IListType

Extends

Constructor

Name Description
new List(instSpec, keyArgs)

Creates a list instance.

Members

Name Description
$isBoundary : boolean

Gets a value that indicates if this list is a boundary list.

$isReadOnly : boolean

Gets a value that indicates if this list is read-only.

$key : string

Gets the key of the list value.

count : number

Gets the number of elements in the list.

Methods

Name Description
_configure(config)
Protected

Configures this list with a given distinct and non-Nully configuration.

_createChangeset()
_initClone()
add(fragment)

Adds one or more elements to the end of the list.

at(index) : pentaho.type.Element

Gets the element at a specified index, or null.

clear()

Removes all elements from the list.

each(fun, ctx)

Calls a function for each element of the list.

get(key) : pentaho.type.Element

Gets the element having a specified key value, if any, or null.

has(key) : boolean

Gets a value that indicates if an element with a given key is present in the list.

includes(elem) : boolean

Gets a value that indicates if a given element is present in the list.

indexOf(elem) : number

Gets the index of a given element in the list.

insert(fragment, index)

Inserts one or more elements, starting at the given index.

move(elemSpec, indexNew)

Moves an element to a new position.

remove(fragment)

Removes one or more elements from the list.

removeAt(start, count)

Removes one or more elements from the list, given the start index and the number of elements to remove.

set(fragment, keyArgs)

Adds, removes, moves and/or updates elements to the element list.

sort(comparer)

Sorts the elements of the list using the given comparer function.

toArray(map, ctx) : Array

Creates an array with the elements of the list or values derived from each element.

toSpecInContext()
validate() : Array.<pentaho.type.ValidationError>

Determines if the given list value is valid.

Constructor Details

new List(instSpec, keyArgs)

Creates a list instance.

When a derived class overrides the constructor and creates additional instance properties, the pentaho.type.List#_initClone method should also be overridden to copy those properties.

Source: javascript/web/pentaho/type/List.js, line 82

Parameters:
Name Default Value Summary
instSpec : pentaho.type.spec.List | pentaho.type.List | Array.<pentaho.type.Element>
Optional

The list specification or a compatible list instance or element's array.

keyArgs : object
Optional

The keyword arguments.

Parameters:
Name Default Value Summary
isBoundary : boolean
Optional
false

Indicates if the list should be a boundary list.

isReadOnly : boolean
Optional
false

Indicates if the list should be a read-only list.

Throws:
Name Description
pentaho.lang.ArgumentInvalidTypeError

When the type of instSpec is not Object, Array or pentaho.type.List.

See also: pentaho.type.Element , pentaho.type.spec.IList , pentaho.type.spec.IListType

Members Details

$isBoundary: boolean

Gets a value that indicates if this list is a boundary list.

A boundary list isolates the list holder from the list's elements.

The validity of a boundary list is not affected by the validity of its elements. Changes within the elements of boundary list do not bubble to it.

Source: javascript/web/pentaho/type/List.js, line 181

$isReadOnly: boolean

Gets a value that indicates if this list is read-only.

Source: javascript/web/pentaho/type/List.js, line 149

$key: string

Gets the key of the list value.

The default list implementation, returns the value of the list instance's pentaho.type.List#$uid.

Source: javascript/web/pentaho/type/List.js, line 232

count: number

Gets the number of elements in the list.

Source: javascript/web/pentaho/type/List.js, line 242

Methods Details

_configure(config)
Protected

Configures this list with a given distinct and non-Nully configuration.

This method can only be called when there is an ambient transaction.

The argument config accepts the same types of values given which a List instance can be constructed from.

An additional configuration input format is supported, the key map configuration format, in which config.d is a map from element keys to element configurations, instead of, an array of element specifications. In this case, each targeted element is individually configured with the corresponding element configuration by using its configureOrCreate method. If the latter returns a distinct element, then the original element is replaced in the list.

With all of the other configuration formats, a list of element specifications is obtained and passed to the set method.

Source: javascript/web/pentaho/type/List.js, line 564

Parameters:
Name Default Value Summary
config : pentaho.type.spec.List | pentaho.type.List | Array.<pentaho.type.Element>

The list specification or a compatible list instance or element's array.

Throws:
Name Description
pentaho.lang.ArgumentInvalidTypeError

When the type of config is not Object, Array or pentaho.type.List.

TypeError

When the list would be changed and it is read-only.

pentaho.lang.ArgumentInvalidError

When config.d is an object that contains a key which is not the key of an element in the list.

See also: pentaho.type.Value#configure , pentaho.type.List#set , pentaho.type.Complex#_configure , pentaho.type.Element#configureOrCreate

_createChangeset()

Source: javascript/web/pentaho/type/List.js, line 511

_initClone()

Source: javascript/web/pentaho/type/List.js, line 891

add(fragment)

Adds one or more elements to the end of the list.

The element or elements specified in argument fragment are converted to the list's element class.

Source: javascript/web/pentaho/type/List.js, line 348

Parameters:
Name Default Value Summary
fragment : * | Array

Value or values to add.

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

at(index) : pentaho.type.Element

Gets the element at a specified index, or null.

Source: javascript/web/pentaho/type/List.js, line 252

Parameters:
Name Default Value Summary
index : number

The desired index.

Returns:
Name Description
pentaho.type.Element

The element value or null.

clear()

Removes all elements from the list.

Source: javascript/web/pentaho/type/List.js, line 443

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

each(fun, ctx)

Calls a function for each element of the list.

Source: javascript/web/pentaho/type/List.js, line 471

Parameters:
Name Default Value Summary
fun : function

The mapping function. Return false to break iteration.

ctx : object
Optional

The JS context object on which fun is called.

get(key) : pentaho.type.Element

Gets the element having a specified key value, if any, or null.

Source: javascript/web/pentaho/type/List.js, line 299

Parameters:
Name Default Value Summary
key : string | *

The element's key.

Returns:
Name Description
pentaho.type.Element

The corresponding element or null.

has(key) : boolean

Gets a value that indicates if an element with a given key is present in the list.

Source: javascript/web/pentaho/type/List.js, line 264

Parameters:
Name Default Value Summary
key : string | *

The element's key.

Returns:
Name Description
boolean

true if an element with the given key is present in the list; false, otherwise.

includes(elem) : boolean

Gets a value that indicates if a given element is present in the list.

Source: javascript/web/pentaho/type/List.js, line 277

Parameters:
Name Default Value Summary
elem : pentaho.type.Element

The element to test.

Returns:
Name Description
boolean

true if the element is present in the list; false, otherwise.

indexOf(elem) : number

Gets the index of a given element in the list.

Source: javascript/web/pentaho/type/List.js, line 288

Parameters:
Name Default Value Summary
elem : pentaho.type.Element

The element whose index to determine.

Returns:
Name Description
number

true if the element is present in the list; false, otherwise.

insert(fragment, index)

Inserts one or more elements, starting at the given index.

If index is negative, it means the position at that many elements from the end (index' = count - index).

When the index is greater than or equal to the length of the list, the element or elements are appended to the list.

Source: javascript/web/pentaho/type/List.js, line 366

Parameters:
Name Default Value Summary
fragment : * | Array

Element or elements to add.

index : number

The index at which to start inserting new elements.

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

move(elemSpec, indexNew)

Moves an element to a new position.

Source: javascript/web/pentaho/type/List.js, line 395

Parameters:
Name Default Value Summary
elemSpec : *

An element specification.

indexNew : number

The new index of the element.

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

remove(fragment)

Removes one or more elements from the list.

Specified elements that are not present in the list are ignored.

Source: javascript/web/pentaho/type/List.js, line 380

Parameters:
Name Default Value Summary
fragment : * | Array

Element or elements to remove.

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

removeAt(start, count)

Removes one or more elements from the list, given the start index and the number of elements to remove.

If count is Nully or omitted, it defaults to 1. If count is less than 1, nothing is removed. If start is not less than the number of elements in the list, nothing is removed. If start is negative, it means to start removing that many elements from the end (start' = length - start).

Source: javascript/web/pentaho/type/List.js, line 417

Parameters:
Name Default Value Summary
start : number

The index at which to start removing.

count : number
Optional
1

The number of elements to remove.

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

set(fragment, keyArgs)

Adds, removes, moves and/or updates elements to the element list.

The element or elements specified in argument fragment are converted to the list's element class.

Source: javascript/web/pentaho/type/List.js, line 327

Parameters:
Name Default Value Summary
fragment : * | Array

The element or elements to set.

keyArgs : object
Optional

The keyword arguments.

Parameters:
Name Default Value Summary
noAdd : boolean
Optional
false

Prevents adding new elements to the list.

noRemove : boolean
Optional
false

Prevents removing elements not present in fragment from the list.

noMove : boolean
Optional
false

Prevents moving elements inside the list.

noUpdate : boolean
Optional
true

Prevents updating elements already present in the list.

index : number
Optional

The index at which to add new elements. When unspecified, new elements are appended to the list. This argument is ignored when noAdd is true.

Throws:
Name Description
TypeError

When a change would occur and the list is read-only.

sort(comparer)

Sorts the elements of the list using the given comparer function.

Source: javascript/web/pentaho/type/List.js, line 431

Parameters:
Name Default Value Summary
comparer : function

The comparer function.

Throws:
Name Description
TypeError

When the list is read-only.

toArray(map, ctx) : Array

Creates an array with the elements of the list or values derived from each element.

Source: javascript/web/pentaho/type/List.js, line 458

Parameters:
Name Default Value Summary
map : function
Optional

A function that converts each element into something else.

ctx : object
Optional

The JS context object on which to call map.

Returns:
Name Description
Array

An array of elements.

toSpecInContext()

Source: javascript/web/pentaho/type/List.js, line 607

validate() : Array.<pentaho.type.ValidationError>

Determines if the given list value is valid.

The default implementation validates each element against the list's element type and collects and returns any reported errors. Override to complement with a type's specific validation logic.

You can use the error utilities in pentaho.type.Util to help in the implementation.

Source: javascript/web/pentaho/type/List.js, line 658

Returns:
Name Description
Array.<pentaho.type.ValidationError>

A non-empty array of errors or null.