public class JSArray<T> extends JSBaseArray<T>
Modifier and Type | Class and Description |
---|---|
static interface |
JSArray.EachBooleanCallback<T>
Interface containing a condition test callback function
|
class |
JSArray.EntriesIterator<U>
An array entry Iterator
|
static interface |
JSArray.ForEachCallback<T>
Interface containing a function to call on each element of an array
|
class |
JSArray.KeysIterator
An array key Iterator
|
static interface |
JSArray.MapCallback<T>
Interface containing a map function
|
static interface |
JSArray.ReduceCallback
Interface containing a reduce function
|
static interface |
JSArray.SortCallback<T>
Interface containing a compare function callback for sort
|
JSObject.jsexport, JSObject.Property<T>
JSPropertyAttributeDontDelete, JSPropertyAttributeDontEnum, JSPropertyAttributeNone, JSPropertyAttributeReadOnly
Constructor and Description |
---|
JSArray(JSContext ctx,
java.lang.Class<T> cls)
Creates an empty JavaScript array object
|
JSArray(JSContext ctx,
java.util.Collection list,
java.lang.Class<T> cls)
Creates a JavaScript array object, initialized with 'list' Java values
|
JSArray(JSContext ctx,
JSValue[] array,
java.lang.Class<T> cls)
Creates a JavaScript array object, initialized with 'array' JSValues
|
JSArray(JSContext ctx,
java.lang.Object[] array,
java.lang.Class<T> cls)
Creates a JavaScript array object, initialized with 'array' Java values
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
T element) |
JSArray<T> |
concat(java.lang.Object... params)
JavaScript Array.prototype.concat(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
|
JSArray<T> |
copyWithin(int target)
JavaScript Array.prototype.copyWithin(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin
|
JSArray<T> |
copyWithin(int target,
int start)
JavaScript Array.prototype.copyWithin(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin
|
JSArray<T> |
copyWithin(int target,
int start,
int end)
JavaScript Array.prototype.copyWithin(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin
|
JSArray.EntriesIterator<T> |
entries()
JavaScript Array.prototype.entries(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries
|
boolean |
every(JSArray.EachBooleanCallback<T> callback)
JavaScript: Array.prototype.every(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
|
boolean |
every(JSFunction callback)
JavaScript: Array.prototype.every(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
|
boolean |
every(JSFunction callback,
JSObject thiz)
JavaScript: Array.prototype.every(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
|
JSArray<T> |
fill(T value)
JavaScript Array.prototype.fill(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
|
JSArray<T> |
fill(T value,
int start)
JavaScript Array.prototype.fill(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
|
JSArray<T> |
fill(T value,
int start,
int end)
JavaScript Array.prototype.fill(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
|
JSArray<T> |
filter(JSArray.EachBooleanCallback<T> callback) |
JSArray<T> |
filter(JSFunction callback)
JavaScript Array.prototype.filter(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
|
JSArray<T> |
filter(JSFunction callback,
JSObject thiz)
JavaScript Array.prototype.filter(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
|
T |
find(JSArray.EachBooleanCallback<T> callback)
JavaScript Array.prototype.find(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
T |
find(JSFunction callback)
JavaScript Array.prototype.find(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
T |
find(JSFunction callback,
JSObject thiz)
JavaScript Array.prototype.find(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
int |
findIndex(JSArray.EachBooleanCallback<T> callback)
JavaScript Array.prototype.findIndex(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
|
int |
findIndex(JSFunction callback)
JavaScript Array.prototype.findIndex(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
|
int |
findIndex(JSFunction callback,
JSObject thiz)
JavaScript Array.prototype.findIndex(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
|
void |
forEach(JSArray.ForEachCallback<T> callback)
JavaScript Array.prototype.forEach(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
|
void |
forEach(JSFunction callback)
JavaScript Array.prototype.forEach(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
|
void |
forEach(JSFunction callback,
JSObject thiz)
JavaScript Array.prototype.forEach(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
|
static JSArray<JSValue> |
from(JSContext ctx,
java.lang.Object arrayLike)
JavaScript Array.from(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
|
static JSArray<JSValue> |
from(JSContext ctx,
java.lang.Object arrayLike,
JSArray.MapCallback<JSValue> mapFn)
JavaScript Array.from(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
|
static JSArray<JSValue> |
from(JSContext ctx,
java.lang.Object arrayLike,
JSFunction mapFn)
JavaScript Array.from(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
|
static JSArray<JSValue> |
from(JSContext ctx,
java.lang.Object arrayLike,
JSFunction mapFn,
JSObject thiz)
JavaScript Array.from(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
|
boolean |
includes(T element)
JavaScript Array.prototype.includes(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
|
boolean |
includes(T element,
int fromIndex)
JavaScript Array.prototype.includes(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
|
int |
indexOf(T element,
int fromIndex)
JavaScript Array.prototype.indexOf(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
|
static boolean |
isArray(JSValue value)
JavaScript Array.isArray(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
java.lang.String |
join()
JavaScript Array.prototype.join(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
|
java.lang.String |
join(java.lang.String separator)
JavaScript Array.prototype.join(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
|
JSArray.KeysIterator |
keys()
JavaScript Array.prototype.keys(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys
|
int |
lastIndexOf(T element,
int fromIndex)
JavaScript Array.prototype.lastIndexOf(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
|
JSArray<JSValue> |
map(JSArray.MapCallback<T> callback)
JavaScript Array.prototype.map(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
|
JSArray<JSValue> |
map(JSFunction callback)
JavaScript Array.prototype.map(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
|
JSArray<JSValue> |
map(JSFunction callback,
JSObject thiz)
JavaScript Array.prototype.map(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
|
static JSArray<JSValue> |
of(JSContext ctx,
java.lang.Object... params)
JavaScript Array.of(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of
|
T |
pop()
JavaScript Array.prototype.pop(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
|
int |
push(T... elements)
JavaScript Array.prototype.push(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
|
JSValue |
reduce(JSArray.ReduceCallback callback)
JavaScript Array.prototype.reduce(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
|
JSValue |
reduce(JSArray.ReduceCallback callback,
java.lang.Object initialValue)
JavaScript Array.prototype.reduce(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
|
JSValue |
reduce(JSFunction callback)
JavaScript Array.prototype.reduce(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
|
JSValue |
reduce(JSFunction callback,
java.lang.Object initialValue)
JavaScript Array.prototype.reduce(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
|
JSValue |
reduceRight(JSArray.ReduceCallback callback)
JavaScript Array.prototype.reduceRight(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
|
JSValue |
reduceRight(JSArray.ReduceCallback callback,
java.lang.Object initialValue)
JavaScript Array.prototype.reduceRight(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
|
JSValue |
reduceRight(JSFunction callback)
JavaScript Array.prototype.reduceRight(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
|
JSValue |
reduceRight(JSFunction callback,
java.lang.Object initialValue)
JavaScript Array.prototype.reduceRight(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
|
T |
remove(int index) |
JSArray<T> |
reverse()
JavaScript Array.prototype.reverse(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
|
T |
shift()
JavaScript Array.prototype.shift(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
|
JSArray<T> |
slice()
JavaScript Array.prototype.slice(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
|
JSArray<T> |
slice(int begin)
JavaScript Array.prototype.slice(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
|
JSArray<T> |
slice(int begin,
int end)
JavaScript Array.prototype.slice(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
|
boolean |
some(JSArray.EachBooleanCallback<T> callback)
JavaScript: Array.prototype.some(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
|
boolean |
some(JSFunction callback)
JavaScript: Array.prototype.some(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
|
boolean |
some(JSFunction callback,
JSObject thiz)
JavaScript: Array.prototype.some(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
|
JSArray<T> |
sort()
JavaScript Array.prototype.sort(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
|
JSArray<T> |
sort(JSArray.SortCallback<T> callback)
JavaScript Array.prototype.sort(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
|
JSArray<T> |
sort(JSFunction compare)
JavaScript Array.prototype.sort(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
|
JSArray<T> |
splice(int start,
int deleteCount,
T... elements)
JavaScript Array.prototype.splice(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
|
java.util.List<T> |
subList(int fromIndex,
int toIndex) |
java.lang.String |
toLocaleString()
JavaScript Array.prototype.toLocaleString(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString
Note: AndroidJSCore does not include the localization library by default, as it adds too
much data to the build.
|
int |
unshift(T... elements)
JavaScript Array.prototype.unshift(), see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
|
add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, set, size, toArray, toArray, toArray
apply, call, call, newInstance
__nullFunc, deleteProperty, getThis, hasProperty, isConstructor, isFunction, property, property, property, propertyAtIndex, propertyAtIndex, propertyNames, prototype, prototype
getContext, isArray, isBoolean, isDate, isEqual, isFloat32Array, isFloat64Array, isInstanceOfConstructor, isInt16Array, isInt32Array, isInt8Array, isNull, isNumber, isObject, isStrictEqual, isString, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, toBoolean, toFunction, toJSArray, toJSON, toNumber, toObject, toString, valueHash, valueRef
public JSArray(JSContext ctx, JSValue[] array, java.lang.Class<T> cls)
ctx
- The JSContext to create the array inarray
- An array of JSValues with which to initialize the JavaScript array objectcls
- The class of the component objectspublic JSArray(JSContext ctx, java.lang.Class<T> cls)
ctx
- The JSContext to create the array incls
- The class of the component objectspublic JSArray(JSContext ctx, java.lang.Object[] array, java.lang.Class<T> cls)
ctx
- The JSContext to create the array inarray
- An array of Java objects with which to initialize the JavaScript array object. Each
Object will be converted to a JSValuecls
- The class of the component objectspublic JSArray(JSContext ctx, java.util.Collection list, java.lang.Class<T> cls)
ctx
- The JSContext to create the array inlist
- The Collection of values with which to initialize the JavaScript array object. Each
object will be converted to a JSValuecls
- The class of the component objectspublic void add(int index, T element)
add
in interface java.util.List<T>
add
in class JSBaseArray<T>
List.add(int, Object)
public T remove(int index)
remove
in interface java.util.List<T>
remove
in class JSBaseArray<T>
List.remove(int)
@NonNull public java.util.List<T> subList(int fromIndex, int toIndex)
List.subList(int, int)
public static JSArray<JSValue> from(JSContext ctx, java.lang.Object arrayLike, JSFunction mapFn, JSObject thiz)
ctx
- the JavaScript context in which to create the arrayarrayLike
- Any array-like object to build the array frommapFn
- A JavaScript function to map each new element of the arraythiz
- The 'this' pointer passed to 'mapFn'public static JSArray<JSValue> from(JSContext ctx, java.lang.Object arrayLike, JSFunction mapFn)
ctx
- the JavaScript context in which to create the arrayarrayLike
- Any array-like object to build the array frommapFn
- A JavaScript function to map each new element of the arraypublic static JSArray<JSValue> from(JSContext ctx, java.lang.Object arrayLike)
ctx
- the JavaScript context in which to create the arrayarrayLike
- Any array-like object to build the array frompublic static JSArray<JSValue> from(JSContext ctx, java.lang.Object arrayLike, JSArray.MapCallback<JSValue> mapFn)
ctx
- the JavaScript context in which to create the arrayarrayLike
- Any array-like object to build the array frommapFn
- A Java function to map each new element of the arraypublic static boolean isArray(JSValue value)
value
- the value to testpublic static JSArray<JSValue> of(JSContext ctx, java.lang.Object... params)
ctx
- The JSContext in which to create the arrayparams
- Elements to add to the arraypublic JSArray<T> concat(java.lang.Object... params)
params
- values to concantenate to the arraypublic T pop()
public int push(T... elements)
elements
- The elements to push on the arraypublic T shift()
public JSArray<T> splice(int start, int deleteCount, T... elements)
start
- the index to start splicing from (inclusive)deleteCount
- the number of elements to removeelements
- the elements to insert into the array at index 'start'public java.lang.String toLocaleString()
public int unshift(T... elements)
elements
- The values to add to the front of the arraypublic JSArray.EntriesIterator<T> entries()
public boolean every(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic boolean every(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic boolean every(JSArray.EachBooleanCallback<T> callback)
callback
- the Java function to call on each elementpublic T find(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic T find(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic T find(JSArray.EachBooleanCallback<T> callback)
callback
- the Java function to call on each elementpublic int findIndex(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic int findIndex(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic int findIndex(JSArray.EachBooleanCallback<T> callback)
callback
- the Java function to call on each elementpublic void forEach(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic void forEach(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic void forEach(JSArray.ForEachCallback<T> callback)
callback
- the Java function to call on each elementpublic boolean includes(T element, int fromIndex)
element
- the value to search forfromIndex
- the index in the array to start searching frompublic boolean includes(T element)
element
- the value to search forpublic int indexOf(T element, int fromIndex)
element
- the value to search forfromIndex
- the index in the array to start searching frompublic java.lang.String join(java.lang.String separator)
separator
- the separator to use between valuespublic java.lang.String join()
public JSArray.KeysIterator keys()
public int lastIndexOf(T element, int fromIndex)
element
- the value to search forfromIndex
- the index in the array to start searching from (reverse order)public JSValue reduce(JSFunction callback, java.lang.Object initialValue)
callback
- The JavaScript reduce function to callinitialValue
- The initial value of the reductionpublic JSValue reduce(JSFunction callback)
callback
- The JavaScript reduce function to callpublic JSValue reduce(JSArray.ReduceCallback callback, java.lang.Object initialValue)
callback
- The Java reduce function to callinitialValue
- The initial value of the reductionpublic JSValue reduce(JSArray.ReduceCallback callback)
callback
- The Java reduce function to callpublic JSValue reduceRight(JSFunction callback, java.lang.Object initialValue)
callback
- The JavaScript reduce function to callinitialValue
- The initial value of the reductionpublic JSValue reduceRight(JSFunction callback)
callback
- The JavaScript reduce function to callpublic JSValue reduceRight(JSArray.ReduceCallback callback, java.lang.Object initialValue)
callback
- The Java reduce function to callinitialValue
- The initial value of the reductionpublic JSValue reduceRight(JSArray.ReduceCallback callback)
callback
- The Java reduce function to callpublic boolean some(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic boolean some(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic boolean some(JSArray.EachBooleanCallback<T> callback)
callback
- the Java function to call on each elementpublic JSArray<T> copyWithin(int target, int start, int end)
target
- index to copy sequence tostart
- index from which to start copying fromend
- index from which to end copying frompublic JSArray<T> copyWithin(int target, int start)
target
- index to copy sequence tostart
- index from which to start copying frompublic JSArray<T> copyWithin(int target)
target
- index to copy sequence topublic JSArray<T> fill(T value, int start, int end)
value
- the value to fillstart
- the index to start fillingend
- the index (exclusive) to stop fillingpublic JSArray<T> fill(T value, int start)
value
- the value to fillstart
- the index to start fillingpublic JSArray<T> fill(T value)
value
- the value to fillpublic JSArray<T> filter(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic JSArray<T> filter(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic JSArray<T> filter(JSArray.EachBooleanCallback<T> callback)
public JSArray<JSValue> map(JSFunction callback, JSObject thiz)
callback
- the JavaScript function to call on each elementthiz
- the 'this' value passed to callbackpublic JSArray<JSValue> map(JSFunction callback)
callback
- the JavaScript function to call on each elementpublic JSArray<JSValue> map(JSArray.MapCallback<T> callback)
callback
- the Java function to call on each elementpublic JSArray<T> reverse()
public JSArray<T> slice(int begin, int end)
begin
- the index to begin slicing (inclusive)end
- the index to end slicing (exclusive)public JSArray<T> slice(int begin)
begin
- the index to begin slicing (inclusive)public JSArray<T> slice()
public JSArray<T> sort(JSFunction compare)
compare
- the JavaScript compare function to use for sortingpublic JSArray<T> sort(JSArray.SortCallback<T> callback)
callback
- the Java compare function to use for sorting