Top Description Inners Fields Constructors Methods
org.python.core

pack-priv abstract Class PyGetSetDescr

extends DataDescriptor
Class Inheritance
Known Direct Subclasses
org.python.core.PyGetSetDescr.Single, org.python.core.PyGetSetDescr.Multiple
Static Imports
org.python.core.ClassShorthand.O, .ClassShorthand.V

Descriptor for an attribute that has been defined by a series of Getter, Setter and Deleter that annotate access methods defined in the object implementation to get, set or delete the value. PyGetSetDescr differs from PyMemberDescr in giving the author of an implementation class the power (and responsibility) entirely to define the behaviour corresponding to these actions.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
PyGetSetDescr.Multiple

A PyGetSetDescr to use for a get-set attribute when the owning Python type has multiple accepted implementations.

pack-priv static class
PyGetSetDescr.Single

A PyGetSetDescr to use for a get-set attribute when the owning Python type has just one accepted implementation.

pack-priv static enum
PyGetSetDescr.Type

A mapping from symbolic names for the types of method handle in a PyGetSetDescr to other properties like the method handle type.

Field Summary

Modifier and TypeField and Description
pack-priv static final MethodType
DELETER

The method handle type (O)V.

pack-priv final String
doc

Documentation string for this attribute.

private static MethodHandle
private static MethodHandle
private static MethodHandle[]
EMPTY_MH_ARRAY

Empty array of method handles

private static MethodHandle
pack-priv static final MethodType
GETTER

The method handle type (O)O.

pack-priv final Class<?>
klass

Java class of attribute accepted by set method.

pack-priv static final MethodHandles.Lookup
pack-priv static final MethodType
SETTER

The method handle type (O,O)V.

pack-priv static final PyType

Constructor Summary

AccessConstructor and Description
pack-priv
PyGetSetDescr(PyType
to which descriptor applies
objclass
,
String
of attribute
name
,
String
documentation string
doc
,
Class<?>
Java class of attribute accepted by set method
klass
)

Construct a descriptor that calls the access methods for get, set and delete operations specified as method handles.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
__delete__(Object
object on which the attribute is sought
obj
)

Implements abstract org.python.core.DataDescriptor.__delete__.

The __delete__ special method of the Python descriptor protocol, implementing del obj.name.
pack-priv Object
__get__(Object
object on which the attribute is sought or null
obj
,
PyType
is ignored
type
)

Implements abstract org.python.core.Descriptor.__get__.

The __get__ special method of the Python descriptor protocol, implementing obj.name or possibly type.name.
private Object
pack-priv void
__set__(Object
object on which the attribute is sought
obj
,
Object
to assign (not null)
value
)

Implements abstract org.python.core.DataDescriptor.__set__.

The __set__ special method of the Python descriptor protocol, implementing obj.name = value.
private static void
emptyDeleter(Object
object to operate on
ignored
)

This method fills delete when the implementation leaves it blank.

private static Object

Returns:

never
emptyGetter
(Object
object to operate on
ignored
)

This method fills get when the implementation leaves it blank.

private static void
emptySetter(Object
object to operate on
ignored
,
Object
ignored too
v
)

This method fills set when the implementation leaves it blank.

pack-priv static Object
pack-priv abstract MethodHandle

Returns:

corresponding handle (or slot.getEmpty())
getWrappedDelete
(Class<?>
Java class of the self argument
selfClass
)

Return the deleter contained in this descriptor applicable to the Java class supplied.

pack-priv abstract MethodHandle

Returns:

corresponding handle (or slot.getEmpty())
getWrappedGet
(Class<?>
Java class of the self argument
selfClass
)

Return the getter contained in this descriptor applicable to the Java class supplied.

pack-priv abstract MethodHandle

Returns:

corresponding handle (or slot.getEmpty())
getWrappedSet
(Class<?>
Java class of the self argument
selfClass
)

Return the setter contained in this descriptor applicable to the Java class supplied.

pack-priv abstract boolean

Returns:

true if the attribute may be deleted.
optional
()

The attribute may be deleted.

pack-priv abstract boolean

Returns:

true if the attribute may not be set or deleted
readonly
()

The attribute may not be set or deleted.

