Interface Cursor

  • All Superinterfaces:
    Inspector

    public interface Cursor
    extends 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.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Cursor addArray()
      Append an array entry containing a new value of ARRAY type.
      Cursor addBool​(boolean bit)
      Append an array entry containing a new value of BOOL type.
      Cursor addData​(byte[] data)
      add a new entry of DATA type to an array
      Cursor addDouble​(double d)
      add a new entry of DOUBLE type to an array
      Cursor addLong​(long l)
      add a new entry of LONG type to an array
      Cursor addNix()
      Append an array entry containing a new value of NIX type.
      Cursor addObject()
      Append an array entry containing a new value of OBJECT type.
      Cursor addString​(byte[] utf8)
      add a new entry of STRING type to an array
      Cursor addString​(java.lang.String str)
      add a new entry of STRING type to an array
      Cursor entry​(int idx)
      Access an array entry.
      Cursor field​(int sym)
      Access an field in an object by symbol id.
      Cursor field​(java.lang.String name)
      Access an field in an object by symbol name.
      Cursor setArray​(int sym)
      Set a field (identified with a symbol id) to contain a new value of ARRAY type.
      Cursor setArray​(java.lang.String name)
      Set a field (identified with a symbol name) to contain a new value of ARRAY type.
      Cursor setBool​(int sym, boolean bit)
      Set a field (identified with a symbol id) to contain a new value of BOOL type.
      Cursor setBool​(java.lang.String name, boolean bit)
      Set a field (identified with a symbol name) to contain a new value of BOOL type.
      Cursor setData​(int sym, byte[] data)
      Set a field (identified with a symbol id) to contain a new value of BOOL type.
      Cursor setData​(java.lang.String name, byte[] data)
      Set a field (identified with a symbol name) to contain a new value of DATA type.
      Cursor setDouble​(int sym, double d)
      Set a field (identified with a symbol id) to contain a new value of BOOL type.
      Cursor setDouble​(java.lang.String name, double d)
      Set a field (identified with a symbol name) to contain a new value of DOUBLE type.
      Cursor setLong​(int sym, long l)
      Set a field (identified with a symbol id) to contain a new value of BOOL type.
      Cursor setLong​(java.lang.String name, long l)
      Set a field (identified with a symbol name) to contain a new value of LONG type.
      Cursor setNix​(int sym)
      Set a field (identified with a symbol id) to contain a new value of NIX type.
      Cursor setNix​(java.lang.String name)
      Set a field (identified with a symbol name) to contain a new value of NIX type.
      Cursor setObject​(int sym)
      Set a field (identified with a symbol id) to contain a new value of OBJECT type.
      Cursor setObject​(java.lang.String name)
      Set a field (identified with a symbol name) to contain a new value of OBJECT type.
      Cursor setString​(int sym, byte[] utf8)
      Set a field (identified with a symbol id) to contain a new value of BOOL type.
      Cursor setString​(int sym, java.lang.String str)
      Set a field (identified with a symbol id) to contain a new value of BOOL type.
      Cursor setString​(java.lang.String name, byte[] utf8)
      Set a field (identified with a symbol name) to contain a new value of STRING type.
      Cursor setString​(java.lang.String name, java.lang.String str)
      Set a field (identified with a symbol name) to contain a new value of STRING type.
    • Method Detail

      • entry

        Cursor entry​(int idx)
        Access 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.
        Specified by:
        entry in interface Inspector
        Parameters:
        idx - array index.
        Returns:
        a new Cursor for the entry value.
      • field

        Cursor field​(int sym)
        Access an 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.
        Specified by:
        field in interface Inspector
        Parameters:
        sym - symbol id.
        Returns:
        a new Cursor for the field value.
      • field

        Cursor field​(java.lang.String name)
        Access an 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.
        Specified by:
        field in interface Inspector
        Parameters:
        name - symbol name.
        Returns:
        a new Cursor for the field value.
      • addNix

        Cursor addNix()
        Append 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

        Cursor addBool​(boolean bit)
        Append 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

        Cursor addLong​(long l)
        add a new entry of LONG type to an array
      • addDouble

        Cursor addDouble​(double d)
        add a new entry of DOUBLE type to an array
      • addString

        Cursor addString​(java.lang.String str)
        add a new entry of STRING type to an array
      • addString

        Cursor addString​(byte[] utf8)
        add a new entry of STRING type to an array
      • addData

        Cursor addData​(byte[] data)
        add a new entry of DATA type to an array
      • addArray

        Cursor addArray()
        Append 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:
        new Cursor for the new entry value
      • addObject

        Cursor addObject()
        Append 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:
        new Cursor for the new entry value
      • setNix

        Cursor setNix​(int sym)
        Set 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

        Cursor setBool​(int sym,
                       boolean bit)
        Set 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 set
        bit - the actual boolean value for the new field
        Returns:
        new Cursor for the new field value
      • setLong

        Cursor setLong​(int sym,
                       long l)
        Set 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 set
        l - the actual long value for the new field
        Returns:
        new Cursor for the new field value
      • setDouble

        Cursor setDouble​(int sym,
                         double d)
        Set 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 set
        d - the actual double value for the new field
        Returns:
        new Cursor for the new field value
      • setString

        Cursor setString​(int sym,
                         java.lang.String str)
        Set 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 set
        str - the actual string for the new field
        Returns:
        new Cursor for the new field value
      • setString

        Cursor setString​(int sym,
                         byte[] utf8)
        Set 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 set
        utf8 - the actual string (encoded as UTF-8 data) for the new field
        Returns:
        new Cursor for the new field value
      • setData

        Cursor setData​(int sym,
                       byte[] data)
        Set 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 set
        data - the actual data to be put into the new field
        Returns:
        new Cursor for the new field value
      • setArray

        Cursor setArray​(int sym)
        Set 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:
        new Cursor for the new field value
      • setObject

        Cursor setObject​(int sym)
        Set 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:
        new Cursor for the new field value
      • setNix

        Cursor setNix​(java.lang.String name)
        Set 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:
        new Cursor for the new field value
      • setBool

        Cursor setBool​(java.lang.String name,
                       boolean bit)
        Set 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 set
        bit - the actual boolean value for the new field
        Returns:
        new Cursor for the new field value
      • setLong

        Cursor setLong​(java.lang.String name,
                       long l)
        Set 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 set
        l - the actual long value for the new field
        Returns:
        new Cursor for the new field value
      • setDouble

        Cursor setDouble​(java.lang.String name,
                         double d)
        Set 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 set
        d - the actual double value for the new field
        Returns:
        new Cursor for the new field value
      • setString

        Cursor setString​(java.lang.String name,
                         java.lang.String str)
        Set 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 set
        str - the actual string for the new field
        Returns:
        new Cursor for the new field value
      • setString

        Cursor setString​(java.lang.String name,
                         byte[] utf8)
        Set 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 set
        utf8 - the actual string (encoded as UTF-8 data) for the new field
        Returns:
        new Cursor for the new field value
      • setData

        Cursor setData​(java.lang.String name,
                       byte[] data)
        Set 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 set
        data - the actual data to be put into the new field
        Returns:
        new Cursor for the new field value
      • setArray

        Cursor setArray​(java.lang.String name)
        Set 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:
        new Cursor for the new field value
      • setObject

        Cursor setObject​(java.lang.String name)
        Set 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:
        new Cursor for the new field value