public abstract class HandleResource extends java.lang.Object implements Printable, CommonHandle, InstantiatingProcedure, Deletable
attribute or base method | API |
---|---|
TYPE | getResourceType() 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 java.lang.Long |
id
The resource's ID.
|
protected handle |
instProc
Handle referencing the instantiating procedure.
|
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 |
---|---|
void |
delete()
Perform actual delete of an resource.
|
protected void |
doDelete()
Perform actual delete of an resource.
|
character |
getResourceType()
Get the type of this handle.
|
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.
|
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 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
valid
private static final java.util.Map<java.lang.Class<?>,java.lang.String> CLS_2_RES
protected final handle 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
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 java.lang.Long id()
id
in interface WrappedResource
null
if not set.public void id(long id)
id
in interface WrappedResource
id
- The resource's ID.public character getResourceType()
getResourceType
in interface CommonHandle
public boolean unknown()
unknown
in interface WrappedResource
false
@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 CommonHandle
attr
- 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 CommonHandle
attribute
- 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 InstantiatingProcedure
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.Object
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 void unableToAssignUnknown(java.lang.String attribute, java.lang.String widgetType)
attribute
- The targeted attribute.widgetType
- The widget type.