Inherited from org.python.core.DataDescriptor:
attrMustBeattrMustBecannotDeleteAttrcannotReadAttrcannotWriteAttrcheckDeletecheckSet

Field Detail

DELETERback to summary
pack-priv static final MethodType DELETER

The method handle type (O)V.

docback to summary
pack-priv final String doc

Documentation string for this attribute.

EMPTY_DELETERback to summary
private static MethodHandle EMPTY_DELETER

A handle on emptyDeleter(PyObject)

EMPTY_GETTERback to summary
private static MethodHandle EMPTY_GETTER

A handle on emptyGetter(PyObject)

EMPTY_MH_ARRAYback to summary
private static MethodHandle[] EMPTY_MH_ARRAY

Empty array of method handles

EMPTY_SETTERback to summary
private static MethodHandle EMPTY_SETTER

A handle on emptySetter(PyObject, PyObject)

GETTERback to summary
pack-priv static final MethodType GETTER

The method handle type (O)O.

klassback to summary
pack-priv final Class<?> klass

Java class of attribute accepted by set method.

LOOKUPback to summary
pack-priv static final MethodHandles.Lookup LOOKUP
SETTERback to summary
pack-priv static final MethodType SETTER

The method handle type (O,O)V.

TYPEback to summary
pack-priv static final PyType TYPE

Constructor Detail

PyGetSetDescrback to summary
pack-priv PyGetSetDescr(PyType objclass, String name, String doc, Class<?> klass)

Construct a descriptor that calls the access methods for get, set and delete operations specified as method handles.

Parameters
objclass:PyType

to which descriptor applies

name:String

of attribute

doc:String

documentation string

klass:Class<?>

Java class of attribute accepted by set method

Method Detail

__delete__back to summary
pack-priv void __delete__(Object obj) throws TypeError, Throwable

Implements abstract org.python.core.DataDescriptor.__delete__.

Doc from org.python.core.DataDescriptor.__delete__.

The __delete__ special method of the Python descriptor protocol, implementing del obj.name. In general, obj must be of type objclass.

Parameters
obj:Object

object on which the attribute is sought

Annotations
@Override
Exceptions
Throwable:
from the implementation of the deleter
__get__back to summary
pack-priv Object __get__(Object obj, PyType type) throws Throwable

Implements abstract org.python.core.Descriptor.__get__.

Doc from org.python.core.Descriptor.__get__.

The __get__ special method of the Python descriptor protocol, implementing obj.name or possibly type.name. If obj != null invoke get on it to return a value. obj must be of type objclass. A call made with obj == null returns this descriptor.

Parameters
obj:Object

object on which the attribute is sought or null

type:PyType

is ignored

Returns:Object

attribute value, bound object or this attribute

Annotations
@Override
Exceptions
Throwable:
from the implementation of the getter
__repr__back to summary
private Object __repr__()
Annotations
@SuppressWarnings:unused
__set__back to summary
pack-priv void __set__(Object obj, Object value) throws TypeError, Throwable

Implements abstract org.python.core.DataDescriptor.__set__.

Doc from org.python.core.DataDescriptor.__set__.

The __set__ special method of the Python descriptor protocol, implementing obj.name = value. In general, obj must be of type objclass.

Parameters
obj:Object

object on which the attribute is sought

value:Object

to assign (not null)

Annotations
@Override
Exceptions
Throwable:
from the implementation of the setter
emptyDeleterback to summary
private static void emptyDeleter(Object ignored) throws EmptyException

This method fills delete when the implementation leaves it blank.

Parameters
ignored:Object

object to operate on

Annotations
@SuppressWarnings:unused
Exceptions
EmptyException:
always
emptyGetterback to summary
private static Object emptyGetter(Object ignored) throws EmptyException

This method fills get when the implementation leaves it blank.

Parameters
ignored:Object

object to operate on

Returns:Object

never

Annotations
@SuppressWarnings:unused
Exceptions
EmptyException:
always
emptySetterback to summary
private static void emptySetter(Object ignored, Object v) throws EmptyException

This method fills set when the implementation leaves it blank.

Parameters
ignored:Object

object to operate on

v:Object

ignored too

Annotations
@SuppressWarnings:unused
Exceptions
EmptyException:
always
getset_get_docback to summary
pack-priv static Object getset_get_doc(PyGetSetDescr descr)
getWrappedDeleteback to summary
pack-priv abstract MethodHandle getWrappedDelete(Class<?> selfClass)

