|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.data.Value
oscript.data.OObject
oscript.data.OArray
An array instance.
Field Summary | |
Value |
concat
Join this array object with one or more additional arrays. |
static java.lang.String[] |
MEMBER_NAMES
|
static java.lang.String |
PARENT_TYPE_NAME
|
Value |
push
Add one or more elements to the end of the array, returning the new length. |
Value |
splice
Add and remove elements from an array |
static Value |
TYPE
The type object for an instance of Array. |
static java.lang.String |
TYPE_NAME
|
Value |
unshift
Add one or more elements to the beginning of the array, returning the new length. |
Fields inherited from class oscript.data.OObject |
EMPTY_EXPR_LIST_EVALUATOR |
Fields inherited from class oscript.data.Value |
DEBUG, NULL, UNDEFINED |
Constructor Summary | |
OArray()
Class Constructor. |
|
OArray(int initialLength)
private constructor, used internally and by compiler... |
|
OArray(MemberTable args)
Class Constructor. |
|
OArray(Reference[] arr,
int size)
Class Constructor. |
|
OArray(Value[] args)
Class Constructor. |
Method Summary | |
java.lang.Object |
castToJavaObject()
Convert this object to a native java Object value. |
java.lang.String |
castToString()
Convert this object to a native java String value. |
Value |
elementAt(int idx)
|
Value |
elementAt(Value idx)
Get the specified index of this object, if this object is an array. |
Value |
elementsAt(int idx1,
int idx2)
|
Value |
elementsAt(Value idx1,
Value idx2)
Get the specified range of this object, if this object is an array. |
void |
ensureCapacity(int sz)
Ensure that the member-table has sufficient capacity to accomodate the index sz . |
Value |
every(Value fxn)
Executes the provided function fxn once for each element
present in the array until it finds one where callback returns
false . |
Value |
filter(Value fxn)
Create a new array with all elements that pass the test implemented by the provided function. |
void |
forEach(Value fxn)
Executes a provided function once per array element. |
void |
free()
Indication from creator of member-table that resources allocated from the stack are no longer needed and should be released. |
protected Value |
getTypeImpl()
Get the type of this object. |
java.util.Iterator |
iterator()
Get an iterator of all the elements of this array. |
Value |
join()
Join all elements in the array into a single string, separated by commas |
Value |
join(Value separator)
Join all elements in the array into a single string, separated by the specified separator. |
int |
length()
For types that implement elementAt , this returns the
number of elements. |
static OArray |
makeArray(java.lang.Object arrObject)
|
Value |
map(Value fxn)
Creates a new array with the results of calling a provided function on every element in this array. |
Value |
pop()
Remove and return the last element of the array. |
void |
push1(Value val)
Push a single parameter into the table. |
void |
push2(Value val1,
Value val2)
Push two values into the table. |
void |
push3(Value val1,
Value val2,
Value val3)
Push three values into the table. |
void |
push4(Value val1,
Value val2,
Value val3,
Value val4)
Push four values into the table. |
void |
readExternal(java.io.ObjectInput in)
Derived class that implements Externalizable must
call this if it overrides it. |
Reference |
referenceAt(int idx)
Return the reference at the specified index. |
Reference |
referenceAt(int idx,
int attr)
|
void |
reset()
An indication from the creator of the member-table that, while the table itself is still required, the references referred to by the table are no longer required and can be freed. |
Value |
reverse()
Reverse the order of elements in this array, returning this array. |
MemberTable |
safeCopy()
Indication to the member-table that a "safe" copy is required. |
Value |
shift()
Remove and return the first element of the array. |
Value |
slice(Value begin)
Slice out a section of the array. |
Value |
slice(Value begin,
Value end)
Slice out a section of the array. |
Value |
some(Value fxn)
Tests whether some element in the array passes the test implemented by the provided function. |
Value |
sort()
Sort the elements in the array, by converting each element to string, and sorting in ascending order. |
Value |
sort(Value fxn)
Sort the elements in the array, by using the specified comparision function. |
void |
writeExternal(java.io.ObjectOutput out)
Derived class that implements Externalizable must
call this if it overrides it. |
Methods inherited from class oscript.data.OObject |
getMember, populateMemberSet |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Value TYPE
public static final java.lang.String PARENT_TYPE_NAME
public static final java.lang.String TYPE_NAME
public static final java.lang.String[] MEMBER_NAMES
public final Value concat
public final Value splice
public final Value push
public final Value unshift
Constructor Detail |
public OArray()
public OArray(int initialLength)
public OArray(Reference[] arr, int size)
public OArray(MemberTable args)
BuiltinType
instance.
args
- arguments to this constructor
PackagedScriptObjectException(Exception)
- if wrong number of argspublic OArray(Value[] args)
BuiltinType
instance.
args
- arguments to this constructor
PackagedScriptObjectException(Exception)
- if wrong number of argsMethod Detail |
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
Externalizable
must
call this if it overrides it. It should override it to save/restore
it's own state.
readExternal
in interface java.io.Externalizable
readExternal
in class Value
java.io.IOException
java.lang.ClassNotFoundException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
Externalizable
must
call this if it overrides it. It should override it to save/restore
it's own state.
writeExternal
in interface java.io.Externalizable
writeExternal
in class Value
java.io.IOException
public static final OArray makeArray(java.lang.Object arrObject)
protected Value getTypeImpl()
Value.getType()
.
getTypeImpl
in class OObject
public java.lang.String castToString() throws PackagedScriptObjectException
String
value.
castToString
in class OObject
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public java.lang.Object castToJavaObject() throws PackagedScriptObjectException
Object
value.
castToJavaObject
in class Value
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public int length() throws PackagedScriptObjectException
elementAt
, this returns the
number of elements. This is the same as the length property
of an object.
length
in interface MemberTable
length
in class Value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
elementAt(oscript.data.Value)
public Value elementAt(Value idx) throws PackagedScriptObjectException
elementAt
in class Value
idx
- the index to get
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
length()
public Value elementAt(int idx)
public final Reference referenceAt(int idx)
MemberTable
MemberTable.ensureCapacity(int)
to ensure the array has sufficient capacity
before dereferencing an index into the table which is not known to exist.
referenceAt
in interface MemberTable
idx
- an index into the member-table
public final Reference referenceAt(int idx, int attr)
public final void ensureCapacity(int sz)
MemberTable
sz
. Grow the array, if necessary.
ensureCapacity
in interface MemberTable
sz
- the requested table sizepublic Value elementsAt(Value idx1, Value idx2) throws PackagedScriptObjectException
elementsAt
in class Value
idx1
- the index index of the beginning of the range, inclusiveidx2
- the index of the end of the range, inclusive
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
length()
,
elementAt(oscript.data.Value)
public Value elementsAt(int idx1, int idx2)
public java.util.Iterator iterator()
public Value join()
public Value join(Value separator)
separator
- the separator string
public Value slice(Value begin)
arr[begin..
arr.length()-1]
. The index can be negative, in which case it
will count from the end of the array.
begin
- the begin index, inclusive
public Value slice(Value begin, Value end)
arr[begin..
end-1]
. Either index can be negative, in which case it
will count from the end of the array.
begin
- the begin index, inclusiveend
- the end index, exclusive
public Value pop()
public Value shift()
public Value reverse()
public Value every(Value fxn)
fxn
once for each element
present in the array until it finds one where callback returns
false
. If such an element is found, the test aborts and
false
is returned, otherwise (callback returned
true
for each of the elements) every will return
true
. This array is not mutated.
fxn
- invoked with three arguments: the value of the element,
the index of the element, and the array object containing the
element; should return true
or false
true
if every element passes the test, otherwise
false
public Value some(Value fxn)
true
. If such an element is found, the test aborts and
true
is returned, otherwise (callback returned
false
for each of the elements) return false
.
fxn
- invoked with three arguments: the value of the element,
the index of the element, and the array object containing the
element; should return true
or false
true
if some element passes the test, otherwise
false
public Value filter(Value fxn)
true
. Elements for which the callback returns
false
are skipped. This array is not mutated.
fxn
- invoked with three arguments: the value of the element,
the index of the element, and the array object containing the
element; should return true
or false
public Value map(Value fxn)
fxn
- invoked with three arguments: the value of the element,
the index of the element, and the array object containing the
element
public void forEach(Value fxn)
fxn
- invoked with three arguments: the value of the element,
the index of the element, and the array object containing the
elementpublic Value sort()
public Value sort(Value fxn)
function(a,b)
should return
less than zero if a is less than b, zero if they
are equal, and greater than zero if a is greater than
b. The array is sorted in place.
fxn
- the comparasion function
public MemberTable safeCopy()
MemberTable
MemberTable.free()
is called.
safeCopy
in interface MemberTable
public void push1(Value val)
MemberTable
push1
in interface MemberTable
val
- the value to pushpublic void push2(Value val1, Value val2)
MemberTable
push2
in interface MemberTable
val1
- the value to pushval2
- the value to pushpublic void push3(Value val1, Value val2, Value val3)
MemberTable
push3
in interface MemberTable
val1
- the value to pushval2
- the value to pushval3
- the value to pushpublic void push4(Value val1, Value val2, Value val3, Value val4)
MemberTable
push4
in interface MemberTable
val1
- the value to pushval2
- the value to pushval3
- the value to pushval4
- the value to pushpublic void reset()
MemberTable
reset
in interface MemberTable
public void free()
MemberTable
MemberTable.safeCopy()
.)
free
in interface MemberTable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |