|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.script.Scriptable
net.rim.device.api.script.ScriptableImpl
public class ScriptableImpl
A convenience class providing an easy-to-use Scriptable
implementation
with elements and fields.
This class uses Hashtables internally to store elements and fields, providing a "push" wrapper
around the "pull" model Scriptable
base class. Instead of subclassing
Scriptable
for every single scriptable object, it may be easier
to simply instantiate a ScriptableImpl
, populate it with the required fields,
and never have to worry about it again. This is particularly true for objects whose
fields don't change dynamically very often.
Field Summary |
---|
Fields inherited from class net.rim.device.api.script.Scriptable |
---|
UNDEFINED |
Constructor Summary | ||
---|---|---|
ScriptableImpl()
Constructor. |
Method Summary | ||
---|---|---|
void |
enumerateFields(Vector v)
Provides a list of elements and fields pushed into this object. |
|
Object |
getElement(int index)
Gets an element pushed into this object. |
|
int |
getElementCount()
Returns the number of elements that have been pushed into this object. |
|
protected int |
getElementLength()
This method calculates the element length of the object. |
|
Object |
getField(String name)
Gets a field pushed into this object. |
|
boolean |
putElement(int index,
Object value)
Pushes an element into this object. |
|
boolean |
putField(String name,
Object value)
Pushes a field into this object. |
|
void |
removeElement(int index)
Removes a pushed element from this object. |
|
void |
removeField(String name)
Removes a pushed field from this object. |
Methods inherited from class net.rim.device.api.script.Scriptable |
---|
getParent |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScriptableImpl()
ScriptableImpl
object.
Method Detail |
---|
public void enumerateFields(Vector v)
put
method and adds the field names to the provided
Vector
.
enumerateFields
in class Scriptable
v
- The vector to which the names should be added. This must not be null
.Scriptable.enumerateFields(Vector)
public Object getField(String name)
put
method. If no field with the given name was pushed, it returns UNDEFINED
.
getElementCount
method. The special-casing of the
length field is provided as a convenience to users of this class.
getField
in class Scriptable
name
- The name of the field being requested. This must not be null
.
null
.Scriptable.getField(String)
public boolean putField(String name, Object value)
true
.
putField
in class Scriptable
name
- The name of the field being modified. This must not be null
.value
- The value that the caller wishes to set as the field value. This
may be null
.
true
if the field mutation was handled, or false
if the caller should handle it instead.Scriptable.putField(String,Object)
public int getElementCount()
getElement
will return something other than UNDEFINED
.
getElementCount
in class Scriptable
Scriptable.getElementCount()
public Object getElement(int index)
putElement
method. If no element
was pushed at the given index, it returns UNDEFINED
.
getElement
in class Scriptable
index
- The index of the element being requested. This may be any integer,
including negative values.
null
.Scriptable.getElement(int)
public boolean putElement(int index, Object value)
true
.
putElement
in class Scriptable
index
- The index of the element being modified. This may be any integer,
including negative values.value
- The value that the caller wishes to set as the element value. This
may be null
.
true
if the element mutation was handled, or false
if the caller should handle it instead.Scriptable.putElement(int,Object)
public void removeField(String name)
getField
with the same name
parameter will return UNDEFINED
,
until some other value is pushed into this object with the same field name.
name
- The name of the field to remove. This must not be null
.public void removeElement(int index)
getElement
with the same index
parameter will return UNDEFINED
,
until some other value is pushed into this object for that index.
index
- The index of the element to remove.protected final int getElementLength()
getField
documentation for the definition of the
element length.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal