      *>----------------------------------------------------------------
      *> System Dictionary class. Enables you to store objects
      *> associated with 32 character keys. The class library uses this
      *> class; all class library keys are prefixed by the letters
      *> "MFCL".
      *>
      *> You can't create instances of this class, as by definition only
      *> one SystemDictionary exists.
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd.
      *>
      *>----------------------------------------------------------------
      $set mfoo
       class-id. systemDictionary  is abstract data is protected
               inherits from Base with data.


        object section.
        class-control.
           SystemDictionary is class "systemd"
           IdentityDictionary is class "idictnry"
           Association is class "associtn"
           cobolpicx32 is class "picx32".

       class-object.

       object-storage section.
       01 namedDictionary  usage object reference.

      *>----------------------------------------------------------------
      *> PRIVATE. initialize class data
      *>----------------------------------------------------------------
       method-id. "initializeclass".
       local-storage section.
       01 valueType        usage object reference.
       01 assocTemplate    usage object reference.
       01 initialSize      pic x(4) comp-5.

       procedure division.
           invoke super "initializeclass"
           if namedDictionary = null then
               *>> Create the named dictionary
               set valueType to null
               invoke Association "newClass" using CobolPicx32 valuetype
                                           returning assocTemplate
               move 20 to initialSize
               invoke IdentityDictionary "ofValues" using assocTemplate
                                                      initialSize
                                            returning namedDictionary
           end-if
           exit method.
       end method "initializeclass".

      *>----------------------------------------------------------------
      *> Should not create instances of this class so override new to
      *> prevent it.
      *>----------------------------------------------------------------
       method-id. "new".
       linkage section.
       01 result           usage object reference.
       procedure division returning result.
           invoke self "shouldNotImplement" returning result
           exit method.
       end method "new".

      *>----------------------------------------------------------------
      *> Store the object lnkValue against the 32 byte key lnkKey
      *>----------------------------------------------------------------

       method-id. "atPut".
       linkage section.
       01 lnkKey           pic x(32).
       01 lnkValue         usage object reference.

       procedure division using lnkKey lnkValue.
           invoke namedDictionary "atput" using lnkKey lnkValue
           exit method.
       end method "atPut".
      *>----------------------------------------------------------------
      *> Retrieve the object associated with the 32 byte key lnkKey.
      *> If the key is not present then return null.
      *>----------------------------------------------------------------

       method-id. "at".
       local-storage section.
       01 aBool    pic x comp-5.
           88 keyIsIncluded   value 1.
           88 keyIsNotIncluded value 0.

       linkage section.
       01 lnkKey           pic x(32).
       01 lnkValue         usage object reference.

       procedure division using lnkKey  returning lnkValue.
           invoke namedDictionary "atornil" using lnkKey
                                   returning lnkValue
           exit method.
       end method "at".
      *>----------------------------------------------------------------
      *> Retrieve the object associated with the null terminated
      *> string lnkKey. LnkKey can be a maximum of 32 bytes excluding
      *> the null character.
      *> If the key is not present then return null.
      *>----------------------------------------------------------------

       method-id. "atz".
       local-storage section.
       01 spaceFilledKey   pic x(32).
       01 i                pic x(4) comp-5.
       linkage section.
       01 lnkKey           pic x(33).
       01 lnkValue         usage object reference.

       procedure division using lnkKey returning lnkValue.
           perform varying i from 1 by 1 until i > 33 or
               lnkKey(i:1) = x"00"
           end-perform
           subtract 1 from i
           move lnkKey(1:i) to spaceFilledKey
           invoke self "at" using spaceFilledKey returning lnkValue
           exit method.
       end method "atz".
      *>----------------------------------------------------------------
      *> Store the object lnkValue against the null terminated string,
      *> lnkKey. LnkKey can be a maximum of 32 bytes excluding the null
      *> character.
      *>----------------------------------------------------------------

       method-id. "atzPut".
       local-storage section.
       01 spaceFilledKey   pic x(32).
       01 i                pic x(4) comp-5.
       linkage section.
       01 lnkKey           pic x(33).
       01 lnkValue         usage object reference.

       procedure division using lnkKey lnkValue.
           perform varying i from 1 by 1 until i > 33 or
               lnkKey(i:1) = x"00"
           end-perform
           subtract 1 from i
           move lnkKey(1:i) to spaceFilledKey
           invoke self "atPut" using spaceFilledKey lnkValue
           exit method.
       end method "atzPut".
      *>----------------------------------------------------------------
      *> If the 32 byte key lnkKey is stored in the dictionary, then
      *> remove it and its associated value.
      *>----------------------------------------------------------------

       method-id. "removeKey".
       local-storage section.
       01 aBool    pic x comp-5.
           88 keyIsIncluded   value 1.
           88 keyIsNotIncluded value 0.
       linkage section.
       01 lnkKey           pic x(33).

       procedure division using lnkKey.
           invoke namedDictionary "includesKey" using lnkKey
               returning aBool
           if keyIsIncluded
               invoke namedDictionary "removeKey" using lnkKey
           end-if
           exit method.
       end method "removeKey".
      *>----------------------------------------------------------------
      *> If the null terminated key lnkKey is stored in the dictionary,
      *> then remove it and its associated value.
      *>----------------------------------------------------------------

       method-id. "removeKeyz".
       local-storage section.
       01 spaceFilledKey   pic x(32).
       01 i                pic x(4) comp-5.
       linkage section.
       01 lnkKey           pic x(33).

       procedure division using lnkKey.
           perform varying i from 1 by 1 until i > 33 or
               lnkKey(i:1) = x"00"
           end-perform
           subtract 1 from i
           move lnkKey(1:i) to spaceFilledKey
           invoke self "removeKey" using spaceFilledKey
           exit method.
       end method "removeKeyz".
       end class-object.

       object.
       object-storage section.
       end object.
       end class systemDictionary.
