Class PyDataDescr

All Implemented Interfaces:
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:
  • Constructor Details

    • PyDataDescr

      public PyDataDescr(PyType onType, String name, Class ofType, 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(String name, Class ofType, 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 Details

    • 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.
    • getset_descriptor___get__

      public PyObject getset_descriptor___get__(PyObject obj, PyObject type)
    • invokeGet

      public abstract Object invokeGet(PyObject obj)
    • __set__

      public void __set__(PyObject obj, PyObject value)
      Overrides:
      __set__ in class PyObject
    • getset_descriptor___set__

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

      public void invokeSet(PyObject obj, Object converted)
    • __delete__

      public void __delete__(PyObject obj)
      Overrides:
      __delete__ in class PyObject
    • getset_descriptor___delete__

      public void getset_descriptor___delete__(PyObject obj)
    • invokeDelete

      public void invokeDelete(PyObject obj)
    • isDataDescr

      public boolean isDataDescr()
      Overrides:
      isDataDescr in class PyObject
    • toString

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

      public String getDoc()
    • getName

      public 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