UnicodeNamedArraylist class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 2: Line 2:
The <var>UnicodeNamedArraylist</var> class is nearly identical to the <var>[[NamedArraylist class|NamedArraylist]]</var> class. The main difference is that instead of EBCDIC subscript names for items as in the <var>NamedArraylist</var> class, the name subscripts in a <var>UnicodeNamedArraylist</var> object are Unicode values. <var>UnicodeNamedArraylist</var> items are stored by item name in Unicode order, whereas <var>NamedArraylist</var> items are stored by item name in EBCDIC order.
The <var>UnicodeNamedArraylist</var> class is nearly identical to the <var>[[NamedArraylist class|NamedArraylist]]</var> class. The main difference is that instead of EBCDIC subscript names for items as in the <var>NamedArraylist</var> class, the name subscripts in a <var>UnicodeNamedArraylist</var> object are Unicode values. <var>UnicodeNamedArraylist</var> items are stored by item name in Unicode order, whereas <var>NamedArraylist</var> items are stored by item name in EBCDIC order.


<var>UnicodeNamedArraylists</var> were added in <var class="product">Sirius Mods</var> version 7.6.
'''Note:''' The names of <var>UnicodeNamedArraylists</var> are limited to 127 characters (versus 255 bytes for <var>NamedArraylists</var>).
==About the GenericNamedArraylist class==
The <var>UnicodeNamedArraylist</var> class extends the system <var>[[GenericNamedArraylist class|GenericNamedArraylist]]</var> class, so many of the methods available in the <var>UnicodeNamedArraylist</var> class are documented as belonging to the <var>GenericNamedArraylist</var> class. Any method available in the<var>GenericNamedArraylist</var> class is also available in the <var>UnicodeNamedArraylist</var> class.
The <var>UnicodeNamedArraylist</var> class extends the system <var>[[GenericNamedArraylist class|GenericNamedArraylist]]</var> class, so many of the methods available in the <var>UnicodeNamedArraylist</var> class are documented as belonging to the <var>GenericNamedArraylist</var> class. Any method available in the<var>GenericNamedArraylist</var> class is also available in the <var>UnicodeNamedArraylist</var> class.
   
   
UnicodeNamedArraylists were added in ''Sirius Mods'' version 7.6.
==Example==
'''Note:'''
The names of UnicodeNamedArraylists are limited to 127 characters (versus
255 bytes for NamedArraylists).
The following annotated request demonstrates the
The following annotated request demonstrates the
methods where the distinction between a UnicodeNamedArraylist
methods where the distinction between a <var>UnicodeNamedArraylist</var> and a <var>NamedArraylist</var> is significant.
and a NamedArraylist is significant.
The <var>[[U (String function)|U]]</var> constant function handily creates <var>Unicode</var> strings
The [[U (String function)|U]] constant function handily creates Unicode strings
in the item name subscripts.
in the item name subscripts.
Those names also begin with an
Those names also begin with an XHTML [[XML processing in Janus SOAP#Entity references|entity reference]].
XHTML entity reference, which is further discussed [[??]] reftxt=* refid=entrefs..
<p class="code">b
<!-- pre style="xmp" -->
    b
   
   
    %i  is float
%i  is float
    %k  is unicodeNamedArraylist of longstring
%k  is unicodeNamedArraylist of longstring
    %m  is Arraylist of longstring
%m  is Arraylist of longstring
    %k = new
%k = new
   
   
    '''* implicit Item method sets list item values:'''
'''* implicit Item method sets list item values:'''
    %k('&amp;sect;Jan':u) = 'Orion'
%k('&amp;sect;Jan':u) = 'Orion'
    %k('&amp;sect;Apr':u) = 'Leo'
%k('&amp;sect;Apr':u) = 'Leo'
    %k('&amp;sect;Mar':u) = 'Cancer'
%k('&amp;sect;Mar':u) = 'Cancer'
    %k('&amp;sect;Jun':u) = 'Ursa Minor'
%k('&amp;sect;Jun':u) = 'Ursa Minor'
    %k('&amp;sect;Nov':u) = 'Andromeda'
%k('&amp;sect;Nov':u) = 'Andromeda'
    %k('&amp;sect;Dec':u) = 'Aries'
%k('&amp;sect;Dec':u) = 'Aries'
    %k('&amp;sect;Feb':u) = 'Canis Major'
%k('&amp;sect;Feb':u) = 'Canis Major'
   
   
    '''* print the value of the item whose name is the'''
'''* print the value of the item whose name is the Item method argument:'''
    '''* Item method argument:'''
print %k:Item('&amp;sect;Jan':u)
    print %k:Item('&amp;sect;Jan':u)
   
   
    '''* print item number of named item:'''
'''* print item number of named item:'''
    print %k:number('&amp;sect;Nov':u)
print %k:number('&amp;sect;Nov':u)
   
   
    '''* print name of each list item, in order of item position'''
'''* print name of each list item, in order of item position from first to last:'''
    '''* from first to last:'''
for %i from 1 to %k:count
    for %i from 1 to %k:count
  print %i ': ' %k:nameByNumber(%i)
      print %i ': ' %k:nameByNumber(%i)
end for
    end for
   
   
    '''* how many items remain after specified item is removed?'''
'''* how many items remain after specified item is removed?'''
    printText {~} = {%k:removeItem('&amp;sect;Dec':u)}
printText {~} = {%k:removeItem('&amp;sect;Dec':u)}
   
   
    '''* names and values of list items in order by item position:'''
'''* names and values of list items in order by item position:'''
    for %i from 1 to %k:count
for %i from 1 to %k:count
      print %k:nameByNumber(%i) ': ' and %k:itembyNumber(%i)
  print %k:nameByNumber(%i) ': ' and %k:itembyNumber(%i)
    end for
end for
   
   
    '''* sort list values alphabetically in descending order'''
'''* sort list values alphabetically in descending order'''
    %m = %k:sortNew(descending(this))
%m = %k:sortNew(descending(this))
    %m:print
%m:print
   
   
    end
end
<!-- /pre -->
</p>
   
   
The request prints:
The request prints:
<pre style="xmp">
<p class="output">Orion
    Orion
7
    7
1: &sect;Apr
    1: &sect.Apr
2: &sect;Dec
    2: &sect.Dec
3: &sect;Feb
    3: &sect.Feb
4: &sect;Jan
    4: &sect.Jan
5: &sect;Jun
    5: &sect.Jun
6: &sect;Mar
    6: &sect.Mar
7: &sect;Nov
    7: &sect.Nov
%k:removeItem('&amp;sect;Dec':u) = 6
    %k:removeItem('&amp;sect;Dec':u) = 6
&sect;Apr:  Leo
    &sect.Apr:  Leo
&sect;Feb:  Canis Major
    &sect.Feb:  Canis Major
&sect;Jan:  Orion
    &sect.Jan:  Orion
&sect;Jun:  Ursa Minor
    &sect.Jun:  Ursa Minor
&sect;Mar:  Cancer
    &sect.Mar:  Cancer
&sect;Nov:  Andromeda
    &sect.Nov:  Andromeda
1: Ursa Minor
    1: Ursa Minor
2: Orion
    2: Orion
3: Leo
    3: Leo
4: Canis Major
    4: Canis Major
5: Cancer
    5: Cancer
6: Andromeda
    6: Andromeda
</p>
</pre>
For background information about collections and about
declaring collection object variables,
see [[Collections]].
See also [[Collections#Coding considerations for collections|Coding considerations for
collections]].
   
   
The individual UnicodeNamedArraylist methods are described in the following subsections.
==List of UnicodeNamedArraylist methods==
In the method templates, <tt>%unamrayl</tt> is used to represent the object
The [[List of UnicodeNamedArraylist methods|"List of UnicodeNamedArraylist methods"]] shows all the class methods, with a brief description of each.
to which the method is being applied, sometimes called the &ldquo;method object&rdquo;
 
or the &ldquo;method UnicodeNamedArraylist.&rdquo;
Additional conventions are described in [[Notation conventions for methods]].
==See also==
==See also==
<table>
<table>
Line 104: Line 91:
<tr><th>[[List of FloatNamedArraylist methods]]</th>
<tr><th>[[List of FloatNamedArraylist methods]]</th>
<td>For a list of all methods in the <var>FloatNamedArraylist</var> class, with a brief description of each.</td></tr>
<td>For a list of all methods in the <var>FloatNamedArraylist</var> class, with a brief description of each.</td></tr>
<tr><th>[[List of UnicodeNamedArraylist methods]]</th>
<td>For a list of all methods in the <var>UnicodeNamedArraylist</var> class, with a brief description of each.</td></tr>
<tr><th>[[Collections]]</th>
<tr><th>[[Collections]]</th>
<td>For background information about collections and <var>Arraylist</var>s and about
<td>For background information about collections and <var>Arraylist</var>s and about

Revision as of 22:24, 23 December 2011

The UnicodeNamedArraylist class is nearly identical to the NamedArraylist class. The main difference is that instead of EBCDIC subscript names for items as in the NamedArraylist class, the name subscripts in a UnicodeNamedArraylist object are Unicode values. UnicodeNamedArraylist items are stored by item name in Unicode order, whereas NamedArraylist items are stored by item name in EBCDIC order.

UnicodeNamedArraylists were added in Sirius Mods version 7.6.

Note: The names of UnicodeNamedArraylists are limited to 127 characters (versus 255 bytes for NamedArraylists).

About the GenericNamedArraylist class

The UnicodeNamedArraylist class extends the system GenericNamedArraylist class, so many of the methods available in the UnicodeNamedArraylist class are documented as belonging to the GenericNamedArraylist class. Any method available in theGenericNamedArraylist class is also available in the UnicodeNamedArraylist class.

Example

The following annotated request demonstrates the methods where the distinction between a UnicodeNamedArraylist and a NamedArraylist is significant. The U constant function handily creates Unicode strings in the item name subscripts. Those names also begin with an XHTML entity reference.

b %i is float %k is unicodeNamedArraylist of longstring %m is Arraylist of longstring %k = new * implicit Item method sets list item values: %k('&sect;Jan':u) = 'Orion' %k('&sect;Apr':u) = 'Leo' %k('&sect;Mar':u) = 'Cancer' %k('&sect;Jun':u) = 'Ursa Minor' %k('&sect;Nov':u) = 'Andromeda' %k('&sect;Dec':u) = 'Aries' %k('&sect;Feb':u) = 'Canis Major' * print the value of the item whose name is the Item method argument: print %k:Item('&sect;Jan':u) * print item number of named item: print %k:number('&sect;Nov':u) * print name of each list item, in order of item position from first to last: for %i from 1 to %k:count print %i ': ' %k:nameByNumber(%i) end for * how many items remain after specified item is removed? printText {~} = {%k:removeItem('&sect;Dec':u)} * names and values of list items in order by item position: for %i from 1 to %k:count print %k:nameByNumber(%i) ': ' and %k:itembyNumber(%i) end for * sort list values alphabetically in descending order %m = %k:sortNew(descending(this)) %m:print end

The request prints:

Orion 7 1: §Apr 2: §Dec 3: §Feb 4: §Jan 5: §Jun 6: §Mar 7: §Nov %k:removeItem('&sect;Dec':u) = 6 §Apr: Leo §Feb: Canis Major §Jan: Orion §Jun: Ursa Minor §Mar: Cancer §Nov: Andromeda 1: Ursa Minor 2: Orion 3: Leo 4: Canis Major 5: Cancer 6: Andromeda

List of UnicodeNamedArraylist methods

The "List of UnicodeNamedArraylist methods" shows all the class methods, with a brief description of each.

See also

List of NamedArraylist methods For a list of all methods in the NamedArraylist class, with a brief description of each.
List of FloatNamedArraylist methods For a list of all methods in the FloatNamedArraylist class, with a brief description of each.
Collections For background information about collections and Arraylists and about declaring Arraylist object variables.
Coding considerations for collections For tips on using collections.