public class HandleOps
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
LOG
Logger
|
Constructor and Description |
---|
HandleOps() |
Modifier and Type | Method and Description |
---|---|
static logical |
canQuery(handle h,
character attr)
Reports if the given attribute can be read from the given handle.
|
static logical |
canQuery(handle h,
java.lang.String attr)
Reports if the given attribute can be read from the given handle.
|
static logical |
canSet(handle h,
character attr)
Reports if the given attribute can be written to the given handle.
|
static logical |
canSet(handle h,
java.lang.String attr)
Reports if the given attribute can be written to the given handle.
|
static void |
delete(handle... handles)
Deletes the given handles.
|
static void |
delete(handle h)
Deletes the given handle.
|
private static LegacyAttribute |
getLegacyAttribute(handle h,
java.lang.String attr,
boolean setter)
Obtains the legacy attribute annotation instance for the given handle object and given
legacy attribute name.
|
private static LegacyAttribute |
getLegacyAttributeInClass(java.lang.Class class_check,
java.lang.String attr,
boolean setter)
Obtains the legacy attribute annotation instance for the given implementation or interface
class object and given legacy attribute name.
|
private static LegacyAttribute |
getLegacyAttributeInMethod(java.lang.reflect.Method meth_check,
java.lang.String attr,
boolean setter)
Obtains the legacy attribute annotation instance for the given method and given legacy
attribute name.
|
private static LegacyAttribute |
getLegacyAttributeInStatic(java.lang.Object obj_check,
java.lang.String attr,
boolean setter)
Obtains the legacy attribute annotation instance for the given static class object and
given legacy attribute name.
|
private static void |
invalidDelete()
Invoked when the handle is invalid or a system (non-procedure) handle.
|
private static void |
invalidDelete(handle h)
Invoked when the handle is invalid or a system (non-procedure) handle.
|
private static boolean |
isHandleAttribute(java.lang.String attrName)
Checks if the given attribute name is HANDLE.
|
static boolean |
isSystemHandle(handle h)
Check if the given resource represents a system handle.
|
static boolean |
isSystemHandle(WrappedResource res)
Check if the given resource represents a system handle.
|
public static boolean isSystemHandle(WrappedResource res)
res
- The resource to check.true
if the resource represents a system handle as defined above.public static boolean isSystemHandle(handle h)
h
- The handle to check.true
if the handle references a system handle.public static void delete(handle... handles)
In cases when the handle is a system handle, an invalidDelete()
is called (to raise an error).
handles
- The list of handles to be deleted.public static void delete(handle h)
In cases when the handle is a system handle, an invalidDelete()
is called (to raise
an error).
h
- The handle to be deleted.public static logical canQuery(handle h, character attr)
CAN-QUERY()
built-in function.h
- The handle to be tested.attr
- The name of the attribute to be checked.true
if the resource in this handle supports reading the named
attribute, false
if the resource is valid but doesn't support
the named attribute and unknown
if either input is
unknown
.public static logical canQuery(handle h, java.lang.String attr)
CAN-QUERY()
built-in function.h
- The handle to be tested.attr
- The name of the attribute to be checked.true
if the resource in this handle supports reading the named
attribute, false
if the resource is valid but doesn't support
the named attribute and unknown
if either input is
unknown
.public static logical canSet(handle h, character attr)
CAN-SET()
built-in function.h
- The handle to be tested.attr
- The name of the attribute to be checked.true
if the resource in this handle supports writing the named
attribute, false
if the resource is valid but doesn't support
the named attribute and unknown
if either input is
unknown
.public static logical canSet(handle h, java.lang.String attr)
CAN-SET()
built-in function.h
- The handle to be tested.attr
- The name of the attribute to be checked.true
if the resource in this handle supports writing the named
attribute, false
if the resource is valid but doesn't support
the named attribute and unknown
if either input is
unknown
.private static LegacyAttribute getLegacyAttributeInMethod(java.lang.reflect.Method meth_check, java.lang.String attr, boolean setter)
meth_check
- The method to be tested.attr
- The name of the legacy attribute to be checked.setter
- The flag indicating if we need to find the setter or getter annotation.private static LegacyAttribute getLegacyAttributeInClass(java.lang.Class class_check, java.lang.String attr, boolean setter)
class_check
- The interface or implementation class object to be tested.attr
- The name of the legacy attribute to be checked.setter
- The flag indicating if we need to find the setter or getter annotation.private static LegacyAttribute getLegacyAttributeInStatic(java.lang.Object obj_check, java.lang.String attr, boolean setter)
obj_check
- The class object to be tested.attr
- The name of the legacy attribute to be checked.setter
- The flag indicating if we need to find the setter or getter annotation.private static LegacyAttribute getLegacyAttribute(handle h, java.lang.String attr, boolean setter)
The search algorithm for this method uses reflection to read annotations from various sources in the following precedence order:
Where possible, we put annotations on the interface, not the class for the resource. But there are some attributes where the configuration is not universal for all resources implementing the same attribute. For example, the following attributes are readable for certain resources even though for most other resources the same attribute is writable:
Keeping the above precedence order is critical to allow attribute configurations of more-specific resources to properly override the more general configuration in the parent hierarchy or the interface hierarchy.
h
- The handle object to be tested.attr
- The name of the legacy attribute to be checked.setter
- The flag indicating if we need to find the setter or getter annotation.private static boolean isHandleAttribute(java.lang.String attrName)
attrName
- The name of the attribute to be checked.true
if the attribute name is HANDLE, false
otherwise.private static void invalidDelete()
invalidDelete(null)
.private static void invalidDelete(handle h)
h
- The handle for which the delete failed. May be
null
if it was decide this is a non-procedure
handle.