Return the deleter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

getWrappedGetback to summary
pack-priv abstract MethodHandle getWrappedGet(Class<?> selfClass)

Return the getter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

getWrappedSetback to summary
pack-priv abstract MethodHandle getWrappedSet(Class<?> selfClass)

Return the setter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

optionalback to summary
pack-priv abstract boolean optional()

The attribute may be deleted.

Returns:boolean

true if the attribute may be deleted.

readonlyback to summary
pack-priv abstract boolean readonly()

The attribute may not be set or deleted.

Returns:boolean

true if the attribute may not be set or deleted

org.python.core back to summary

pack-priv Class PyGetSetDescr.Multiple

extends PyGetSetDescr
Class Inheritance

A PyGetSetDescr to use for a get-set attribute when the owning Python type has multiple accepted implementations.

Field Summary

Modifier and TypeField and Description
protected final MethodHandle[]
delete

Handles for the particular implementations of the deleter.

protected final MethodHandle[]
get

Handles for the particular implementations of the getter.

protected final MethodHandle[]
set

Handles for the particular implementations of the setter.

Inherited from org.python.core.PyGetSetDescr:
DELETERdocGETTERklassLOOKUPSETTERTYPE

Constructor Summary

AccessConstructor and Description
pack-priv
Multiple(PyType
to which descriptor applies
objclass
,
String
of attribute
name
,
MethodHandle[]
operation
get
,
MethodHandle[]
operation
set
,
MethodHandle[]
operation
delete
,
String
documentation string
doc
,
Class<?>
Java class of attribute accepted by set method
klass
)

Construct a get-set descriptor, identifying by an array of method handles the implementation methods applicable to objclass.

Method Summary

Modifier and TypeMethod and Description
pack-priv MethodHandle
getWrappedDelete(Class<?>
Java class of the self argument
selfClass
)

Implements abstract org.python.core.PyGetSetDescr.getWrappedDelete.

Return the deleter contained in this descriptor applicable to the Java class supplied.
pack-priv MethodHandle
getWrappedGet(Class<?>
Java class of the self argument
selfClass
)

Implements abstract org.python.core.PyGetSetDescr.getWrappedGet.

Return the getter contained in this descriptor applicable to the Java class supplied.
pack-priv MethodHandle
getWrappedSet(Class<?>
Java class of the self argument
selfClass
)

Implements abstract org.python.core.PyGetSetDescr.getWrappedSet.

Return the setter contained in this descriptor applicable to the Java class supplied.
pack-priv boolean
optional()

Implements abstract org.python.core.PyGetSetDescr.optional.

The attribute may be deleted.
pack-priv boolean
readonly()

Implements abstract org.python.core.PyGetSetDescr.readonly.

The attribute may not be set or deleted.
Inherited from org.python.core.PyGetSetDescr:
__delete____get____set__getset_get_doc

Field Detail

deleteback to summary
protected final MethodHandle[] delete

Handles for the particular implementations of the deleter. The method type of each is (O)V.

getback to summary
protected final MethodHandle[] get

Handles for the particular implementations of the getter. The method type of each is (O)O.

setback to summary
protected final MethodHandle[] set

Handles for the particular implementations of the setter. The method type of each is (O,O)V.

Constructor Detail

Multipleback to summary
pack-priv Multiple(PyType objclass, String name, MethodHandle[] get, MethodHandle[] set, MethodHandle[] delete, String doc, Class<?> klass)

Construct a get-set descriptor, identifying by an array of method handles the implementation methods applicable to objclass. These methods will be identified in an implementation by annotations Getter, Setter, Deleter.

Parameters
objclass:PyType

to which descriptor applies

name:String

of attribute

get:MethodHandle[]

operation

set:MethodHandle[]

operation

delete:MethodHandle[]

operation

doc:String

documentation string

klass:Class<?>

Java class of attribute accepted by set method

Method Detail

getWrappedDeleteback to summary
pack-priv MethodHandle getWrappedDelete(Class<?> selfClass)

Implements abstract org.python.core.PyGetSetDescr.getWrappedDelete.

Doc from org.python.core.PyGetSetDescr.getWrappedDelete.

