Home > Class Reference > ENSLIB namespace > %Library.ArrayOfObjects

%Library.ArrayOfObjects

serial class %Library.ArrayOfObjects extends %Collection.AbstractArrayOfObj, %Library.SerialObject

The %ArrayOfObjects class represents an array of references to objects, each of which is associated with a unique key value. Keys can have any value, string or numeric. The objects referred to must be registered. They can be either persistent objects or non-id objects.

Internally, an %ArrayOfObjects object contains two arrays: one for holding the OID values for the objects referred to (or their serialized state in the case of an array of non-id objects); and another for holding the OREF values for any objects that have been explicitly referred to, and hence "swizzled" into memory. Swizzling (loading an object into memory and generating an OREF value for it) happens automatically whenever the user refers to an object within the array.

For example, if array is an %ArrayOfObjects object containing an array of Doctor objects (that is an array of OID values for Doctor objects stored in the database) then the following code fragment will automatically load the Doctor object associated with the key "Primary" into memory and generate an OREF value referring to the in-memory version of the Doctor object. This OREF value can then be used to access the properties and methods of the Doctor object:

  Set doc=array.GetAt("Primary")
  Write doc.Name
  

Alternatively, we could use cascading dot syntax:

  Set name=array.GetAt("Primary").Name
  

When the %ArrayOfObjects object is closed (removed from memory) it will close (call %Close on) all of the references it has swizzled into memory. These classes can be used 'stand alone' to store a collection.

Property Inventory (Including Private)

Method Inventory (Including Private)

Parameters

parameter CLASSNAMEINOID = 0;
This parameter determines how the collection object stores OID values. If this parameter is set to 0, then partially-formed OID values, containing only an ID number, are used. If this parameter is set to 1, then fully-formed OID values, containing both a class name and an ID number, are used.
parameter ELEMENTTYPE = %RegisteredObject;
The type (class name) of the elements stored in the collection.

Properties (Including Private)

property Data as %String [ MultiDimensional ];
Data is a private property used to hold the contents of the array.
Property methods: DataDisplayToLogical(), DataGet(), DataIsValid(), DataLogicalToDisplay(), DataLogicalToOdbc(), DataNormalize(), DataSet()
property ElementType as %String (MAXLEN = 256) [ InitialExpression = ..#ELEMENTTYPE ];
The type (class name) of the elements stored in the collection.
Property methods: ElementTypeDisplayToLogical(), ElementTypeGet(), ElementTypeIsValid(), ElementTypeLogicalToDisplay(), ElementTypeLogicalToOdbc(), ElementTypeNormalize(), ElementTypeSet()
property Oref as %String [ MultiDimensional ];
Private storage area used to hold OREF values.
Property methods: OrefDisplayToLogical(), OrefGet(), OrefIsValid(), OrefLogicalToDisplay(), OrefLogicalToOdbc(), OrefNormalize(), OrefSet()

Methods (Including Private)

method %AddToSaveSet(force As %Integer = 0, refresh As %Integer = 0) as %Status
Overrides %SerialObject implementation. Scans objects for modifications in the related list (Element) and the terminated relationship list (DeleteOref). Modified/Scheduled to delete objects are added to the save graph.
private method %GetSerial(force As %Integer = 0) as %String
private method %OnConstructClone(oref As %RegisteredObject, deep As %Boolean = 0, ByRef cloned As %String) as %Status
Inherited description: This callback method is invoked by the %ConstructClone() method to provide notification that a clone of an object is being created. It passes in the oref of the object that was cloned in object.

If this method returns an error then the object will not be created.

private method %OnNew(initvalue As %String) as %Status
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

method %SerializeObject(ByRef serial As %Binary, partial As %Integer = 0) as %Status
Inherited description: This method retrieves all of the serial values for referenced objects and places them into the instance variables, Validates, Normalizes, and serializes the object (with a save of the persistent image if persistent).
This method is not meant to be called directly. It is called by %Save and by %GetSwizzleObject.
private method %SetSerial(serialized As %String) as %Status