An object view causes the compiler to treat an object reference (e.g. within the framework of conformance checks) as if it were defined in the specified form. If required, runtime checks are performed to ensure that the current contents of the object reference have the required properties.
Format
identifier-1 AS { [
FACTORY OF] class-name-1 [ONLY]
| interface-name-1
| UNIVERSAL
}
Syntax rules
identifier-1 must be an object reference or a predefined object identifier, which must not be SUPER or NULL or a further object view.
identifier-1 may also be a class name.
The object view may not be specified as a receiving operand.
General rules
An object view returns an object reference that points to the same object as identifier-1 and assumes the same interface for conformance checks as specified in the AS phrase.
If class-name-1 is specified without either of the optional phrases, the implicit result is the same as for USAGE IS OBJECT REFERENCE class-name-1. If the object referenced by identifier-1 is not an object of class-name-1 or a subclass of class-name-1, an exception condition EC-OO-CONFORMANCE occurs.
If the FACTORY phrase is specified without the ONLY phrase, the implicit result is the same as for USAGE IS OBJECT REFERENCE class-name-1. If the object referenced by identifier-1 is not the factory object of class-name-1 or a subclass of class-name-1, an exception condition EC-OO-CONFORMANCE occurs.
If the ONLY phrase is specified and the FACTORY phrase is not specified, the implicit result is the same as for USAGE OBJECT REFERENCE class-name-1 ONLY. If the object referenced by identifier-1 is not an object of class-name-1, an exception condition EC-OO-CONFORMANCE occurs.
If both the FACTORY phrase and the ONLY phrase are specified, the implicit result is the same as for USAGE OBJECT REFERENCE class-name-1 ONLY. If the object referenced by identifier-1 is not the factory object of class-name-1, an exception EC-OO-CONFORMANCE condition occurs.
If interface-name-1 is specified, the implicit result is the same as for USAGE OBJECT REFERENCE interface-name-1. If the object referenced by identifier-1 does not conform to interface-name-1, an exception condition EC-OO-CONFORMANCE occurs.
If UNIVERSAL is specified, the implicit result is the same as for USAGE OBJECT REFERENCE without any of the optional phrases. No exception condition occurs.
If the exception condition EC-OO-CONFORMANCE has occurred and the check for this exception condition is activated, the associated exception status is triggered and control is transferred to the relevant USE procedure.