Return the deleter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

The method will check that the type of self matches Descriptor#objclass, according to its PyType#indexAccepted(Class).

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

Annotations
@Override
getWrappedGetback to summary
pack-priv MethodHandle getWrappedGet(Class<?> selfClass)

Implements abstract org.python.core.PyGetSetDescr.getWrappedGet.

Doc from org.python.core.PyGetSetDescr.getWrappedGet.

Return the getter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

The method will check that the type of self matches Descriptor#objclass, according to its PyType#indexAccepted(Class).

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

Annotations
@Override
getWrappedSetback to summary
pack-priv MethodHandle getWrappedSet(Class<?> selfClass)

Implements abstract org.python.core.PyGetSetDescr.getWrappedSet.

Doc from org.python.core.PyGetSetDescr.getWrappedSet.

Return the setter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

The method will check that the type of self matches Descriptor#objclass, according to its PyType#indexAccepted(Class).

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

Annotations
@Override
optionalback to summary
pack-priv boolean optional()

Implements abstract org.python.core.PyGetSetDescr.optional.

Doc from org.python.core.PyGetSetDescr.optional.

The attribute may be deleted.

Returns:boolean

true if the attribute may be deleted.

Annotations
@Override
readonlyback to summary
pack-priv boolean readonly()

Implements abstract org.python.core.PyGetSetDescr.readonly.

Doc from org.python.core.PyGetSetDescr.readonly.

The attribute may not be set or deleted.

Returns:boolean

true if the attribute may not be set or deleted

Annotations
@Override
org.python.core back to summary

pack-priv Class PyGetSetDescr.Single

extends PyGetSetDescr
Class Inheritance

A PyGetSetDescr to use for a get-set attribute when the owning Python type has just one accepted implementation.

Field Summary

Modifier and TypeField and Description
pack-priv final MethodHandle
delete

A handle on the deleter defined by the unique implementation of Descriptor#objclass for this attribute.

pack-priv final MethodHandle
get

A handle on the getter defined by the unique implementation of Descriptor#objclass for this attribute.

pack-priv final MethodHandle
set

A handle on the setter defined by the unique implementation of Descriptor#objclass for this attribute.

Inherited from org.python.core.PyGetSetDescr:
DELETERdocGETTERklassLOOKUPSETTERTYPE

Constructor Summary

AccessConstructor and Description
pack-priv
Single(PyType
to which descriptor applies
objclass
,
String
of attribute
name
,
MethodHandle
handle on getter method (or null)
get
,
MethodHandle
handle on setter method (or null)
set
,
MethodHandle
handle on deleter method (or null)
delete
,
String
documentation string
doc
,
Class<?>
Java class of attribute accepted by set method
klass
)

Construct a get-set descriptor, identifying by a method handle each implementation method applicable to objclass.

Method Summary

Modifier and TypeMethod and Description
pack-priv MethodHandle
getWrappedDelete(Class<?>
Java class of the self argument
selfClass
)

Implements abstract org.python.core.PyGetSetDescr.getWrappedDelete.

Return the deleter contained in this descriptor applicable to the Java class supplied.
pack-priv MethodHandle
getWrappedGet(Class<?>
Java class of the self argument
selfClass
)

Implements abstract org.python.core.PyGetSetDescr.getWrappedGet.

Return the getter contained in this descriptor applicable to the Java class supplied.
pack-priv MethodHandle
getWrappedSet(Class<?>
Java class of the self argument
selfClass
)

Implements abstract org.python.core.PyGetSetDescr.getWrappedSet.

Return the setter contained in this descriptor applicable to the Java class supplied.
pack-priv boolean
optional()

Implements abstract org.python.core.PyGetSetDescr.optional.

The attribute may be deleted.
pack-priv boolean
readonly()

Implements abstract org.python.core.PyGetSetDescr.readonly.

The attribute may not be set or deleted.
Inherited from org.python.core.PyGetSetDescr:
__delete____get____set__getset_get_doc

Field Detail

deleteback to summary
pack-priv final MethodHandle delete

A handle on the deleter defined by the unique implementation of Descriptor#objclass for this attribute. The method type is DELETER = (O)V.

getback to summary
pack-priv final MethodHandle get

