PersistentObjectInfo class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The <var>PersistentObjectInfo</var> class contains information about a [[Global and session objects|global or session object]] in the current thread. Persistent information was typically stored in <var>Stringlists</var> (or <var>$lists</var>), and individual values all began at designated columns. This approach at least allowed for the sorting of these values.
The <var>PersistentObjectInfo</var> class contains information about a [[Global and session objects|global or session object]] in the current thread (note that global and session objects are different from <var>[[Local and Common entities#Persistent and Shared local variables|Persistent variables]]</var>).
But the availability of generic sorting for <var>Arraylists</var> makes <var>Arraylists</var> of information objects the correct way to provide information to <var class="product">User Language</var>:
<ul>
<li>It eliminates the reliance on column positions in <var class="product">User Language</var> code.
   
   
<li>It makes it possible to change the size of values or to add information to the
<var>PersistentObjectInfo</var>
Info class in the future without breaking existing applications.
objects offer the advantage of the sorting, finding, and subsetting facilities of
</ul>
collections.
   
   
In addition to occupying considerably less space than fixed column $lists, <var>PersistentObjectInfo</var>
objects also offer the advantage of the sorting, finding, and subsetting facilities of
collections.
The <var>PersistentObjectInfo</var> class is available as of <var class="product">Sirius Mods</var> Version 7.8.
The <var>PersistentObjectInfo</var> class is available as of <var class="product">Sirius Mods</var> Version 7.8.
 
The [[List of PersistentObjectInfo methods|"List of PersistentObjectInfo methods"]] lists all the methods in this class.
 
==The information accessing methods==
==The information accessing methods==
Three pieces of information (provided by class functions named as follows) are available for a global or
Three pieces of information (provided by class functions named as follows) are available for a global or
session object in the <var>PersistentObjectInfo</var> class:
session object in the <var>PersistentObjectInfo</var> class:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><td><var>Name</var></td>
<tr><td><var>[[Name (PersistentObjectInfo function)|Name]]</var></td>
<td>The global/session name associated with the object.</td></tr>
<td>The global/session name associated with the object.</td></tr>
<tr><td><var>SetTime</var></td>
<tr><td><var>[[SetTime (PersistentObjectInfo function)|SetTime]]</var></td>
<td>The time the global/session object was set in YYYYMMDDHHMISSXXX format.
<td>The time the global/session object was set (YYYYMMDDHHMISSXXX format).
<tr><td><var>ClassDescription</var></td>
<tr><td><var>[[ClassDescription (PersistentObjectInfo function)|ClassDescription]]</var></td>
<td>A description of the class of the object. For example, "System:Stringlist", or "MyUserLanguageClass", or "Arraylist of Object MyUserLanguageClass".  
<td>A description of the class of the object. For example, "System:Stringlist", or "MyUserLanguageClass", or "Arraylist of Object MyUserLanguageClass".
</td></tr></table>
</td></tr></table>
   
   
Line 33: Line 24:
<var>SetTime</var> does '''not''' change if request <code>A</code> sets a variable to an object
<var>SetTime</var> does '''not''' change if request <code>A</code> sets a variable to an object
instance, and then request <code>B</code> sets it to a new value, <var>SetTime</var> still indicates
instance, and then request <code>B</code> sets it to a new value, <var>SetTime</var> still indicates
the time the object reference was set in request <code>A</code>.  
the time the object reference was set in request <code>A</code>.
   
   
<li>The format of the data in <var>ClassDescription</var> is subject to change by Sirius; for example, a change in casing.
<li>The format of the data in <var>ClassDescription</var> is subject to change by Rocket; for example, a change in casing.
</ul>
</ul>
 
==Creating PersistentObjectInfo objects==
==Creating PersistentObjectInfo objects==
===Using NewFromGlobal or NewFromSession===
===Using NewFromGlobal or NewFromSession===
One way of creating a <var>PersistentObjectInfo</var> object is with the <var>[[NewFromGlobal (PersistentObjectInfo function)|NewFromGlobal]]</var> method
One way of creating a <var>PersistentObjectInfo</var> object is with the <var>[[NewFromGlobal (PersistentObjectInfo function)|NewFromGlobal]]</var> method
or the <var>[[NewFromSession (PersistentObjectInfo function)|NewFromSession]]</var>
or the <var>[[NewFromSession (PersistentObjectInfo function)|NewFromSession]]</var>
method. These methods take a single, required, unnamed string parameter which indicates the name
method. These methods take a single, required, unnamed string parameter that indicates the name
of the global or session variable:
of the global or session variable:
<p class="code">%persInfo    is object persistentObjectInfo
<p class="code">%persInfo    is object persistentObjectInfo
Line 53: Line 44:
</p>
</p>
   
   
A <var>NewFromSession</var> request cancels if not in a session.  
A <var>NewFromSession</var> request cancels if not in a session.
 
===Using GlobalList or SessionList===
===Using GlobalList or SessionList===
Probably the most common way of creating <var>PersistentObjectInfo</var> objects is using
Probably the most common way of creating <var>PersistentObjectInfo</var> objects is using
the <var>GlobalList</var> and <var>SessionList</var> methods. These are [[Notation conventions for methods#Shared methods|shared]] methods that return an
the <var>[[GlobalList (PersistentObjectInfo function)|GlobalList]]</var> and <var>[[SessionList (PersistentObjectInfo function)|SessionList]]</var> methods. These are [[Notation conventions for methods#Shared methods|shared]] methods that return an <var>Arraylist of Object PersistentObjectInfo</var>.
<var>Arraylist of Object PersistentObjectInfo</var>.  
 
The <var>GlobalList</var> and <var>SessionList</var> methods have one
The <var>GlobalList</var> and <var>SessionList</var> methods have one
optional parameter that contains the name of the variables to be returned, with wildcards allowed.
optional parameter that contains the name of the variables to be returned, with wildcards allowed.
Line 73: Line 63:
end for
end for
</p>
</p>
 
==The PersistentObjectInfoList type==
==The PersistentObjectInfoList type==
As a coding convenience, this Info class feature also introduces a new <var class="product">User Language</var> %variable declaration type: <var>PersistentObjectInfoList</var>.
As a coding convenience, the <var>PersistentObjectInfoList</var>
This type is defined as an "Arraylist of Object PersistentObjectInfo". Consequently, you can specify a declaration like the one in the preceding example for <code>%persInfoList</code> more simply as:
type is defined as an "Arraylist of Object PersistentObjectInfo". Consequently, you can specify a declaration like the one in the preceding example for <code>%persInfoList</code> more simply as:
<p class="code">%persInfoList is type persistentObjectInfoList</p>
<p class="code">%persInfoList is type persistentObjectInfoList</p>
 
'''Note:''' The keyword <var>Type</var> is required.
'''Note:''' The keyword <var>Type</var> is required.
   
   
==The GlobalList and SessionList Object class methods==
==The GlobalList and SessionList Object class methods==
The <var>GlobalList</var> and <var>SessionList</var> methods are members of two classes.
The <var>GlobalList</var> and <var>SessionList</var> methods are members of two classes.
In addition to belonging to the <var>PersistentObjectInfo</var> class, they are also <var>[[Object class|Object]]</var> class shared methods. This means that both of these statements are valid:  
In addition to belonging to the <var>PersistentObjectInfo</var> class, they are also <var>[[Object class|Object]]</var> class shared methods. This means that both of these statements are valid:
   
   
<p class="code">%persInfoList = %(persistentObjectInfo):globalList
<p class="code">%persInfoList = %(persistentObjectInfo):globalList
   
   
%persInfoList = %(object):globalList</p>
%persInfoList = %(object):globalList</p>
 
And a statement like the following is also valid:
And a statement like the following is also valid:
  <p class="code">%persInfoList = %(object):globalList:sortNew(descending(setTime))</p>
  <p class="code">%persInfoList = %(object):globalList:sortNew(descending(setTime))</p>
 
In this last case, the class name before the <var>GlobalList</var> method is unavoidable.
==List of PersistentObjectInfo methods==
The [[List of PersistentObjectInfo methods]] contains a complete list of the class methods.
 
[[Category:System classes]]

Latest revision as of 18:23, 27 August 2014

The PersistentObjectInfo class contains information about a global or session object in the current thread (note that global and session objects are different from Persistent variables).

PersistentObjectInfo objects offer the advantage of the sorting, finding, and subsetting facilities of collections.

The PersistentObjectInfo class is available as of Sirius Mods Version 7.8.

The information accessing methods

Three pieces of information (provided by class functions named as follows) are available for a global or session object in the PersistentObjectInfo class:

Name The global/session name associated with the object.
SetTime The time the global/session object was set (YYYYMMDDHHMISSXXX format).
ClassDescription A description of the class of the object. For example, "System:Stringlist", or "MyUserLanguageClass", or "Arraylist of Object MyUserLanguageClass".

SetTime and ClassDescription are intended for debugging and problem diagnosis and not for application purposes:

  • For Global/Session variable declarations, SetTime does not change if request A sets a variable to an object instance, and then request B sets it to a new value, SetTime still indicates the time the object reference was set in request A.
  • The format of the data in ClassDescription is subject to change by Rocket; for example, a change in casing.

Creating PersistentObjectInfo objects

Using NewFromGlobal or NewFromSession

One way of creating a PersistentObjectInfo object is with the NewFromGlobal method or the NewFromSession method. These methods take a single, required, unnamed string parameter that indicates the name of the global or session variable:

%persInfo is object persistentObjectInfo ... %persInfo = newFromGlobal('FOOBAR') printText *** {~} = {%persInfo:name}, {~} = {%persInfo:setTime}, {~} = {%persInfo:classDescription} ... %persInfo = newFromSession('SNAFU') printText *** {~} = {%persInfo:name}, {~} = {%persInfo:setTime}, {~} = {%persInfo:classDescription}

A NewFromSession request cancels if not in a session.

Using GlobalList or SessionList

Probably the most common way of creating PersistentObjectInfo objects is using the GlobalList and SessionList methods. These are shared methods that return an Arraylist of Object PersistentObjectInfo.

The GlobalList and SessionList methods have one optional parameter that contains the name of the variables to be returned, with wildcards allowed. These wildcards are the User Language standard, non-regex, wildcards. Specifying no variable name is the same as specifying an asterisk (*) for the variable name: the information is returned for all global or session objects.

For example:

%persInfoList is arraylist of object persistentObjectInfo ... %persInfoList = %(persistentObjectInfo):globalList for %i from 1 to %persInfoList:count printText *** {~} = {%i}, {~} = {%persInfoList(%i):name}, {~} = {%persInfoList(%i):classDescription} end for

The PersistentObjectInfoList type

As a coding convenience, the PersistentObjectInfoList type is defined as an "Arraylist of Object PersistentObjectInfo". Consequently, you can specify a declaration like the one in the preceding example for %persInfoList more simply as:

%persInfoList is type persistentObjectInfoList

Note: The keyword Type is required.

The GlobalList and SessionList Object class methods

The GlobalList and SessionList methods are members of two classes. In addition to belonging to the PersistentObjectInfo class, they are also Object class shared methods. This means that both of these statements are valid:

%persInfoList = %(persistentObjectInfo):globalList %persInfoList = %(object):globalList

And a statement like the following is also valid:

%persInfoList = %(object):globalList:sortNew(descending(setTime))

List of PersistentObjectInfo methods

The List of PersistentObjectInfo methods contains a complete list of the class methods.