      *>----------------------------------------------------------------
      *> DOCS-ROOT.
      *> An instance of association stores key/data pairs. The key and
      *> data must both be objects, unless Association is cloned (by
      *> sending it the "newClass" message) to provide a class where
      *> the key, data, or both are intrinsics.
      *>
      *>#See the method "newClass".
      *>
      *> Association is mostly used in conjunction with the Dictionary
      *> and IdentityDictionary classes. Either Association (or a clone
      *> of the Association class) is used as a template for
      *> instantiating a dictionary "ofValues", or instances of
      *> Association are stored in a dictionary "ofAssociations".
      *>
      *>#See the class "dictinry" .
      *>#See the class "idictnry".
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd.
      *>
      *>----------------------------------------------------------------
      $set linkcount(150) mfoo localCount(200)
       class-id. Association data is protected
               inherits from intrinsic with data.


        object section.
        class-control.
           intrinsic is class "intrnsic"
           association is class "associtn"
           CobolCOMP5Association is class "compasoc"
           CharacterArray is class "chararry"
           CobolComp5 is class "comp5"
           nilobject is class "nil".

       class-object.

       object-storage section.

      *>>---------------------------------------------------------------
      *>> Represents the size of the data to be stored for this
      *>> association class
      *>>---------------------------------------------------------------

          01 datasize         pic x(4) comp-5 value 0.

      *>>---------------------------------------------------------------
      *>> Represents the size of the key to be stored for this
      *>> association class
      *>>---------------------------------------------------------------
          01 keysize          pic x(4) comp-5 value 0.

      *>>---------------------------------------------------------------
      *>> Represents the type of key to be stored for this association
      *>> class
      *>>---------------------------------------------------------------

          01 keytemplate      usage object reference value null.

      *>>---------------------------------------------------------------
      *>> Represents the type of data to be stored for this association
      *>> class
      *>>---------------------------------------------------------------
          01 datatemplate     usage object reference value null.

      *>----------------------------------------------------------------
      *> PRIVATE. initialize class data
      *>----------------------------------------------------------------
       method-id. "initializeclass".
       procedure division.
           invoke super "initializeclass"
           set keytemplate to null
           set datatemplate to null
           move objectReferenceSize to keysize
                                       datasize
                                       storagerequirements
           add objectReferenceSize to storagerequirements
           exit method.
       end method "initializeclass".

      *>----------------------------------------------------------------
      *> Return a boolean indicating whether this static structure
      *> contains objects or not.
      *>----------------------------------------------------------------
       method-id. "storingObjects".
       linkage section.
       01 lnkBool                pic x comp-5.
        88 storingObjects       value 1.
        88 notstoringObjects       value 0.
       procedure division returning lnkBool.
           invoke keyTemplate "storingObjects" returning lnkBool
           if notStoringObjects
                invoke dataTemplate "storingObjects" returning lnkBool
           end-if
           exit method.
       end method "storingObjects".

      *>----------------------------------------------------------------
      *> Return a new instance of Association with the key set to
      *> aKey and the data set to aDatum. aKey and aDatum can be either
      *> objects or intrinsic data, depending on the templates used to
      *> clone the class.
      *>
      *> See the method "newClass".
      *>----------------------------------------------------------------
       method-id. "keyData".
       local-storage section.

       01 anassociation        usage object reference.

       linkage section.
       01 aDatum        pic x.
       01 defaultreturn        usage object reference.
       01 aKey          pic x.

       procedure division using aKey aDatum
                               returning defaultreturn.

           invoke self "key" using aKey
                                  returning anassociation
           invoke anassociation "setdata" using aDatum
           set defaultreturn to anassociation
           exit method.
       end method "keyData".
      *>----------------------------------------------------------------
      *> Return a new instance of Association with the key set to
      *> aKeyObject and the data set to low values or NULL depending on
      *> whether it is storing an intrinsic or an object. aKeyObject can
      *> be either an object or intrinsic data, depending on the template
      *> used to clone the class (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "key".
       local-storage section.

       01 newsize              pic x(4) comp-5.
       01 anassociation        usage object reference.
       01 anObject             usage object reference.
       linkage section.
       01 defaultreturn        usage object reference.
       01 akeyobject           pic x.

       procedure division using akeyobject returning defaultreturn.
           add keysize to datasize  giving newsize.
           invoke super "new" returning anassociation
           invoke anassociation "setkey" using akeyobject.
           set anObject to null
           invoke anassociation "setdata" using anObject
           set defaultreturn to anassociation
           exit method.
       end method "key".
      *>----------------------------------------------------------------
      *> Return Association as the base class for all clones of
      *> association.
      *>----------------------------------------------------------------
       method-id. "baseClass".
       linkage section.
       01 defaultreturn        usage object reference.

       procedure division returning defaultreturn.
           set defaultreturn to association
           exit method.
       end method "baseClass".
      *>----------------------------------------------------------------
      *> PRIVATE. Set the type of key to be stored in this template
      *> to aKeyType.
      *>----------------------------------------------------------------
       method-id. "setKeyType".
       linkage section.
       01 akeytype             usage object reference.

       procedure division using akeytype.
           subtract keysize from storagerequirements
           set keytemplate to akeytype
           if akeytype equal to null
               move objectReferenceSize to keysize
           else
               invoke akeytype "sizeInBytes" returning keysize
           end-if
           add keysize to storagerequirements
           exit method.
       end method "setKeyType".

      *>----------------------------------------------------------------
      *> PRIVATE. Set the type of data to be stored in this template
      *> to adataType.
      *>----------------------------------------------------------------
       method-id. "setDataType".
       linkage section.
       01 adatatype            usage object reference.

       procedure division using adatatype.
           subtract datasize from storagerequirements
           set datatemplate to adatatype
           if adatatype equal to null
               move objectReferenceSize to datasize
           else
               invoke adatatype "sizeInBytes" returning datasize
           end-if
           add datasize to storagerequirements
           exit method.
       end method "setDataType".

      *>----------------------------------------------------------------
      *> Return a new clone of the class Association. The
      *> parameters aKeyType and aDataType are templates to indicate
      *> the types of data being associated with each other.
      *>
      *> Set aKeyType or aDataType to null when either the key or data
      *> are objects. Set aKeyType or aDataType to clones of one of the
      *> intrinsic data subclasses if either the key or data are to
      *> be intrinsic COBOL data.
      *>
      *>#See the section Intrinsic Data.
      *>----------------------------------------------------------------
       method-id. "newClass".
       working-storage section.
       01 AssocComp5           usage object reference value null.

       local-storage section.

       01 exceptionnumber      pic s9(9) comp-5.
       01 i                    pic x(4) comp-5.
       01 j                    pic x(4) comp-5.
       01 k                    pic x(4) comp-5.

       linkage section.
       01 adatatype            usage object reference.
       01 akeytype             usage object reference.
       01 lnkclass              usage object reference.

       procedure division using akeytype adatatype
                           returning lnkclass.
          set lnkClass to null
          if aKeyType = null and adataType = null
              set lnkClass to Association
          else
              if aKeyType = CobolComp5 and adataType = null
                  set lnkClass to CobolCOMP5Association
              else
                  if aKeyType = null and adataType = CobolComp5
                      and AssocComp5 not = null
                      set lnkClass to AssocComp5
                  end-if
              end-if
          end-if

          if lnkClass = null
              invoke akeytype "sizeInBytes" returning i
              invoke adatatype "sizeInBytes" returning k
              add i to k
              invoke self "maximumSize" returning j
              if k > j
                  move 30 to exceptionnumber
                  invoke self "raiseException" using exceptionnumber
                                           returning lnkclass
              else
                  invoke self "basicCopy" returning lnkclass
                  invoke lnkclass "setDataType" using adatatype
                  invoke lnkclass "setKeyType" using akeytype
                  if aKeyType = null and adataType = CobolComp5
                      set AssocComp5 to lnkClass
                  end-if
              end-if
          end-if
          exit method.
       end method "newClass".
      *>----------------------------------------------------------------
      *> Answer the type of key being stored in this association
      *>----------------------------------------------------------------
       method-id. "getkeyTemplate".
       linkage section.
       01 atype                        usage object reference.

       procedure division returning atype.
           set atype to keytemplate
           exit method.
       end method "getkeyTemplate".

      *>----------------------------------------------------------------
      *> Answer the type of data being stored in this association
      *>----------------------------------------------------------------
       method-id. "getDataTemplate".
       linkage section.
       01 atype                        usage object reference.

       procedure division returning atype.
           set atype to datatemplate
           exit method.
       end method "getDataTemplate".
      *>----------------------------------------------------------------
      *> Answer the number of bytes required to store the key for this
      *> association type.
      *>----------------------------------------------------------------
       method-id. "getkeySize".
       linkage section.
       01 asize                pic x(4) comp-5.

       procedure division returning asize.
           move keysize to asize
           exit method.
       end method "getkeySize".
      *>----------------------------------------------------------------
      *> Answer the number of bytes required to store the data for this
      *> association type.
      *>----------------------------------------------------------------
       method-id. "getDataSize".
       linkage section.
       01 asize                pic x(4) comp-5.

       procedure division returning asize.
           move datasize to asize
           exit method.
       end method "getDataSize".

       end class-object.

       Object.

       object-storage section.

      *>----------------------------------------------------------------
      *> Display the key for this Association
      *>----------------------------------------------------------------
       method-id. "displayKey".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 kTemplate            usage object reference.

       procedure division.
           move 1 to i
           invoke selfClass "getkeyTemplate" returning ktemplate
           invoke selfClass "getkeySize" returning ksize
           if ktemplate equal to null
              invoke instancedata(i : objectreferencesize) as object
                  "display"
           else
              invoke instancedata(i: kSize) as ktemplate
                                              "display"
           end-if
           exit method.
       end method "displayKey".
      *>----------------------------------------------------------------
      *> Display the data for this association
      *>----------------------------------------------------------------
       method-id. "displayData".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 dSize                pic x(4) comp-5.
       01 dTemplate            usage object reference.
       01 kTemplate            usage object reference.

       procedure division.
           invoke selfClass "getdataTemplate" returning dtemplate
           invoke selfClass "getdataSize" returning dsize
           invoke selfClass "getkeySize" returning ksize
           move 1 to i
           add kSize to i
           if dtemplate equal to null
              invoke instancedata(i : objectreferencesize) as object
                  "display"
           else
              invoke instancedata(i: dSize) as dtemplate
                                              "display"
           end-if
           exit method.
       end method "displayData".
      *>----------------------------------------------------------------
      *> Return true if the receiver's key is equal to the
      *> intrinsic key defined by aLength and akeyObject otherwise
      *> return false. aKeyObject can be either an object or intrinsic
      *> data, depending on the template used to clone the class
      *> (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "equalbyLengthValue".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 kTemplate            usage object reference.

       linkage section.
       01 aLength              pic x(4) comp-5.
       01 lnkbool              pic x comp-5.
           88 lnkistrue        value 1.
           88 lnkisfalse       value 0.
       01 akeyobject           pic x.

       procedure division using alength akeyobject
                                  returning lnkbool.
           move 1 to i
           invoke selfClass "getkeyTemplate" returning ktemplate
           invoke selfClass "getkeySize" returning ksize
           if ktemplate equal to null
               invoke instancedata(i:objectreferencesize)
                    as object "equal" using akeyobject
                                          returning lnkbool
           else
               invoke instancedata(i:ksize) as ktemplate
                                            "equalbyLengthValue"
                                       using kSize akeyobject
                                   returning lnkbool
           end-if
           exit method.
       end method "equalbyLengthValue".
      *>----------------------------------------------------------------
      *> Return true if the receiver's key is less than the
      *> intrinsic key defined by aLength and akeyObject otherwise
      *> return false. aKeyObject can be either an object or intrinsic
      *> data, depending on the template used to clone the class
      *> (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "lessThanbyLengthValue".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 kTemplate            usage object reference.

       linkage section.
       01 aLength              pic x(4) comp-5.
       01 lnkbool              pic x comp-5.
           88 lnkistrue        value 1.
           88 lnkisfalse       value 0.
       01 akeyobject            pic x.

       procedure division using alength akeyobject
                                  returning lnkbool.
           move 1 to i
           invoke selfClass "getkeyTemplate" returning ktemplate
           invoke selfClass "getkeySize" returning ksize
           if ktemplate equal to null
               invoke instancedata(i:objectreferencesize)
                                        as object "lessThan"
                                             using akeyobject
                                          returning lnkbool
           else
               invoke instancedata(i:ksize) as ktemplate
                                            "lessThanbyLengthValue"
                                       using  kSize akeyobject
                                   returning lnkbool
           end-if
           exit method.
       end method "lessThanbyLengthValue".
      *>----------------------------------------------------------------
      *> Destroy this Association the key and the value.
      *>----------------------------------------------------------------
       method-id. "deepFinalizeWithDepth".
       local-storage section.
       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 template             usage object reference.
       01 lsNewDepth           pic x(4) comp-5.

       linkage section.
       01 defaultReturn        usage object reference.
       01 lnkDepth             pic x(4) comp-5.

       procedure division using lnkDepth returning defaultReturn.
           if lnkDepth > 0
               subtract 1 from lnkDepth giving lsNewDepth
               move 1 to i
               invoke selfClass "getkeyTemplate" returning template
               invoke selfClass "getkeySize" returning ksize
               if template equal to null
                   invoke instancedata(i:objectReferenceSize)
                           as object "deepFinalizeWithDepth"
                              using lsNewDepth
                       returning instancedata(i:objectReferenceSize)
               end-if
               invoke selfClass "getdataTemplate" returning template
               if template = null
                   add kSize to i
                   invoke instancedata(i:objectReferenceSize)
                           as object "deepFinalizeWithDepth"
                              using lsNewDepth
                           returning instancedata(i:objectReferenceSize)
               end-if
           end-if
           if self not = null
               invoke super "deepFinalizeWithDepth" using lnkDepth
                                returning defaultreturn
           else
               set defaultReturn to null
           end-if
           exit method.
       end method "deepFinalizeWithDepth".
      *>----------------------------------------------------------------
      *> Return true if the receiver's key is greater than the
      *> intrinsic key defined by aLength and akeyObject otherwise return
      *> false. aKeyObject can be either an object or intrinsic data,
      *> depending on the template used to clone the class (see method
      *> "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "GreaterThanbyLengthValue".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 dSize                pic x(4) comp-5.
       01 dTemplate            usage object reference.
       01 kTemplate            usage object reference.

       linkage section.
       01 alength              pic x(4) comp-5.
       01 lnkbool              pic x comp-5.
           88 lnkistrue        value 1.
           88 lnkisfalse       value 0.
       01 akeyobject            pic x.

       procedure division using alength akeyobject returning lnkbool.
           move 1 to i
           invoke selfClass "getkeyTemplate" returning ktemplate
           invoke selfClass "getkeySize" returning ksize
           if ktemplate equal to null
               invoke instancedata(i:objectreferencesize)
                                         as object "greaterThan"
                                             using akeyobject
                                             returning lnkbool
           else
               invoke instancedata(i:ksize) as ktemplate
                                        "greaterThanbyLengthValue"
                                       using  kSize akeyobject
                                   returning lnkbool
           end-if
           exit method.
       end method "GreaterThanbyLengthValue".
      *>----------------------------------------------------------------
      *> Return the hash value for this association
      *>----------------------------------------------------------------
       method-id. "hash".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 kTemplate            usage object reference.

       linkage section.
       01 hashvalue            pic s9(9) comp-5.

       procedure division returning hashvalue.
           move 1 to i
           invoke selfClass "getkeyTemplate" returning ktemplate
           invoke selfClass "getkeySize" returning ksize
           if ktemplate equal to null
               invoke instancedata(i:objectreferencesize)
                                           as object "hash"
                                           returning hashvalue
           else
               invoke instancedata(i:ksize) as ktemplate "hash"
                                           returning hashvalue
           end-if
           exit method.
       end method "hash".
      *>----------------------------------------------------------------
      *> Return the key for this association
      *> aKeyObject can be either an object or intrinsic data,
      *> depending on the template used to clone the class
      *> (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "getkey".
       local-storage section.
       01 kSize                pic x(4) comp-5.
       01 kTemp                usage object reference.

       linkage section.
       01 akeyobject            pic x.

       procedure division returning akeyobject.
           invoke selfClass "getkeySize" returning ksize
      $if gc defined
           invoke selfClass "getkeyTemplate" returning kTemp
           if ktemp = null
                call "oopsassignobjectreference"
                  using by reference akeyobject(1:objectreferencesize)
                        by value instancedata(1:objectreferencesize)
           else
                invoke instancedata(1:ksize) as kTemp
                        "getvalue" returning akeyobject(1:ksize) 
           end-if
      $else
           move instancedata(1:ksize) to akeyobject(1:ksize)
      $end  
           exit method.
       end method "getkey".
      *>----------------------------------------------------------------
      *> Set the key for this association to aKeyObject
      *> aKeyObject can be either an object or intrinsic data,
      *> depending on the template used to clone the class
      *> (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "setkey".
       local-storage section.

       01 kSize                pic x(4) comp-5.
       01 kTemp                usage object reference.

       linkage section.
       01 akeyobject           pic x.

       procedure division using akeyobject.
           invoke selfClass "getkeySize" returning ksize
      $if gc defined
           invoke selfclass "getkeytemplate" returning kTemp
           if kTemp = null
                call "oopsassignobjectreference"
                 using by reference instancedata(1:objectreferencesize)
                       by value akeyobject(1:objectreferencesize)
           else
                invoke akeyobject(1:ksize) as kTemp
                        "getvalue" returning instancedata(1:ksize)
           end-if
      $else  
           move akeyobject(1:ksize) to instancedata(1:ksize)
      $end
           exit method.
       end method "setkey".
      *>----------------------------------------------------------------
      *> Return the data for this association
      *> adataobject can be either an object or intrinsic data,
      *> depending on the template used to clone the class
      *> (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "getData".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 dSize                pic x(4) comp-5.
       01 dTemp                usage object reference.

       linkage section.
       01 adataobject           pic x.

       procedure division returning adataobject.
           move 1 to i
           invoke selfClass "getkeySize" returning ksize
           invoke selfClass "getdataSize" returning dsize
           add kSize to i
      $if gc defined
           invoke selfclass "getdataTemplate" returning dTemp
           if dTemp = null
                call "oopsassignobjectreference"
                   using by reference adataobject(1:objectreferencesize)
                         by value instancedata(i:objectreferencesize)
           else
                invoke instancedata(i:dsize) as dTemp
                        "getvalue" returning adataobject(1:dsize)
           end-if
      $else
           move instancedata(i:dsize) to adataobject(1:dsize)
      $end
           exit method.
       end method "getData".
      *>----------------------------------------------------------------
      *> Return the number of bytes required to store the data for this
      *> association type.
      *>----------------------------------------------------------------
       method-id. "dataSize".
       linkage section.
       01 asize                pic x(4) comp-5.

       procedure division returning asize.
           invoke selfClass "getdataSize" returning asize
           exit method.
       end method "dataSize".
      *>----------------------------------------------------------------
      *> Return the type of key being stored in this association
      *>----------------------------------------------------------------
       method-id. "keyType".
       linkage section.
       01 ktemplate                     usage object reference.

       procedure division returning ktemplate.
           invoke selfClass "getkeytemplate" returning ktemplate
           exit method.
       end method "keyType".
      *>----------------------------------------------------------------
      *> Return the type of data being stored in this association
      *>----------------------------------------------------------------
       method-id. "dataType".
       linkage section.
       01 dtemplate                     usage object reference.

       procedure division returning dtemplate.
           invoke selfClass "getdatatemplate" returning dtemplate
           exit method.
       end method "dataType".

      *>----------------------------------------------------------------
      *> Return the type of data being stored in this association
      *>----------------------------------------------------------------
       method-id. "deepCopy".
       local-storage section.
       01 aKey                          usage object reference.
       01 aValue                        usage object reference.
       01 keySize                       pic x(4) comp-5.
       01 dtemplate                     usage object reference.
       01 ktemplate                     usage object reference.
       linkage section.
       01 lnkNewObject                  usage object reference.

       procedure division returning lnkNewObject.
           invoke selfClass "getdatatemplate" returning dtemplate
           invoke selfClass "getKeytemplate" returning ktemplate
           invoke self "copy" returning lnkNewObject
           if kTemplate = null
               invoke InstanceData(1:objectreferencesize)
                               AS OBJECT "copy"
                               returning aKey
               invoke lnkNewObject "setKey" using aKey
           end-if
           if dTemplate = null
               invoke selfclass "getKeySize" returning keySize
               invoke InstanceData(keySize + 1: objectreferencesize)
                                as object
                           "copy" returning aValue
               invoke lnkNewObject "setData" using aValue
           end-if
           exit method.
       end method "deepCopy".
      *>----------------------------------------------------------------
      *> Return the number of bytes required to store the key for this
      *> association type.
      *>----------------------------------------------------------------
       method-id. "keySize".
       linkage section.
       01 asize                pic x(4) comp-5.

       procedure division returning asize.
           invoke selfClass "getkeySize" returning aSize
           exit method.
       end method "keySize".
      *>----------------------------------------------------------------
      *> Set the data for this association to aDataObject
      *> adataobject can be either an object or intrinsic data,
      *> depending on the template used to clone the class
      *> (see method "newClass" for cloning).
      *>----------------------------------------------------------------
       method-id. "setData".
       local-storage section.

       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 dSize                pic x(4) comp-5.
       01 dTemp                usage object reference.

       linkage section.
       01 adataobject           pic x.

       procedure division using adataobject.
           invoke selfClass "getkeySize" returning kSize
           invoke selfClass "getdataSize" returning dSize
           move 1 to i
           add kSize to i
      $if gc defined
           invoke selfclass "getdatatemplate" returning dTemp
           if dTemp = null
                call "oopsassignobjectreference"
                     using by reference
                             instancedata(i : objectreferencesize)
                           by value adataobject(1:objectreferencesize)
           else
                invoke adataobject(1:dSize) as dTemp
                        "getvalue" returning instancedata(i : dSize)
           end-if
      $else
           move adataobject(1:dSize) to instancedata(i : dSize)
      $end
           exit method.
       end method "setData".
      *>----------------------------------------------------------------
      *> Return a string containing a description of the key->data pair
      *>----------------------------------------------------------------
       method-id. "asCharacterArray".
       local-storage section.
       01 i                    pic x(4) comp-5.
       01 kSize                pic x(4) comp-5.
       01 dSize                pic x(4) comp-5.
       01 lsKeySize            pic x(4) comp-5.
       01 lsDataSize           pic x(4) comp-5.
       01 dTemplate            usage object reference.
       01 kTemplate            usage object reference.

       01 lsKeyDesc             usage object reference.
       01 lsDataDesc            usage object reference.
       01 totalSize             pic x(4) comp-5.
       01 j                     pic x(4) comp-5.
       01 k                     pic x(4) comp-5.
       linkage section.
       01 lnkString    usage object reference.
       procedure division returning lnkString.
           invoke selfClass "getkeytemplate" returning ktemplate
           invoke selfClass "getdataSize" returning dsize
           invoke selfClass "getkeySize" returning ksize
           move 1 to i
           if ktemplate equal to null
               invoke instancedata(i:objectreferencesize)
                                          as object "description"
                                           returning lsKeyDesc
           else
               invoke instancedata(i:ksize) as ktemplate "description"
                                           returning lsKeyDesc
           end-if
           add kSize to i
           invoke selfClass "getDatatemplate" returning dtemplate
           if dtemplate equal to null
               invoke instancedata(i:objectreferencesize)
                                        as object "description"
                                           returning lsDataDesc
           else
               invoke instancedata(i:dsize) as ktemplate "description"
                                           returning lsDataDesc
           end-if
           invoke lsDataDesc "size" returning lsDataSize
           invoke lsKeyDesc "size" returning lsKeySize
           compute totalSize = lsDataSize + lsKeySize + 4
           invoke CharacterArray "withLength" using totalSize
                   returning lnkString
           move 1 to i
           invoke lnkString "atPut" using i "("
           compute j = i + lsKeySize
           add 1 to i
           move 1 to k
           invoke lnkString "replaceSubCollection" using i j lsKeyDesc k
           add 1 to j
           invoke lnkString "atPut" using j "-"
           add 1 to j
           invoke lnkString "atPut" using j ">"
           add 1 to i
           add lsKeySize to i
           compute j = i + lsDataSize
           add 1 to i
           move 1 to k
           invoke lnkString "replaceSubCollection" using i j lsDataDesc
               k
           add 1 to j
           invoke lnkString "atPut" using j ")"
           invoke lsDataDesc "finalize" returning lsDataDesc
           invoke lsKeyDesc "finalize" returning lsKeyDesc
           exit method.
       end method "asCharacterArray".

      *>----------------------------------------------------------------
      *> Set the Value of this Intrinsic
      *> Note that the number of bytes read from avalue is equal to
      *> the current size of the Intrinsic.
      *>----------------------------------------------------------------
       method-id. "setValue".
       local-storage section.
       01 i             pic x(4) comp-5.
       linkage section.
       01 avalue        pic x.
       procedure division using avalue.
           invoke selfclass "getkeysize" returning i
           invoke self "setKey" using avalue
           invoke self "setdata" using avalue(1 + i:)
           exit method.
       end method "setValue".

      *>----------------------------------------------------------------
      *> Return the value of this Intrinsic
      *>----------------------------------------------------------------
       method-id. "getValue".
       local-storage section.
       01 i             pic x(4) comp-5.

       linkage section.
       01 avalue        pic x(4) comp-5.

       procedure division returning avalue.
           invoke selfclass "getkeysize" returning i
           invoke self "getKey" returning avalue
           invoke self "getdata" returning avalue(1 + i:)
           exit method.
       end method "getValue".

       end object.
       end class Association.