A handle on the getter defined by the unique implementation of Descriptor#objclass for this attribute. The method type is GETTER = (O)O.

setback to summary
pack-priv final MethodHandle set

A handle on the setter defined by the unique implementation of Descriptor#objclass for this attribute. The method type is SETTER = (O,O)V.

Constructor Detail

Singleback to summary
pack-priv Single(PyType objclass, String name, MethodHandle get, MethodHandle set, MethodHandle delete, String doc, Class<?> klass)

Construct a get-set descriptor, identifying by a method handle each implementation method applicable to objclass. These methods will be identified in an implementation by annotations Getter, Setter, Deleter.

Parameters
objclass:PyType

to which descriptor applies

name:String

of attribute

get:MethodHandle

handle on getter method (or null)

set:MethodHandle

handle on setter method (or null)

delete:MethodHandle

handle on deleter method (or null)

doc:String

documentation string

klass:Class<?>

Java class of attribute accepted by set method

Method Detail

getWrappedDeleteback to summary
pack-priv MethodHandle getWrappedDelete(Class<?> selfClass)

Implements abstract org.python.core.PyGetSetDescr.getWrappedDelete.

Doc from org.python.core.PyGetSetDescr.getWrappedDelete.

Return the deleter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

Annotations
@Override
getWrappedGetback to summary
pack-priv MethodHandle getWrappedGet(Class<?> selfClass)

Implements abstract org.python.core.PyGetSetDescr.getWrappedGet.

Doc from org.python.core.PyGetSetDescr.getWrappedGet.

Return the getter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

Annotations
@Override
getWrappedSetback to summary
pack-priv MethodHandle getWrappedSet(Class<?> selfClass)

Implements abstract org.python.core.PyGetSetDescr.getWrappedSet.

Doc from org.python.core.PyGetSetDescr.getWrappedSet.

Return the setter contained in this descriptor applicable to the Java class supplied. The Descriptor#objclass is consulted to make this determination. If the class is not an accepted implementation of objclass, an empty slot handle (with the correct signature) is returned.

Parameters
selfClass:Class<?>

Java class of the self argument

Returns:MethodHandle

corresponding handle (or slot.getEmpty())

Annotations
@Override
optionalback to summary
pack-priv boolean optional()

Implements abstract org.python.core.PyGetSetDescr.optional.

Doc from org.python.core.PyGetSetDescr.optional.

The attribute may be deleted.

Returns:boolean

true if the attribute may be deleted.

Annotations
@Override
readonlyback to summary
pack-priv boolean readonly()

Implements abstract org.python.core.PyGetSetDescr.readonly.

Doc from org.python.core.PyGetSetDescr.readonly.

The attribute may not be set or deleted.

Returns:boolean

true if the attribute may not be set or deleted

Annotations
@Override
org.python.core back to summary

pack-priv final Enum PyGetSetDescr.Type

extends Enum<PyGetSetDescr.Type>
Class Inheritance

A mapping from symbolic names for the types of method handle in a PyGetSetDescr to other properties like the method handle type.

Field Summary

Modifier and TypeField and Description
public static final PyGetSetDescr.Type
public static final PyGetSetDescr.Type
pack-priv final MethodType
public static final PyGetSetDescr.Type

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static PyGetSetDescr.Type

Returns:

matching type or null
fromMethodType
(MethodType
to match
mt
)

Map the method handle type back to the PyGetSetDescr.Type that has it or null.

public static PyGetSetDescr.Type
public static PyGetSetDescr.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Deleterback to summary
public static final PyGetSetDescr.Type Deleter
Getterback to summary
public static final PyGetSetDescr.Type Getter
methodTypeback to summary
pack-priv final MethodType methodType
Setterback to summary
public static final PyGetSetDescr.Type Setter

Constructor Detail

Typeback to summary
private Type(MethodType mt)

Method Detail

fromMethodTypeback to summary
pack-priv static PyGetSetDescr.Type fromMethodType(MethodType mt)

Map the method handle type back to the PyGetSetDescr.Type that has it or null.

Parameters
mt:MethodType

to match

Returns:PyGetSetDescr.Type

matching type or null

valueOfback to summary
public static PyGetSetDescr.Type valueOf(String name)
valuesback to summary
public static PyGetSetDescr.Type[] values()