Package com.yahoo.slime
Interface Cursor
- All Superinterfaces:
Inspector
Interface for read-write access to any value or object that is part
of a Slime. All accessors (including meta-data) are inherited from
the Inspector interface. The navigational methods also work the
same, except that they return a new Cursor for contained values and
sub-structures, to permit writes to embedded values.
The write operations are adding a new entry (to arrays), or setting
a field value (for objects). If adding an entry or setting a field
cannot be performed for any reason, an invalid Cursor is returned.
This could happen because the current cursor is invalid, or it's
not connected to an array value (for add methods), or it's not
connected to an object (for set methods). Also note that you can
only set() a field once; you cannot overwrite the field in any way.
- Author:
- havardpe
-
Method Summary
Modifier and TypeMethodDescriptionaddArray()
Appends an array entry containing a new value of ARRAY type.addBool
(boolean bit) Appends an array entry containing a new value of BOOL type.addData
(byte[] data) Add a new entry of DATA type to an array.addDouble
(double d) Adds a new entry of DOUBLE type to an array.addLong
(long l) Adds a new entry of LONG type to an array.addNix()
Appends an array entry containing a new value of NIX type.Appends an array entry containing a new value of OBJECT type.addString
(byte[] utf8) Add a new entry of STRING type to an array.Add a new entry of STRING type to an array.entry
(int idx) Accesses an array entry.field
(int sym) Accesses a field in an object by symbol id.Accesses a field in an object by symbol name.setArray
(int sym) Sets a field (identified with a symbol id) to contain a new value of ARRAY type.Sets a field (identified with a symbol name) to contain a new value of ARRAY type.setBool
(int sym, boolean bit) Sets a field (identified with a symbol id) to contain a new value of BOOL type.Sets a field (identified with a symbol name) to contain a new value of BOOL type.setData
(int sym, byte[] data) Sets a field (identified with a symbol id) to contain a new value of BOOL type.Sets a field (identified with a symbol name) to contain a new value of DATA type.setDouble
(int sym, double d) Sets a field (identified with a symbol id) to contain a new value of BOOL type.Sets a field (identified with a symbol name) to contain a new value of DOUBLE type.setLong
(int sym, long l) Sets a field (identified with a symbol id) to contain a new value of BOOL type.Sets a field (identified with a symbol name) to contain a new value of LONG type.setNix
(int sym) Sets a field (identified with a symbol id) to contain a new value of NIX type.Sets a field (identified with a symbol name) to contain a new value of NIX type.setObject
(int sym) Sets a field (identified with a symbol id) to contain a new value of OBJECT type.Sets a field (identified with a symbol name) to contain a new value of OBJECT type.setString
(int sym, byte[] utf8) Sets a field (identified with a symbol id) to contain a new value of BOOL type.Sets a field (identified with a symbol id) to contain a new value of BOOL type.Sets a field (identified with a symbol name) to contain a new value of STRING type.Sets a field (identified with a symbol name) to contain a new value of STRING type.
-
Method Details
-
entry
Accesses an array entry. If the current Cursor doesn't connect to an array value, or the given array index is out of bounds, the returned Cursor will be invalid. -
field
Accesses a field in an object by symbol id. If the current Cursor doesn't connect to an object value, or the object value does not contain a field with the given symbol id, the returned Cursor will be invalid. -
field
Accesses a field in an object by symbol name. If the current Cursor doesn't connect to an object value, or the object value does not contain a field with the given symbol name, the returned Cursor will be invalid. -
addNix
Cursor addNix()Appends an array entry containing a new value of NIX type. Returns an invalid Cursor if unsuccessful.- Returns:
- a valid Cursor referencing the new entry value if successful
-
addBool
Appends an array entry containing a new value of BOOL type. Returns an invalid Cursor if unsuccessful.- Parameters:
bit
- the actual boolean value for initializing a new BoolValue- Returns:
- a valid Cursor referencing the new entry value if successful
-
addLong
Adds a new entry of LONG type to an array. -
addDouble
Adds a new entry of DOUBLE type to an array. -
addString
Add a new entry of STRING type to an array. -
addString
Add a new entry of STRING type to an array. -
addData
Add a new entry of DATA type to an array. -
addArray
Cursor addArray()Appends an array entry containing a new value of ARRAY type. Returns a valid Cursor (thay may again be used for adding new sub-array entries) referencing the new entry value if successful; otherwise returns an invalid Cursor.- Returns:
- a new Cursor for the new entry value
-
addObject
Cursor addObject()Appends an array entry containing a new value of OBJECT type. Returns a valid Cursor (thay may again be used for setting sub-fields inside the new object) referencing the new entry value if successful; otherwise returns an invalid Cursor.- Returns:
- a new Cursor for the new entry value
-
setNix
Sets a field (identified with a symbol id) to contain a new value of NIX type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be set- Returns:
- new Cursor for the new field value
-
setBool
Sets a field (identified with a symbol id) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be setbit
- the actual boolean value for the new field- Returns:
- new Cursor for the new field value
-
setLong
Sets a field (identified with a symbol id) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be setl
- the actual long value for the new field- Returns:
- new Cursor for the new field value
-
setDouble
Sets a field (identified with a symbol id) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be setd
- the actual double value for the new field- Returns:
- new Cursor for the new field value
-
setString
Sets a field (identified with a symbol id) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be setstr
- the actual string for the new field- Returns:
- a new Cursor for the new field value
-
setString
Sets a field (identified with a symbol id) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be setutf8
- the actual string (encoded as UTF-8 data) for the new field- Returns:
- a new Cursor for the new field value
-
setData
Sets a field (identified with a symbol id) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be setdata
- the actual data to be put into the new field- Returns:
- a new Cursor for the new field value
-
setArray
Sets a field (identified with a symbol id) to contain a new value of ARRAY type. Returns a valid Cursor (thay may again be used for adding new array entries) referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be set- Returns:
- a new Cursor for the new field value
-
setObject
Sets a field (identified with a symbol id) to contain a new value of OBJECT type. Returns a valid Cursor (thay may again be used for setting sub-fields inside the new object) referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
sym
- symbol id for the field to be set- Returns:
- a new Cursor for the new field value
-
setNix
Sets a field (identified with a symbol name) to contain a new value of NIX type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be set- Returns:
- a new Cursor for the new field value
-
setBool
Sets a field (identified with a symbol name) to contain a new value of BOOL type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be setbit
- the actual boolean value for the new field- Returns:
- a new Cursor for the new field value
-
setLong
Sets a field (identified with a symbol name) to contain a new value of LONG type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be setl
- the actual long value for the new field- Returns:
- a new Cursor for the new field value
-
setDouble
Sets a field (identified with a symbol name) to contain a new value of DOUBLE type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be setd
- the actual double value for the new field- Returns:
- a new Cursor for the new field value
-
setString
Sets a field (identified with a symbol name) to contain a new value of STRING type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be setstr
- the actual string for the new field- Returns:
- a new Cursor for the new field value
-
setString
Sets a field (identified with a symbol name) to contain a new value of STRING type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be setutf8
- the actual string (encoded as UTF-8 data) for the new field- Returns:
- a new Cursor for the new field value
-
setData
Sets a field (identified with a symbol name) to contain a new value of DATA type. Returns a valid Cursor referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be setdata
- the actual data to be put into the new field- Returns:
- a new Cursor for the new field value
-
setArray
Sets a field (identified with a symbol name) to contain a new value of ARRAY type. Returns a valid Cursor (thay may again be used for adding new array entries) referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be set- Returns:
- a new Cursor for the new field value
-
setObject
Sets a field (identified with a symbol name) to contain a new value of OBJECT type. Returns a valid Cursor (thay may again be used for setting sub-fields inside the new object) referencing the new field value if successful; otherwise returns an invalid Cursor.- Parameters:
name
- symbol name for the field to be set- Returns:
- a new Cursor for the new field value
-