public abstract class HandleResource extends java.lang.Object implements Printable, CommonHandle, InstantiatingProcedure, Deletable
| attribute or base method | API |
|---|---|
| TYPE | resourceType() and type() |
| INSTANTIATING-PROCEDURE | instantiatingProcedure() |
| Unknown status | unknown() |
| Read only field error | readOnlyError(String, Object) |
| Invalid attribute access | invalidAttribute(String, boolean) |
The abstract class also provides setters for the implemented attributes which are not defined inside the interfaces to be used for initializing of those attributes
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<java.lang.Class<?>,java.lang.String> |
CLS_2_RES
A mapping of resource names for each FWD class implementing a resource.
|
private int |
hashCode
Cached hash code.
|
private java.lang.Long |
id
The resource's ID.
|
protected java.lang.ref.WeakReference<java.lang.Object> |
instProc
Weak reference to the instantiating procedure.
|
protected ProcedureManager.ProcedureHelper |
pm
Helper to use the ProcedureManager without any context local lookups.
|
private int |
triggerRegistration
The number of trigger registration (ever).
|
private java.lang.String |
type
Variable for holding the type attribute
|
| Modifier | Constructor and Description |
|---|---|
|
HandleResource()
Default c'tor.
|
protected |
HandleResource(boolean dynamic)
Initialize this resource by determining its type.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
_instantiatingProcedure()
Getter for the INSTANTIATING-PROCEDURE attribute, as direct resource.
|
void |
addToPool(character pool)
Add this resource to the
WidgetPool. |
void |
delete()
Perform actual delete of an resource.
|
protected void |
doDelete()
Perform actual delete of an resource.
|
boolean |
equals(java.lang.Object obj)
Determine whether this object is equivalent to the specified object.
|
int |
hashCode()
Return the hash code for this object.
|
java.lang.Long |
id()
Get this resource's ID, if is already set.
|
void |
id(long id)
Set this resource's ID.
|
protected boolean |
implicitDeletion()
Check if the resource may be implicitly deleted.
|
void |
incrementTrigger()
Increment the
triggerRegistration counter. |
handle |
instantiatingProcedure()
Getter for the INSTANTIATING-PROCEDURE attribute.
|
protected void |
invalidAttribute(java.lang.String attr,
boolean setter)
To be used only in cases a getter for a not-supported attribute is forced to be implemented
by the resource.
|
protected boolean |
processResource()
Check if this resource must be processed via
ProcedureManager.processResource(com.goldencode.p2j.util.WrappedResource, boolean), once
it has been instantiated. |
void |
readOnlyError(java.lang.String attr)
Deprecated.
Use the overloaded method with multiple arguments.
This API is deprecated because of two reasons: first, it looses the possible side effect of the assigned expression (consider the case when it is a function or method, but not exclusively). Secondly, some (if not all) are unknown value sensitive, meaning that, prior testing whether this is a writable attribute, P4GL checks first if the expression is unknown and if this value is supported. In this case a different error condition is raised. |
void |
readOnlyError(java.lang.String attribute,
java.lang.Object expr)
Shows a specific error, as this read-only
attribute was used on the right-side of an assignment. |
static void |
registerResource(java.lang.Class clazz,
java.lang.String name)
Registers a new resource in the internal map of resource class to resource name.
|
protected boolean |
resourceDelete()
Worker to be implemented by each resource.
|
character |
resourceType()
Get the type of this handle.
|
protected void |
setInstantiatingProcedure(handle hproc)
Set the instantiating procedure for this resource.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
java.lang.String |
type()
Get the type of this handle as type of String.
|
protected static void |
unableToAssignUnknown(java.lang.String attribute,
java.lang.String widgetType)
Show an error complaining that the UNKNOWN value cannot be assigned to a specified
attribute.
|
boolean |
unknown()
A newly-created resource is always not-unknown.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitvalidallowDeleteprivate static final java.util.Map<java.lang.Class<?>,java.lang.String> CLS_2_RES
protected java.lang.ref.WeakReference<java.lang.Object> instProc
private java.lang.String type
private java.lang.Long id
null until the ID is requested via
handle.resourceId(com.goldencode.p2j.util.WrappedResource)private int triggerRegistration
private int hashCode
protected final ProcedureManager.ProcedureHelper pm
public HandleResource()
protected HandleResource(boolean dynamic)
The resource's type is determined from a LegacyResource annotation, which is
searched in these locations, in this order:
LegacyResource annotation; if there is more than annotated interface, then n
IllegalStateException is thrown.dynamic - Flag indicating if this is a static or dynamic resource.java.lang.IllegalStateException - If the resource type could not be determined from a LegacyResource
annotation, after checking the interface hierarchy, or more than one interface
is annotated.public static void registerResource(java.lang.Class clazz,
java.lang.String name)
clazz - Resource class.name - Resource name.public final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - Object to test for equality.true if equivalent, else false.public final int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Long id()
id in interface WrappedResourcenull if not set.public void id(long id)
id in interface WrappedResourceid - The resource's ID.public character resourceType()
resourceType in interface CommonHandlepublic boolean unknown()
unknown in interface WrappedResourcefalse@Deprecated public void readOnlyError(java.lang.String attr)
This API is deprecated because of two reasons: first, it looses the possible side effect of the assigned expression (consider the case when it is a function or method, but not exclusively). Secondly, some (if not all) are unknown value sensitive, meaning that, prior testing whether this is a writable attribute, P4GL checks first if the expression is unknown and if this value is supported. In this case a different error condition is raised.
attribute was used on the right-side of an assignment.readOnlyError in interface CommonHandleattr - The read-only attribute.public void readOnlyError(java.lang.String attribute,
java.lang.Object expr)
attribute was used on the right-side of an assignment.
If the expr is evaluated to ? (unknown value) and this attribute does not support it,
a specific error is raised.readOnlyError in interface CommonHandleattribute - The read-only attribute.expr - The expression whose value was attempted to be assigned to READ-ONLY attribute.public java.lang.String type()
public handle instantiatingProcedure()
The returned handle will refer a valid external procedure (persistent or not) or will be unknown, in case its instantiating procedure was persistent and has been deleted.
instantiatingProcedure in interface InstantiatingProcedurepublic java.lang.Object _instantiatingProcedure()
The returned reference will refer the exact external procedure (persistent or not) or will be
null, if instProc was not set.
public void delete()
The method first calls resourceDelete(), if the method returns false, the deletion
is aborted.
public void incrementTrigger()
triggerRegistration counter.public java.lang.String toString()
toString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString in class java.lang.Objectpublic void addToPool(character pool)
WidgetPool.pool - The pool name, set to null if the unnamed pool is to be used.protected void doDelete()
protected boolean resourceDelete()
delete().true if the resource was deleted.protected void invalidAttribute(java.lang.String attr,
boolean setter)
attr - The not-supported attribute attribute.setter - true for write access.protected boolean implicitDeletion()
true if the resource's instantiating procedure is currently being
deleted, and the resource is currently being processed.protected void setInstantiatingProcedure(handle hproc)
hproc - The procedure where the resource was instantiated.protected boolean processResource()
ProcedureManager.processResource(com.goldencode.p2j.util.WrappedResource, boolean), once
it has been instantiated.true.protected static void unableToAssignUnknown(java.lang.String attribute,
java.lang.String widgetType)
attribute - The targeted attribute.widgetType - The widget type.