@doc alias="obj" hierarchy="GMLDOM">
The ultimate superclass of all model objects.
Instances of GmlObject or any of its derived classes are persistent objects that are
stored as part of the model and are universally accessible.
To create instances of GmlObject or any of its sub-classes, use respective GMLDOM methods.
Do not use constructors for initializing instances of GmlObject.
(c) SAP AG 2003-2006. All rights reserved.
///////////////////////////////////////////////////////////////////////
// CLASS HEADER
abstract Class GmlObject;
metadata title = '#TEXT[XTIT_GML_OBJECT]';
metadata descr = '#TEXT[XTOL_GML_OBJECT]';
///////////////////////////////////////////////////////////////////////
// PROPERTIES
<@prop name="Class" type="@Class!" access="RO" static="yes" group="I. Properties">Gets the object's Class
<@doc>Gets the object identifier (unique within the scope of the parent object)
readonly property id = '';
<@doc>Gets or sets the object name
property name = '';
///////////////////////////////////////////////////////////////////////
// METHODS
<@method name="isa" group="II. Methods">
Tests whether this object is an instance of one or more specified classes
A variable list of qualified class names to test
The test result
<@doc>
Gets the value of a specified property
Gets an object property
The name of the property to get
Gets an object's aspect property
The qualified aspect role name
The name of the property to get
The requested property value
override method getProperty(name)
if (arguments.length == 2) {
name = $DOM.getAspect$Name(arguments[0], arguments[1]);
}
if (this.hasOwnProperty(name)) {
return this[name];
} else {
var P=this.Class.properties[name];
return (P && P.isProperty) ? P.value : null;
}
end
<@doc>
Sets the value of a specified property
The name of the property to set
The property's new value. If omitted, the property will be reset to its default value.
Returns ~true if the property was set successfully; otherwise, returns ~false
override method setProperty(name, value, silent)
var C=this.Class, P=C.properties[name];
if (!P || P.isReadonly) return false;
if (P.isVirtual) {
if (value === undefined) delete this[name]; else this[name] = value;
return true;
}
var oldval = P.isStatic ? P.value : this.hasOwnProperty(name) ? this[name] : void(0);
if (oldval === value) return true;
var msg1="#TEXT[XMSG_TYPE_CHECK_FAILED]";
var msg2="when expecting type";
#DEVTIME[
if (P && P.typecheck && (typeof value == 'object') && !ISA(value, P.typecheck)) {
throw new Error(-1,msg1 + value.Class.fullname + msg2 + P.typecheck);
}
]
if (P.isStatic) {
C.prototype[name] = value;
P.value = value;
} else {
if (value === undefined) delete this[name]; else this[name] = value;
this.setDirty();
}
if (silent) return true;
var evt = document.createEventObject();
evt.type = 'onUpdateObject';
evt.object = this;
evt.name = name;
evt.value = value;
evt.oldval = oldval;
$ENV.fireModelEvent(evt);
if (name == 'name') {
var evt = document.createEventObject();
evt.type = 'onRenameObject';
evt.object = this;
evt.newname = value;
evt.oldname = oldval;
$ENV.fireModelEvent(evt);
}
return true;
end
<@doc>
Tests whether the object has a value in a specified property
The name of the property to test
The test result
Use this method to test whether the object has a value in the given property.
The method works as expected even if the property value (instance)
is equal to the default property value (class).
override method hasProperty(name)
return this.hasOwnProperty(name);
end
<@doc scope="private">
Sets the dirty flag of the containing unit and raises a notification event
method setDirty()
// override
end
<@doc>
Invokes an overridden method on the superclass
The overridden method arguments. If omitted, the arguments passed to the invoking method will be used
The invoked method return value
method supercall()
try {
var caller = arguments.callee.caller;
var ancestor = caller.Class.superclass;
if (ancestor) {
var args = (arguments.length == 0 ? caller.arguments : arguments);
var func = ancestor.prototype[caller.name];
if (func) return func.apply(this, args);
}
} catch(e) {
var a = '#TEXT[XMSG_METHOD]';
var b = 'supercall failed\:';
#LOG[4, a + ' ' + caller.name + ' ' + b + ' ' + e.description]
}
end
<@doc>
Invokes an overridden method on an ancestor class (including indirect ancestor classes and prototypes from which this class is derived)
The name of the ancestor class/prototype to invoke
The overridden method arguments. If omitted, the arguments passed to the invoking method will be used
The invoked method return value
method protocall(ancestorName)
try {
var caller = arguments.callee.caller;
var ancestor = caller.Class.precedents[ancestorName];
if (ancestor) {
var args = caller.arguments;
if (arguments.length > 1 ) {
for (var i=1, len=arguments.length, args=[]; i
A callback method that is invoked when the object is loaded to memory from the model repository
This method is invoked each time the object is loaded to memory (this can happen at most
once during a work session). Override this method to update virtual properties on the object, as needed.
It is guaranteed that when this method is invoked, all other objects in the same unit
unit have been loaded and can be safely referenced.
// abstract method
<@method name="onCreate">
A callback method that is invoked when the object is first created
This method is invoked immediately after the object has been created, but before it is
inserted into the model, and before any notification events are raised.
Override this method to initialize persistent properties on the object, as needed.
// abstract method
<@doc=>
Notifies that an object property has been updated
The object that was updated
The name of the property that was updated
The new property value
The old property value
event onUpdateObject(object, name, value, oldval);
<@doc>
Notifies that an object has been renamed
The object that was renamed
The new object name
The old object name
event onRenameObject(object, newname, oldname);