Class PyDataDescr

  • All Implemented Interfaces:
    java.io.Serializable, Traverseproc

    public abstract class PyDataDescr
    extends PyDescriptor
    Implements type checking and return type coercion for a data descriptor. A subclass must at least implement invokeGet which is called in __get__ operations. If the descriptor supports setting and deleting, the subclass must also override invokeSet and invokeDel respectively. When implementing those methods, their respective implementsDescr* methods should be overriden as well.
    See Also:
    Serialized Form
    • Constructor Detail

      • PyDataDescr

        public PyDataDescr​(PyType onType,
                           java.lang.String name,
                           java.lang.Class ofType,
                           java.lang.String doc)
        Parameters:
        onType - - the type the descriptor belongs to
        name - - the name of the descriptor on descriptor type
        ofType - - the type returned by the descriptor
      • PyDataDescr

        public PyDataDescr​(java.lang.String name,
                           java.lang.Class ofType,
                           java.lang.String doc)
        This constructor does not initialize the type the descriptor belongs to. setType must be called before this descriptor can be used.
        Parameters:
        name - - the name of the descriptor on descriptor type
        ofType - - the type returned by the descriptor
    • Method Detail

      • setType

        public void setType​(PyType onType)
        Sets the type the descriptor belongs to.
        Overrides:
        setType in class PyObject
      • __get__

        public PyObject __get__​(PyObject obj,
                                PyObject type)
        Description copied from class: PyObject
        Get descriptor for this PyObject.
        Overrides:
        __get__ in class PyObject
        Parameters:
        obj - - the instance accessing this descriptor. Can be null if this is being accessed by a type.
        type - - the type accessing this descriptor. Will be null if obj exists as obj is of the type accessing the descriptor.
        Returns:
        - the object defined for this descriptor for the given obj and type.
      • invokeGet

        public abstract java.lang.Object invokeGet​(PyObject obj)
      • getset_descriptor___set__

        public void getset_descriptor___set__​(PyObject obj,
                                              PyObject value)
      • invokeSet

        public void invokeSet​(PyObject obj,
                              java.lang.Object converted)
      • getset_descriptor___delete__

        public void getset_descriptor___delete__​(PyObject obj)
      • invokeDelete

        public void invokeDelete​(PyObject obj)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class PyObject
      • getDoc

        public java.lang.String getDoc()
      • getName

        public java.lang.String getName()
        Return the name this descriptor is exposed as.
        Returns:
        a name String
      • getObjClass

        public PyObject getObjClass()
        Return the owner class of this descriptor.
        Returns:
        this descriptor's owner