home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / javaoopl.tcl < prev    next >
Text File  |  1997-05-16  |  48KB  |  1,981 lines

  1. #--------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           %W%
  6. #      Author:         <generated>
  7. #
  8. #--------------------------------------------------------------------------
  9.  
  10. #      File:           @(#)jvgclass.tcl    /main/hindenburg/14
  11.  
  12.  
  13. Class JVGClass : {Object} {
  14.     constructor
  15.     method destructor
  16.     method generate
  17.     method generateClass
  18.     method generateInterface
  19.     method generateAccess
  20.     method generateComment
  21.     method generateContainer
  22.     method generateModifier
  23.     method generatePackages
  24.     method getModifier
  25.     method isExternal
  26.     method isInterface
  27.     attribute isMaster
  28.     attribute unit
  29.     attribute container
  30. }
  31.  
  32. constructor JVGClass {class this name} {
  33.     set this [Object::constructor $class $this $name]
  34.     # Start constructor user section
  35.     # End constructor user section
  36.     return $this
  37. }
  38.  
  39. method JVGClass::destructor {this} {
  40.     # Start destructor user section
  41.     # End destructor user section
  42. }
  43.  
  44. method JVGClass::generate {this model} {
  45.     if {[$this isExternal] || [$this container] != ""} {
  46.         return
  47.     }
  48.  
  49.     set unitName [$this getPropertyValue "source_file"]
  50.  
  51.     if {$unitName == ""} {
  52.         set unitName [$this getName]
  53.     }
  54.  
  55.     $this unit [$model getCompilationUnit $unitName]
  56.  
  57.     if [$this isInterface] {
  58.         $this generateInterface
  59.     } else {
  60.         $this generateClass
  61.     }
  62. }
  63.  
  64. method JVGClass::generateClass {this} {
  65.     $this container [JavaClass new $this]
  66.  
  67.     $this generateContainer
  68.     $this generatePackages
  69.     $this generateComment
  70.     $this generateAccess
  71.     $this generateModifier
  72.  
  73.     set javaContainer [$this container]
  74.  
  75.     foreach genNode [$this genNodeSet] {
  76.         set super [$genNode superClass]
  77.         set superName [$super getName]
  78.  
  79.         if [$super isInterface] {
  80.         $javaContainer addInterface $superName
  81.         } elseif {[$javaContainer superClass] != ""} {
  82.         m4_error $E_NOMULTINH [$this getName] $superName [$javaContainer superClass]
  83.         } else {
  84.         $javaContainer superClass $superName
  85.         }
  86.     }
  87.  
  88.     if {[$this constructor] != ""} {
  89.         [$this constructor] generate
  90.     }
  91.  
  92.     foreach dataAttr [$this dataAttrSet] {
  93.         $dataAttr generate
  94.     }
  95.  
  96.     foreach method [$this operationSet] {
  97.         $method generate
  98.     }
  99.  
  100.     foreach assocAttr [$this genAssocAttrSet] {
  101.         $assocAttr generate
  102.     }
  103. }
  104.  
  105. method JVGClass::generateInterface {this} {
  106.     $this container [JavaInterface new $this]
  107.  
  108.     $this generateContainer
  109.     $this generatePackages
  110.     $this generateComment
  111.     $this generateAccess
  112.     $this generateModifier
  113.  
  114.     foreach genNode [$this genNodeSet] {
  115.         set super [$genNode superClass]
  116.         set superName [$super getName]
  117.  
  118.         if [$super isInterface] {
  119.         [$this container] addInterface $superName
  120.         } else {
  121.         m4_error $E_INTFROMCLASS [$this getName] $superName
  122.         }
  123.     }
  124.  
  125.     foreach dataAttr [$this dataAttrSet] {
  126.         $dataAttr generate
  127.     }
  128.  
  129.     foreach method [$this operationSet] {
  130.         if {[$method isClassFeature] && [$method getName] == "create"} {
  131.         m4_warning $W_INTNOCONSTR [$this getName]
  132.         } else {
  133.         $method generate
  134.         }
  135.     }
  136.  
  137.     foreach assocAttr [$this genAssocAttrSet] {
  138.         set item [[$assocAttr smConnector] getItem]
  139.  
  140.         if [$item isNil] {
  141.         set itemName ""
  142.         } else {
  143.         set itemName [$item name]
  144.         }
  145.  
  146.         m4_warning $W_INTASSOCATTR [$assocAttr getName] $itemName [$this getName]
  147.     }
  148. }
  149.  
  150. method JVGClass::generateAccess {this} {
  151.     set access [string tolower [$this getPropertyValue class_access]]
  152.  
  153.     if {$access != "none"} {
  154.         if [$this isMaster] {
  155.         if {$access == ""} {
  156.             set access "public"
  157.         }
  158.         } else {
  159.         if {$access == "public"} {
  160.             m4_warning $W_NOTPUBLIC [$this getName] [[$this unit] name]
  161.             set access ""
  162.         }
  163.         }
  164.  
  165.         if {$access != ""} {
  166.         [$this container] access [JavaAccess new $access]
  167.         }
  168.     }
  169. }
  170.  
  171. method JVGClass::generateComment {this} {
  172.     set text [$this getPropertyValue freeText]
  173.  
  174.     if {$text == ""} {
  175.         return
  176.     }
  177.  
  178.     set type [$this getPropertyValue comment_type]
  179.  
  180.     switch $type {
  181.         Block {[$this container] comment [JavaBlockComment new $text]}
  182.         Document {[$this container] comment [JavaDocComment new $text]}
  183.         default {[$this container] comment [JavaLineComment new $text]}
  184.     }
  185. }
  186.  
  187. method JVGClass::generateContainer {this} {
  188.     set unit [$this unit]
  189.  
  190.     $unit addContainer [$this container]
  191.  
  192.     if {[$this getName] == [$unit name]} {
  193.         $this isMaster 1
  194.         $unit masterContainer [$this container]
  195.  
  196.         set packageStatement [$this getPropertyValue package_stmnt]
  197.  
  198.         if {$packageStatement != ""} {
  199.         $unit packageStatement [JavaPackageName new "$packageStatement"]
  200.         }
  201.     } else {
  202.         $this isMaster 0
  203.     }
  204. }
  205.  
  206. method JVGClass::generateModifier {this} {
  207.     set modifier [$this getModifier]
  208.  
  209.     if {$modifier != ""} {
  210.         if {[$this isInterface] && $modifier == "final"} {
  211.         m4_warning $W_INTNOTFINAL [$this getName]
  212.         } else {
  213.         [$this container] modifier [JavaModifier new $modifier]
  214.         }
  215.     }
  216. }
  217.  
  218. method JVGClass::generatePackages {this} {
  219.     set unit [$this unit]
  220.  
  221.     foreach importPackage [$this getPropertyValue import_package] {
  222.         $unit addImportPackage [JavaPackageName new $importPackage]
  223.     }
  224.  
  225.     foreach importType [$this getPropertyValue import_type] {
  226.         $unit addImportType [JavaPackageName new $importType]
  227.     }
  228.  
  229.     foreach importOnDemand [$this getPropertyValue import_ondemand] {
  230.         $unit addImportOnDemand [JavaPackageName new $importOnDemand]
  231.     }
  232. }
  233.  
  234. method JVGClass::getModifier {this} {
  235.     return [string tolower [$this getPropertyValue class_modifier]]
  236. }
  237.  
  238. method JVGClass::isExternal {this} {
  239.     if {[$this OPClass::isExternal] ||
  240.         [$this getPropertyValue interface_type] == "External"} {
  241.         return 1
  242.     }
  243.  
  244.     return 0
  245. }
  246.  
  247. method JVGClass::isInterface {this} {
  248.     if {[$this getPropertyValue class_interface] == "Interface"} {
  249.         return 1
  250.     }
  251.  
  252.     return 0
  253. }
  254.  
  255. # Do not delete this line -- regeneration end marker
  256.  
  257. Class JVGClassD : {JVGClass OPClass} {
  258. }
  259.  
  260. selfPromoter OPClass {this} {
  261.     JVGClassD promote $this
  262. }
  263.  
  264. #      File:           @(#)jvgfeature.tcl    /main/hindenburg/3
  265.  
  266.  
  267. Class JVGFeature : {Object} {
  268.     constructor
  269.     method destructor
  270.     method generate
  271.     method getComment
  272.     method getMethodAccess
  273.     method getTypeName
  274.     method isFinal
  275.     method isNative
  276.     method isSynchronized
  277.     method isThreadsafe
  278.     method isTransient
  279.     method isVolatile
  280. }
  281.  
  282. constructor JVGFeature {class this name} {
  283.     set this [Object::constructor $class $this $name]
  284.     # Start constructor user section
  285.     # End constructor user section
  286.     return $this
  287. }
  288.  
  289. method JVGFeature::destructor {this} {
  290.     # Start destructor user section
  291.     # End destructor user section
  292. }
  293.  
  294. method JVGFeature::generate {this} {
  295.     # !! Implement this function !!
  296. }
  297.  
  298. method JVGFeature::getComment {this} {
  299.     set text [$this getPropertyValue freeText]
  300.  
  301.     if {$text == ""} {
  302.         return ""
  303.     }
  304.  
  305.     set type [$this getPropertyValue comment_type]
  306.  
  307.     switch $type {
  308.         Block {return [JavaBlockComment new $text]}
  309.         Document {return [JavaDocComment new $text]}
  310.         default {return [JavaLineComment new $text]}
  311.     }
  312. }
  313.  
  314. method JVGFeature::getMethodAccess {this} {
  315.     return [string tolower [$this getPropertyValue method_access]]
  316. }
  317.  
  318. method JVGFeature::getTypeName {this} {
  319.     if {[$this ooplType] == ""} {
  320.         return ""
  321.     }
  322.  
  323.     return [[$this ooplType] getName]
  324. }
  325.  
  326. method JVGFeature::isFinal {this} {
  327.     if {[$this getPropertyValue is_final] == "1"} {
  328.         return "1"
  329.     }
  330.  
  331.     return "0"
  332. }
  333.  
  334. method JVGFeature::isNative {this} {
  335.     if {[$this getPropertyValue is_native] == "1"} {
  336.         return "1"
  337.     }
  338.  
  339.     return "0"
  340. }
  341.  
  342. method JVGFeature::isSynchronized {this} {
  343.     if {[$this getPropertyValue is_synchronized] == "1"} {
  344.         return "1"
  345.     }
  346.  
  347.     return "0"
  348. }
  349.  
  350. method JVGFeature::isThreadsafe {this} {
  351.     if {[$this getPropertyValue is_threadsafe] == "1"} {
  352.         return "1"
  353.     }
  354.  
  355.     return "0"
  356. }
  357.  
  358. method JVGFeature::isTransient {this} {
  359.     if {[$this getPropertyValue is_transient] == "1"} {
  360.         return "1"
  361.     }
  362.  
  363.     return "0"
  364. }
  365.  
  366. method JVGFeature::isVolatile {this} {
  367.     if {[$this getPropertyValue is_volatile] == "1"} {
  368.         return "1"
  369.     }
  370.  
  371.     return "0"
  372. }
  373.  
  374. # Do not delete this line -- regeneration end marker
  375.  
  376. Class JVGFeatureD : {JVGFeature OPFeature} {
  377. }
  378.  
  379. selfPromoter OPFeature {this} {
  380.     JVGFeatureD promote $this
  381. }
  382.  
  383. #      File:           @(#)jvgtype.tcl    /main/hindenburg/1
  384.  
  385.  
  386. Class JVGType : {Object} {
  387.     constructor
  388.     method destructor
  389. }
  390.  
  391. constructor JVGType {class this name} {
  392.     set this [Object::constructor $class $this $name]
  393.     # Start constructor user section
  394.     # End constructor user section
  395.     return $this
  396. }
  397.  
  398. method JVGType::destructor {this} {
  399.     # Start destructor user section
  400.     # End destructor user section
  401. }
  402.  
  403. # Do not delete this line -- regeneration end marker
  404.  
  405. Class JVGTypeD : {JVGType OPType} {
  406. }
  407.  
  408. selfPromoter OPType {this} {
  409.     JVGTypeD promote $this
  410. }
  411.  
  412. #      File:           @(#)jvgclassen.tcl    /main/hindenburg/1
  413.  
  414.  
  415. Class JVGClassEnum : {JVGClass} {
  416.     constructor
  417.     method destructor
  418.     method generate
  419. }
  420.  
  421. constructor JVGClassEnum {class this name} {
  422.     set this [JVGClass::constructor $class $this $name]
  423.     # Start constructor user section
  424.     # End constructor user section
  425.     return $this
  426. }
  427.  
  428. method JVGClassEnum::destructor {this} {
  429.     # Start destructor user section
  430.     # End destructor user section
  431. }
  432.  
  433. method JVGClassEnum::generate {this model} {
  434.     $this JVGClass::generate $model
  435. }
  436.  
  437. # Do not delete this line -- regeneration end marker
  438.  
  439. Class JVGClassEnumD : {JVGClassEnum OPClassEnum} {
  440. }
  441.  
  442. selfPromoter OPClassEnum {this} {
  443.     JVGClassEnumD promote $this
  444. }
  445.  
  446. #      File:           @(#)jvgclassge.tcl    /main/hindenburg/1
  447.  
  448.  
  449. Class JVGClassGenericTypeDef : {JVGClass} {
  450.     constructor
  451.     method destructor
  452.     method generate
  453. }
  454.  
  455. constructor JVGClassGenericTypeDef {class this name} {
  456.     set this [JVGClass::constructor $class $this $name]
  457.     # Start constructor user section
  458.     # End constructor user section
  459.     return $this
  460. }
  461.  
  462. method JVGClassGenericTypeDef::destructor {this} {
  463.     # Start destructor user section
  464.     # End destructor user section
  465. }
  466.  
  467. method JVGClassGenericTypeDef::generate {this model} {
  468.     $this JVGClass::generate $model
  469. }
  470.  
  471. # Do not delete this line -- regeneration end marker
  472.  
  473. Class JVGClassGenericTypeDefD : {JVGClassGenericTypeDef OPClassGenericTypeDef} {
  474. }
  475.  
  476. selfPromoter OPClassGenericTypeDef {this} {
  477.     JVGClassGenericTypeDefD promote $this
  478. }
  479.  
  480. #      File:           @(#)jvgclasstd.tcl    /main/hindenburg/1
  481.  
  482.  
  483. Class JVGClassTDef : {JVGClass} {
  484.     constructor
  485.     method destructor
  486.     method generate
  487. }
  488.  
  489. constructor JVGClassTDef {class this name} {
  490.     set this [JVGClass::constructor $class $this $name]
  491.     # Start constructor user section
  492.     # End constructor user section
  493.     return $this
  494. }
  495.  
  496. method JVGClassTDef::destructor {this} {
  497.     # Start destructor user section
  498.     # End destructor user section
  499. }
  500.  
  501. method JVGClassTDef::generate {this model} {
  502.     $this JVGClass::generate $model
  503. }
  504.  
  505. # Do not delete this line -- regeneration end marker
  506.  
  507. Class JVGClassTDefD : {JVGClassTDef OPClassTDef} {
  508. }
  509.  
  510. selfPromoter OPClassTDef {this} {
  511.     JVGClassTDefD promote $this
  512. }
  513.  
  514. #      File:           @(#)jvglinkcla.tcl    /main/hindenburg/1
  515.  
  516.  
  517. Class JVGLinkClass : {JVGClass} {
  518.     constructor
  519.     method destructor
  520.     method generate
  521. }
  522.  
  523. constructor JVGLinkClass {class this name} {
  524.     set this [JVGClass::constructor $class $this $name]
  525.     # Start constructor user section
  526.     # End constructor user section
  527.     return $this
  528. }
  529.  
  530. method JVGLinkClass::destructor {this} {
  531.     # Start destructor user section
  532.     # End destructor user section
  533. }
  534.  
  535. method JVGLinkClass::generate {this model} {
  536.     $this JVGClass::generate $model
  537. }
  538.  
  539. # Do not delete this line -- regeneration end marker
  540.  
  541. Class JVGLinkClassD : {JVGLinkClass OPLinkClass} {
  542. }
  543.  
  544. selfPromoter OPLinkClass {this} {
  545.     JVGLinkClassD promote $this
  546. }
  547.  
  548. #      File:           @(#)jvgattribu.tcl    /main/hindenburg/3
  549.  
  550.  
  551. Class JVGAttribute : {JVGFeature} {
  552.     constructor
  553.     method destructor
  554.     method generate
  555.     method getAccessorAccess
  556.     method getAttributeAccess
  557. }
  558.  
  559. constructor JVGAttribute {class this name} {
  560.     set this [JVGFeature::constructor $class $this $name]
  561.     # Start constructor user section
  562.     # End constructor user section
  563.     return $this
  564. }
  565.  
  566. method JVGAttribute::destructor {this} {
  567.     # Start destructor user section
  568.     # End destructor user section
  569. }
  570.  
  571. method JVGAttribute::generate {this} {
  572.     # !! Implement this function !!
  573. }
  574.  
  575. method JVGAttribute::getAccessorAccess {this mode} {
  576.     set manip [string tolower [$this getPropertyValue attrib_manipulator]]
  577.  
  578.     if {$manip == ""} {
  579.         return "public"
  580.     }
  581.  
  582.     set rwAccessList [split $manip -]
  583.  
  584.     if {[llength $rwAccessList] == 2} {
  585.         if {$mode == "r"} {
  586.         return [lindex $rwAccessList 0]
  587.         }
  588.  
  589.         return [lindex $rwAccessList 1]
  590.     }
  591.  
  592.     return $manip
  593. }
  594.  
  595. method JVGAttribute::getAttributeAccess {this} {
  596.     return [string tolower [$this getPropertyValue attrib_access]]
  597. }
  598.  
  599. # Do not delete this line -- regeneration end marker
  600.  
  601. Class JVGAttributeD : {JVGAttribute OPAttribute} {
  602. }
  603.  
  604. selfPromoter OPAttribute {this} {
  605.     JVGAttributeD promote $this
  606. }
  607.  
  608. #      File:           @(#)jvgconstru.tcl    /main/hindenburg/3
  609.  
  610.  
  611. Class JVGConstructor : {JVGFeature} {
  612.     constructor
  613.     method destructor
  614.     method generate
  615. }
  616.  
  617. constructor JVGConstructor {class this name} {
  618.     set this [JVGFeature::constructor $class $this $name]
  619.     # Start constructor user section
  620.     # End constructor user section
  621.     return $this
  622. }
  623.  
  624. method JVGConstructor::destructor {this} {
  625.     # Start destructor user section
  626.     # End destructor user section
  627. }
  628.  
  629. method JVGConstructor::generate {this} {
  630.     set class [$this ooplClass]
  631.  
  632.     if [$class isInterface] {
  633.         return
  634.     }
  635.  
  636.     set container [$class container]
  637.     set constructor [JavaConstructor new [$class getName]]
  638.  
  639.     $container defaultConstructor $constructor
  640.     $container addConstructor $constructor
  641.  
  642.     foreach param [$class creationParamSet] {
  643.         set paramType [JavaType new [[$param ooplType] getName]]
  644.         set javaParam [JavaParameter new [$param getName]_ $paramType]
  645.         $constructor addParameter $javaParam
  646.     }
  647.  
  648.     set genBody [TextSection new]
  649.     $constructor generatorBody $genBody
  650.  
  651.     set superInitList ""
  652.  
  653.     foreach scInitializer [$this superClassInitializerSet] {
  654.         foreach param [$scInitializer parameterSet] {
  655.         lappend superInitList "[$param getName]_"
  656.         }
  657.     }
  658.  
  659.     if {$superInitList != ""} {
  660.         $genBody append "super([join $superInitList ", "]);\n"
  661.     }
  662.  
  663.     foreach initializer [$this initializerSet] {
  664.         set initType [$initializer get_obj_type]
  665.  
  666.         if {$initType != "sc_init" && $initType != "qual_init"} {
  667.         set ident [$initializer getName]
  668.         $genBody append "$ident = ${ident}_;\n"
  669.         }
  670.     }
  671.  
  672.     foreach assoc [$class genAssocAttrSet] {
  673.         set var [$assoc getAssocVariable]
  674.  
  675.         if [$assoc isQualified] {
  676.         $genBody append "$var = new Hashtable();\n"
  677.         } elseif {[$assoc getMultiplicity] == "many"} {
  678.         if {[$assoc isOrdered]} {
  679.             $genBody append "$var = new Queue();\n"
  680.         } else {
  681.             $genBody append "$var = new Vector();\n"
  682.         }
  683.         }
  684.  
  685.         if [$assoc isReverseLinkAttr] {
  686.         set opposite [$assoc opposite]
  687.  
  688.         if {$opposite != ""} {
  689.             $genBody append [$opposite extendAssociation $var]
  690.         }
  691.         }
  692.     }
  693.  
  694.     set access [$this getMethodAccess]
  695.  
  696.     if {$access == ""} {
  697.         set access "public"
  698.     }
  699.  
  700.     $constructor access [JavaAccess new $access]
  701. }
  702.  
  703. # Do not delete this line -- regeneration end marker
  704.  
  705. Class JVGConstructorD : {JVGConstructor OPConstructor} {
  706. }
  707.  
  708. selfPromoter OPConstructor {this} {
  709.     JVGConstructorD promote $this
  710. }
  711.  
  712. #      File:           @(#)jvgoperati.tcl    /main/hindenburg/5
  713.  
  714.  
  715. Class JVGOperation : {JVGFeature} {
  716.     constructor
  717.     method destructor
  718.     method generate
  719.     method generateClassMethod
  720.     method generateExceptions
  721.     method generateInterfaceMethod
  722.     method generateParameters
  723.     method generateStaticInitializer
  724.     method generateUserConstructor
  725. }
  726.  
  727. constructor JVGOperation {class this name} {
  728.     set this [JVGFeature::constructor $class $this $name]
  729.     # Start constructor user section
  730.     # End constructor user section
  731.     return $this
  732. }
  733.  
  734. method JVGOperation::destructor {this} {
  735.     # Start destructor user section
  736.     # End destructor user section
  737. }
  738.  
  739. method JVGOperation::generate {this} {
  740.     if {[$this getPropertyValue is_static] != ""} {
  741.         m4_warning $W_OLDPROPERTY is_static
  742.     }
  743.  
  744.     set name [$this getName]
  745.  
  746.     if {[$this isClassFeature] && $name == "create"} {
  747.         $this generateUserConstructor
  748.     } elseif {$name == "static"} {
  749.         $this generateStaticInitializer
  750.     } else {
  751.         if [[$this ooplClass] isInterface] {
  752.         $this generateInterfaceMethod
  753.         } else {
  754.         $this generateClassMethod
  755.         }
  756.     }
  757. }
  758.  
  759. method JVGOperation::generateClassMethod {this} {
  760.     set class [$this ooplClass]
  761.     set container [$class container]
  762.     set method [JavaUserMethod new [$this getName]]
  763.  
  764.     $container addMethod $method
  765.  
  766.     $method comment [$this getComment]
  767.  
  768.     if {[$this getTypeName] == ""} {
  769.         $method type [JavaType new "void"]
  770.     } else {
  771.         $method type [JavaType new [$this getTypeName]]
  772.     }
  773.  
  774.     set access [$this getMethodAccess]
  775.  
  776.     if {[$this isAbstract] &&
  777.         ($access == "private" || $access == "private protected")} {
  778.         m4_warning $W_ABSPRIVMETH $access [$this getName] [$class getName]
  779.         set access "none"
  780.     }
  781.  
  782.     if {$access != "none"} {
  783.         if {$access == ""} {
  784.         set access "public"
  785.         }
  786.  
  787.         $method access [JavaAccess new $access]
  788.     }
  789.  
  790.     if [$this isAbstract] {
  791.         if {[$class getModifier] != "abstract"} {
  792.         m4_warning $W_ABSTRACTMETH [$class getName] [$this getName]
  793.         m4_warning $W_NOTCOMPILE
  794.         }
  795.  
  796.         $method addModifier [JavaModifier new "abstract"]
  797.         $method hasBody 0
  798.     } else {
  799.         if [$this isClassFeature] {
  800.         $method addModifier [JavaModifier new "static"]
  801.         }
  802.  
  803.         if [$this isFinal] {
  804.         $method addModifier [JavaModifier new "final"]
  805.         }
  806.     }
  807.  
  808.     if [$this isNative] {
  809.         $method addModifier [JavaModifier new "native"]
  810.         $method hasBody 0
  811.     }
  812.  
  813.     if [$this isSynchronized] {
  814.         $method addModifier [JavaModifier new "synchronized"]
  815.     }
  816.  
  817.     $this generateParameters $method
  818.     $this generateExceptions $method
  819. }
  820.  
  821. method JVGOperation::generateExceptions {this method} {
  822.     foreach throwException [$this getPropertyValue method_exceptions] {
  823.         $method addThrow [JavaException new $throwException]
  824.     }
  825. }
  826.  
  827. method JVGOperation::generateInterfaceMethod {this} {
  828.     set class [$this ooplClass]
  829.     set container [$class container]
  830.     set method [JavaUserMethod new [$this getName]]
  831.  
  832.     $container addMethod $method
  833.     $method hasBody 0
  834.     $method comment [$this getComment]
  835.  
  836.     if {[$this getTypeName] == ""} {
  837.         $method type [JavaType new "void"]
  838.     } else {
  839.         $method type [JavaType new [$this getTypeName]]
  840.     }
  841.  
  842.     set access [$this getMethodAccess]
  843.  
  844.     if {$access == "private" || $access == "protected" ||
  845.         $access == "private protected"} {
  846.         m4_warning $W_INVINTDECL $access [$this getName] [$class getName]
  847.     }
  848.  
  849.     if {$access != "none"} {
  850.         set access "public"
  851.  
  852.         $method access [JavaAccess new $access]
  853.     }
  854.  
  855.     if [$this isNative] {
  856.         m4_warning $W_INVINTDECL native [$this getName] [$class getName]
  857.     }
  858.  
  859.     if [$this isClassFeature] {
  860.         m4_warning $W_INVINTDECL static [$this getName] [$class getName]
  861.     }
  862.  
  863.     if [$this isSynchronized] {
  864.         m4_warning $W_INVINTDECL synchronized [$this getName] [$class getName]
  865.     }
  866.  
  867.     if [$this isFinal] {
  868.         m4_warning $W_INVINTDECL final [$this getName] [$class getName]
  869.     }
  870.  
  871.     if [$this isAbstract] {
  872.         $method addModifier [JavaModifier new "abstract"]
  873.         $method hasBody 0
  874.     }
  875.  
  876.     $this generateParameters $method
  877.     $this generateExceptions $method
  878. }
  879.  
  880. method JVGOperation::generateParameters {this method} {
  881.     foreach param [$this parameterSet] {
  882.         set paramType [JavaType new [[$param ooplType] getName]]
  883.         set javaParam [JavaParameter new [$param getName] $paramType]
  884.         $method addParameter $javaParam
  885.     }
  886. }
  887.  
  888. method JVGOperation::generateStaticInitializer {this} {
  889.     set container [[$this ooplClass] container]
  890.     set initializer [JavaStaticInitializer new "static"]
  891.  
  892.     $container addMethod $initializer
  893.  
  894.     $initializer comment [$this getComment]
  895. }
  896.  
  897. method JVGOperation::generateUserConstructor {this} {
  898.     set class [$this ooplClass]
  899.     set container [$class container]
  900.     set constructor [JavaUserConstructor new [$class getName]]
  901.  
  902.     $container addUserConstructor $constructor
  903.     $container addConstructor $constructor
  904.  
  905.     $constructor comment [$this getComment]
  906.  
  907.     foreach param [$this parameterSet] {
  908.         set paramType [JavaType new [[$param ooplType] getName]]
  909.         set javaParam [JavaParameter new [$param getName] $paramType]
  910.         $constructor addParameter $javaParam
  911.     }
  912.  
  913.     foreach throwException [$this getPropertyValue method_exceptions] {
  914.         $constructor addThrow [JavaException new $throwException]
  915.     }
  916.  
  917.     set access [$this getMethodAccess]
  918.  
  919.     if {$access == "" || $access == "none"} {
  920.         set access "public"
  921.     }
  922.  
  923.     $constructor access [JavaAccess new $access]
  924. }
  925.  
  926. # Do not delete this line -- regeneration end marker
  927.  
  928. Class JVGOperationD : {JVGOperation OPOperation} {
  929. }
  930.  
  931. selfPromoter OPOperation {this} {
  932.     JVGOperationD promote $this
  933. }
  934.  
  935. #      File:           @(#)jvgbasetyp.tcl    /main/hindenburg/1
  936.  
  937.  
  938. Class JVGBaseType : {JVGType} {
  939.     constructor
  940.     method destructor
  941.     method getName
  942. }
  943.  
  944. constructor JVGBaseType {class this name} {
  945.     set this [JVGType::constructor $class $this $name]
  946.     # Start constructor user section
  947.     # End constructor user section
  948.     return $this
  949. }
  950.  
  951. method JVGBaseType::destructor {this} {
  952.     # Start destructor user section
  953.     # End destructor user section
  954. }
  955.  
  956. method JVGBaseType::getName {this} {
  957.     set name [$this getType3GL]
  958.  
  959.     if {$name != ""} {
  960.         return $name
  961.     }
  962.  
  963.     return [$this OPType::getName]
  964. }
  965.  
  966. # Do not delete this line -- regeneration end marker
  967.  
  968. Class JVGBaseTypeD : {JVGBaseType OPBaseType} {
  969. }
  970.  
  971. selfPromoter OPBaseType {this} {
  972.     JVGBaseTypeD promote $this
  973. }
  974.  
  975. #      File:           @(#)jvgdataatt.tcl    /main/hindenburg/4
  976.  
  977.  
  978. Class JVGDataAttr : {JVGAttribute} {
  979.     constructor
  980.     method destructor
  981.     method generate
  982.     method generateClassVariable
  983.     method generateInterfaceVariable
  984.     method getVariableInitializer
  985. }
  986.  
  987. constructor JVGDataAttr {class this name} {
  988.     set this [JVGAttribute::constructor $class $this $name]
  989.     # Start constructor user section
  990.     # End constructor user section
  991.     return $this
  992. }
  993.  
  994. method JVGDataAttr::destructor {this} {
  995.     # Start destructor user section
  996.     # End destructor user section
  997. }
  998.  
  999. method JVGDataAttr::generate {this} {
  1000.     if {[$this getPropertyValue is_static] != ""} {
  1001.         m4_warning $W_OLDPROPERTY is_static
  1002.     }
  1003.  
  1004.     set class [$this ooplClass]
  1005.  
  1006.     if [$class isInterface] {
  1007.         $this generateInterfaceVariable
  1008.     } else {
  1009.         $this generateClassVariable
  1010.     }
  1011. }
  1012.  
  1013. method JVGDataAttr::generateClassVariable {this} {
  1014.     set class [$this ooplClass]
  1015.     set container [$class container]
  1016.     set variable [JavaVariable new [$this getName]]
  1017.  
  1018.     $container addVariable $variable
  1019.  
  1020.     $variable type [JavaType new [$this getTypeName]]
  1021.     $variable comment [$this getComment]
  1022.     $variable initializer [$this getVariableInitializer]
  1023.  
  1024.     if {[$this isFinal] && [$variable initializer] == ""} {
  1025.         m4_warning $W_FINALVAR [$this getName] [$class getName]
  1026.         m4_warning $W_NOTCOMPILE
  1027.     }
  1028.  
  1029.     set access [$this getAttributeAccess]
  1030.  
  1031.     if {$access != "none"} {
  1032.         if {$access == ""} {
  1033.         set access "private"
  1034.         }
  1035.  
  1036.         $variable access [JavaAccess new $access]
  1037.     }
  1038.  
  1039.     if [$this isClassFeature] {
  1040.         $variable addModifier [JavaModifier new "static"]
  1041.     }
  1042.  
  1043.     if [$this isFinal] {
  1044.         $variable addModifier [JavaModifier new "final"]
  1045.     }
  1046.  
  1047.     if [$this isThreadsafe] {
  1048.         $variable addModifier [JavaModifier new "threadsafe"]
  1049.     }
  1050.  
  1051.     if [$this isTransient] {
  1052.         if {[$this isClassFeature] || [$this isFinal]} {
  1053.         m4_warning $W_TRANSIENTVAR [$this getName] [$class getName]
  1054.         m4_warning $W_NOTCOMPILE
  1055.         }
  1056.  
  1057.         $variable addModifier [JavaModifier new "transient"]
  1058.     }
  1059.  
  1060.     if [$this isVolatile] {
  1061.         $variable addModifier [JavaModifier new "volatile"]
  1062.     }
  1063.  
  1064.     #
  1065.     # Generate accessor methods
  1066.     #
  1067.  
  1068.     set access [$this getAccessorAccess "r"]
  1069.  
  1070.     if {$access != "none"} {
  1071.         set ident [$this getName]
  1072.         set genBody [TextSection new]
  1073.         set accessor [JavaAccMethod new "get[cap $ident]"]
  1074.  
  1075.         if [$this isClassFeature] {
  1076.         $accessor addModifier [JavaModifier new "static"]
  1077.         }
  1078.  
  1079.         $accessor type [JavaType new [$this getTypeName]]
  1080.         $container addAttributeAccessor $accessor
  1081.         $accessor access [JavaAccess new $access]
  1082.         $accessor generatorBody $genBody
  1083.         $genBody append "return $ident;\n"
  1084.     }
  1085.  
  1086.     set access [$this getAccessorAccess "w"]
  1087.  
  1088.     if {![$this isFinal] && $access != "none"} {
  1089.         set ident [$this getName]
  1090.         set paramId "${ident}_"
  1091.         set genBody [TextSection new]
  1092.         set accessor [JavaAccMethod new "set[cap $ident]"]
  1093.         set type [JavaType new [$this getTypeName]]
  1094.         set parameter [JavaParameter new $paramId $type]
  1095.  
  1096.         if [$this isClassFeature] {
  1097.         $accessor addModifier [JavaModifier new "static"]
  1098.         }
  1099.  
  1100.         $container addAttributeAccessor $accessor
  1101.         $accessor type [JavaType new "void"]
  1102.         $accessor addParameter $parameter
  1103.         $accessor access [JavaAccess new $access]
  1104.         $accessor generatorBody $genBody
  1105.         $genBody append "$ident = $paramId;\n"
  1106.     }
  1107. }
  1108.  
  1109. method JVGDataAttr::generateInterfaceVariable {this} {
  1110.     set class [$this ooplClass]
  1111.     set container [$class container]
  1112.     set variable [JavaVariable new [$this getName]]
  1113.  
  1114.     $container addVariable $variable
  1115.  
  1116.     $variable type [JavaType new [$this getTypeName]]
  1117.     $variable comment [$this getComment]
  1118.     $variable access [JavaAccess new "public"]
  1119.     $variable initializer [$this getVariableInitializer]
  1120.  
  1121.     if {[$variable initializer] == ""} {
  1122.         m4_warning $W_INTVARNOASSGN [$this getName]
  1123.         m4_warning $W_NOTCOMPILE
  1124.     }
  1125.  
  1126.     if [$this isClassFeature] {
  1127.         $variable addModifier [JavaModifier new "static"]
  1128.     }
  1129.  
  1130.     if [$this isFinal] {
  1131.         $variable addModifier [JavaModifier new "final"]
  1132.     }
  1133. }
  1134.  
  1135. method JVGDataAttr::getVariableInitializer {this} {
  1136.     if {[$this getPropertyValue default_value] != ""} {
  1137.         m4_warning $W_OLDPROPERTY default_value
  1138.     }
  1139.  
  1140.     if {[set initVal [$this getPropertyValue initial_value]] != ""} {
  1141.         return [JavaInitializer new $initVal]
  1142.     }
  1143.  
  1144.     if {[set initVal [$this getPropertyValue array_initialization]] != ""} {
  1145.         return [JavaInitializer new $initVal]
  1146.     }
  1147.  
  1148.     return ""
  1149. }
  1150.  
  1151. # Do not delete this line -- regeneration end marker
  1152.  
  1153. Class JVGDataAttrD : {JVGDataAttr OPDataAttr} {
  1154. }
  1155.  
  1156. selfPromoter OPDataAttr {this} {
  1157.     JVGDataAttrD promote $this
  1158. }
  1159.  
  1160. #      File:           @(#)jvggenasso.tcl    /main/hindenburg/7
  1161.  
  1162.  
  1163. Class JVGGenAssocAttr : {JVGAttribute} {
  1164.     constructor
  1165.     method destructor
  1166.     method generate
  1167.     method generateAddAccessor
  1168.     method generateGetAccessor
  1169.     method generateGetManyAccessor
  1170.     method generateRemoveAccessor
  1171.     method generateSetAccessor
  1172.     method generateAssociationVariable
  1173.     method getAssocIdentifier
  1174.     method getAssocVariable
  1175.     method isClassFeature
  1176.     method extendAssociation
  1177.     method reduceAssociation
  1178.     method setAssociation
  1179. }
  1180.  
  1181. constructor JVGGenAssocAttr {class this name} {
  1182.     set this [JVGAttribute::constructor $class $this $name]
  1183.     # Start constructor user section
  1184.     # End constructor user section
  1185.     return $this
  1186. }
  1187.  
  1188. method JVGGenAssocAttr::destructor {this} {
  1189.     # Start destructor user section
  1190.     # End destructor user section
  1191. }
  1192.  
  1193. method JVGGenAssocAttr::generate {this} {
  1194.     # !! Implement this function !!
  1195. }
  1196.  
  1197. method JVGGenAssocAttr::generateAddAccessor {this} {
  1198.     set ident [$this getAssocIdentifier]
  1199.  
  1200.     if [$this isOrdered] {
  1201.         set accessor [JavaAccMethod new "append[cap $ident]"]
  1202.     } else {
  1203.         set accessor [JavaAccMethod new "add[cap $ident]"]
  1204.     }
  1205.  
  1206.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1207.  
  1208.     $accessor type [JavaType new "void"]
  1209.  
  1210.     if [$this isQualified] {
  1211.         set qualifier [$this qualifier]
  1212.         set qualTypeName [[$qualifier ooplType] getName]
  1213.         set qualId "[$qualifier getName]_"
  1214.         set type [JavaType new $qualTypeName]
  1215.         $accessor addParameter [JavaParameter new $qualId $type]
  1216.     }
  1217.  
  1218.     set opposite [$this opposite]
  1219.  
  1220.     if {$opposite != "" && [$opposite isQualified]} {
  1221.         set qualTypeName [[[$opposite qualifier] ooplType] getName]
  1222.         set qualId "[[$opposite qualifier] getName]_"
  1223.         set type [JavaType new $qualTypeName]
  1224.         $accessor addParameter [JavaParameter new $qualId $type]
  1225.     }
  1226.  
  1227.     set paramId "${ident}_"
  1228.     set type [JavaType new [[$this ooplType] getName]]
  1229.     $accessor addParameter [JavaParameter new $paramId $type]
  1230.  
  1231.     set body [TextSection new]
  1232.  
  1233.     $accessor generatorBody $body
  1234.  
  1235.     $body append "if ($paramId == null)\n"
  1236.     $body append "    return;\n";
  1237.  
  1238.     if {$opposite != ""} {
  1239.         if {[$opposite getMultiplicity] == "one" &&
  1240.         ![$opposite isQualified] && ![$this isQualified]} {
  1241.             $body append [$opposite setAssociation $paramId]
  1242.         }
  1243.  
  1244.         $body append [$opposite extendAssociation $paramId]
  1245.     }
  1246.  
  1247.     if [$this isQualified] {
  1248.         [[$this ooplClass] container] needsVector 1
  1249.         set varName [$this getAssocVariable]
  1250.  
  1251.         $body append "// You must supply a hashCode and equals method for Object\n"
  1252.         $body append "// [[$this qualifier] getName] for java.util.Hashtable usage.\n"
  1253.         $body append "Vector vector = (Vector) $varName.get($qualId);\n"
  1254.         $body append "if (vector == null) {\n"
  1255.         $body append "    vector = new Vector();\n"
  1256.         $body append "    $varName.put($qualId, vector);\n"
  1257.         $body append "}\n"
  1258.         $body append "vector.addElement($paramId);\n"
  1259.     } else {
  1260.         $body append [$this extendAssociation "" $paramId]
  1261.     }
  1262.  
  1263.     set access [$this getAccessorAccess w]
  1264.  
  1265.     if {$access != "none"} {
  1266.         $accessor access [JavaAccess new $access]
  1267.     }
  1268. }
  1269.  
  1270. method JVGGenAssocAttr::generateGetAccessor {this} {
  1271.     set varName [$this getAssocVariable]
  1272.     set accessor [JavaAccMethod new "get[cap $varName]"]
  1273.  
  1274.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1275.  
  1276.     $accessor type [JavaType new [[$this ooplType] getName]]
  1277.  
  1278.     set access [$this getAccessorAccess r]
  1279.  
  1280.     if {$access != "none"} {
  1281.         $accessor access [JavaAccess new $access]
  1282.     }
  1283.  
  1284.     set body [TextSection new]
  1285.  
  1286.     $body append "return $varName;\n"
  1287.  
  1288.     $accessor generatorBody $body
  1289. }
  1290.  
  1291. method JVGGenAssocAttr::generateGetManyAccessor {this} {
  1292.     set varName [$this getAssocVariable]
  1293.     set accessor [JavaAccMethod new "get[cap $varName]"]
  1294.  
  1295.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1296.  
  1297.     if [$this isOrdered] {
  1298.         $accessor type [JavaType new "Queue"]
  1299.     } else {
  1300.         [[$this ooplClass] container] needsVector 1
  1301.         $accessor type [JavaType new "Vector"]
  1302.     }
  1303.  
  1304.     set access [$this getAccessorAccess r]
  1305.  
  1306.     if {$access != "none"} {
  1307.         $accessor access [JavaAccess new $access]
  1308.     }
  1309.  
  1310.     set body [TextSection new]
  1311.  
  1312.     $body append "return $varName;\n"
  1313.  
  1314.     $accessor generatorBody $body
  1315. }
  1316.  
  1317. method JVGGenAssocAttr::generateRemoveAccessor {this} {
  1318.     set ident [$this getAssocIdentifier]
  1319.     set opposite [$this opposite]
  1320.     set accessor [JavaAccMethod new "remove[cap $ident]"]
  1321.  
  1322.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1323.  
  1324.     $accessor type [JavaType new "void"]
  1325.  
  1326.     if {$opposite != "" && [$opposite isQualified]} {
  1327.         set qualifier [$opposite qualifier]
  1328.         set type [JavaType new [[$qualifier ooplType] getName]]
  1329.         set qualId "[$qualifier getName]_"
  1330.         $accessor addParameter [JavaParameter new $qualId $type]
  1331.     }
  1332.  
  1333.     set paramId "${ident}_"
  1334.     set type [JavaType new [[$this ooplType] getName]]
  1335.     $accessor addParameter [JavaParameter new $paramId $type]
  1336.  
  1337.     set body [TextSection new]
  1338.  
  1339.     $accessor generatorBody $body
  1340.  
  1341.     $body append "if ($paramId == null)\n"
  1342.     $body append "    return;\n"
  1343.  
  1344.     if {$opposite != ""} {
  1345.         $body append [$opposite reduceAssociation $paramId]
  1346.     }
  1347.  
  1348.     $body append [$this reduceAssociation "" $paramId]
  1349.  
  1350.     set access [$this getAccessorAccess w]
  1351.  
  1352.     if {$access != "none"} {
  1353.         $accessor access [JavaAccess new $access]
  1354.     }
  1355. }
  1356.  
  1357. method JVGGenAssocAttr::generateSetAccessor {this} {
  1358.     set opposite [$this opposite]
  1359.     set ident [$this getAssocIdentifier]
  1360.     set paramId "${ident}_"
  1361.     set accessor [JavaAccMethod new "set[cap $ident]"]
  1362.  
  1363.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1364.  
  1365.     $accessor type [JavaType new "void"]
  1366.  
  1367.     set access [$this getAccessorAccess w]
  1368.  
  1369.     if {$access != "none"} {
  1370.         $accessor access [JavaAccess new $access]
  1371.     }
  1372.  
  1373.     if {$opposite != "" && [$opposite isQualified]} {
  1374.         set qualifier [$opposite qualifier]
  1375.         set type [JavaType new [[$qualifier ooplType] getName]]
  1376.         set parameter [JavaParameter new "[$qualifier getName]_" $type]
  1377.         $accessor addParameter $parameter
  1378.     }
  1379.  
  1380.     set type [JavaType new [[$this ooplType] getName]]
  1381.     $accessor addParameter [JavaParameter new $paramId $type]
  1382.  
  1383.     set body [TextSection new]
  1384.  
  1385.     $accessor generatorBody $body
  1386.  
  1387.     if {$opposite != ""} {
  1388.         if [$opposite isQualified] {
  1389.         $body append "if ($paramId != null)\n"
  1390.         $body append "    [$opposite extendAssociation $paramId]"
  1391.         } else {
  1392.         $body append "if ($ident != null)\n"
  1393.         $body append "    [$opposite reduceAssociation $ident]"
  1394.  
  1395.         if {[$opposite getMultiplicity] == "one"} {
  1396.             $body append "if ($paramId != null) {\n"
  1397.             $body append "    [$opposite setAssociation $paramId]"
  1398.             $body append "    [$opposite extendAssociation $paramId]"
  1399.             $body append "}\n"
  1400.         }
  1401.  
  1402.         if {[$opposite getMultiplicity] == "many"} {
  1403.             $body append "if ($paramId != null)\n"
  1404.             $body append "    [$opposite extendAssociation $paramId]"
  1405.         }
  1406.         }
  1407.     }
  1408.  
  1409.     $body append "$ident = $paramId;\n"
  1410. }
  1411.  
  1412. method JVGGenAssocAttr::generateAssociationVariable {this} {
  1413.     set assocVar [JavaVariable new [$this getAssocVariable]]
  1414.  
  1415.     if [$this isQualified] {
  1416.         [[$this ooplClass] container] needsHashtable 1
  1417.         $assocVar type [JavaType new "Hashtable"]
  1418.     } elseif {[$this getMultiplicity] == "many"} {
  1419.         if [$this isOrdered] {
  1420.         $assocVar type [JavaType new "Queue"]
  1421.         } else {
  1422.         [[$this ooplClass] container] needsVector 1
  1423.         $assocVar type [JavaType new "Vector"]
  1424.         }
  1425.     } else {
  1426.         $assocVar type [JavaType new [[$this ooplType] getName]]
  1427.     }
  1428.  
  1429.     [[$this ooplClass] container] addAssocVariable $assocVar
  1430.  
  1431.     if {[$this opposite] != ""} {
  1432.         set access "public"
  1433.     } else {
  1434.         set access [$this getAttributeAccess]
  1435.     }
  1436.  
  1437.     if {$access != "none"} {
  1438.         if {$access == ""} {
  1439.         set access "private"
  1440.         }
  1441.  
  1442.         $assocVar access [JavaAccess new $access]
  1443.     }
  1444.  
  1445.     if [$this isClassFeature] {
  1446.         $assocVar addModifier [JavaModifier new "static"]
  1447.     }
  1448.  
  1449.     if [$this isThreadsafe] {
  1450.         $assocVar addModifier [JavaModifier new "threadsafe"]
  1451.     }
  1452.  
  1453.     if [$this isTransient] {
  1454.         $assocVar addModifier [JavaModifier new "transient"]
  1455.     }
  1456.  
  1457.     if [$this isVolatile] {
  1458.         $assocVar addModifier [JavaModifier new "volatile"]
  1459.     }
  1460. }
  1461.  
  1462. method JVGGenAssocAttr::getAssocIdentifier {this} {
  1463.     if [$this isLinkAttr] {
  1464.         return [uncap [[$this ooplType] getName]Of[cap [$this getName]]]
  1465.     }
  1466.  
  1467.     return [$this getName]
  1468. }
  1469.  
  1470. method JVGGenAssocAttr::getAssocVariable {this} {
  1471.     if {[$this getMultiplicity] == "many"} {
  1472.         return [$this getAssocIdentifier]Set
  1473.     }
  1474.  
  1475.     return [$this getAssocIdentifier]
  1476. }
  1477.  
  1478. method JVGGenAssocAttr::isClassFeature {this} {
  1479.     if {[$this getPropertyValue "is_static"] == "1"} {
  1480.         return "1"
  1481.     }
  1482.  
  1483.     return "0"
  1484. }
  1485.  
  1486. method JVGGenAssocAttr::extendAssociation {this {prefix ""} {element "this"}} {
  1487.     set sect [TextSection new]
  1488.  
  1489.     if {$prefix != ""} {
  1490.         set prefix ${prefix}.
  1491.     }
  1492.  
  1493.     set varName [$this getAssocVariable]
  1494.  
  1495.     if [$this isQualified] {
  1496.         set qualId "[[$this qualifier] getName]_"
  1497.  
  1498.         if {[$this getMultiplicity] == "one"} {
  1499.         return "$prefix$varName.put($qualId, $element);\n"
  1500.         }
  1501.  
  1502.         set ident [$this getAssocIdentifier]
  1503.  
  1504.         return "${prefix}add[cap $ident]($qualId, $element);\n"
  1505.     }
  1506.  
  1507.     if {[$this getMultiplicity] == "one"} {
  1508.         return "$prefix$varName = $element;\n"
  1509.     }
  1510.  
  1511.     if [$this isOrdered] {
  1512.         return "$prefix$varName.append($element);\n"
  1513.     }
  1514.  
  1515.     return "$prefix$varName.addElement($element);\n"
  1516. }
  1517.  
  1518. method JVGGenAssocAttr::reduceAssociation {this {prefix ""} {element "this"}} {
  1519.     if {$prefix != ""} {
  1520.         set prefix "${prefix}."
  1521.     }
  1522.  
  1523.     set varName [$this getAssocVariable]
  1524.  
  1525.     if [$this isQualified] {
  1526.         set qualId "[[$this qualifier] getName]_"
  1527.  
  1528.         if {[$this getMultiplicity] == "one"} {
  1529.         return "$prefix$varName.remove($qualId);\n"
  1530.         }
  1531.  
  1532.         set ident [$this getAssocIdentifier]
  1533.  
  1534.         return "${prefix}remove[cap $ident]($qualId, $element);\n"
  1535.     }
  1536.  
  1537.     if {[$this getMultiplicity] == "one"} {
  1538.         return "$prefix$varName = null;\n"
  1539.     }
  1540.  
  1541.     return "$prefix$varName.removeElement($element);\n"
  1542. }
  1543.  
  1544. method JVGGenAssocAttr::setAssociation {this {prefix ""} {element "null"}} {
  1545.     if {$prefix != ""} {
  1546.         set prefix "${prefix}."
  1547.     }
  1548.  
  1549.     return "${prefix}set[cap [$this getAssocIdentifier]]($element);\n"
  1550. }
  1551.  
  1552. # Do not delete this line -- regeneration end marker
  1553.  
  1554. Class JVGGenAssocAttrD : {JVGGenAssocAttr OPGenAssocAttr} {
  1555. }
  1556.  
  1557. selfPromoter OPGenAssocAttr {this} {
  1558.     JVGGenAssocAttrD promote $this
  1559. }
  1560.  
  1561. #      File:           @(#)jvgassocat.tcl    /main/hindenburg/3
  1562.  
  1563.  
  1564. Class JVGAssocAttr : {JVGGenAssocAttr} {
  1565.     constructor
  1566.     method destructor
  1567.     method generate
  1568. }
  1569.  
  1570. constructor JVGAssocAttr {class this name} {
  1571.     set this [JVGGenAssocAttr::constructor $class $this $name]
  1572.     # Start constructor user section
  1573.     # End constructor user section
  1574.     return $this
  1575. }
  1576.  
  1577. method JVGAssocAttr::destructor {this} {
  1578.     # Start destructor user section
  1579.     # End destructor user section
  1580. }
  1581.  
  1582. method JVGAssocAttr::generate {this} {
  1583.     if [[$this ooplClass] isInterface] {
  1584.         return
  1585.     }
  1586.  
  1587.     $this generateAssociationVariable
  1588.  
  1589.     if {[$this getMultiplicity] == "one"} {
  1590.         if {[$this getAccessorAccess r] != "none"} {
  1591.         $this generateGetAccessor
  1592.         }
  1593.  
  1594.         if {[$this getAccessorAccess w] != "none"} {
  1595.         $this generateSetAccessor
  1596.         }
  1597.     } else {
  1598.         if {[$this getAccessorAccess w] != "none"} {
  1599.         $this generateAddAccessor
  1600.         $this generateRemoveAccessor
  1601.         }
  1602.  
  1603.         if {[$this getAccessorAccess r] != "none"} {
  1604.         $this generateGetManyAccessor
  1605.         }
  1606.     }
  1607. }
  1608.  
  1609. # Do not delete this line -- regeneration end marker
  1610.  
  1611. Class JVGAssocAttrD : {JVGAssocAttr OPAssocAttr} {
  1612. }
  1613.  
  1614. selfPromoter OPAssocAttr {this} {
  1615.     JVGAssocAttrD promote $this
  1616. }
  1617.  
  1618. #      File:           @(#)jvglinkatt.tcl    /main/hindenburg/1
  1619.  
  1620.  
  1621. Class JVGLinkAttr : {JVGGenAssocAttr} {
  1622.     constructor
  1623.     method destructor
  1624.     method generate
  1625. }
  1626.  
  1627. constructor JVGLinkAttr {class this name} {
  1628.     set this [JVGGenAssocAttr::constructor $class $this $name]
  1629.     # Start constructor user section
  1630.     # End constructor user section
  1631.     return $this
  1632. }
  1633.  
  1634. method JVGLinkAttr::destructor {this} {
  1635.     # Start destructor user section
  1636.     # End destructor user section
  1637. }
  1638.  
  1639. method JVGLinkAttr::generate {this} {
  1640.     if [[$this ooplClass] isInterface] {
  1641.         return
  1642.     }
  1643.  
  1644.     $this generateAssociationVariable
  1645.  
  1646.     if {[$this getMultiplicity] == "one"} {
  1647.         $this generateGetAccessor
  1648.     } else {
  1649.         $this generateGetManyAccessor
  1650.     }
  1651. }
  1652.  
  1653. # Do not delete this line -- regeneration end marker
  1654.  
  1655. Class JVGLinkAttrD : {JVGLinkAttr OPLinkAttr} {
  1656. }
  1657.  
  1658. selfPromoter OPLinkAttr {this} {
  1659.     JVGLinkAttrD promote $this
  1660. }
  1661.  
  1662. #      File:           @(#)jvgqualatt.tcl    /main/hindenburg/4
  1663.  
  1664.  
  1665. Class JVGQualAttr : {JVGGenAssocAttr} {
  1666.     constructor
  1667.     method destructor
  1668.     method generate
  1669.     method generateGetQualifiedAccessor
  1670.     method generateRemoveQualifiedAccessor
  1671.     method generateSetQualifiedAccessor
  1672. }
  1673.  
  1674. constructor JVGQualAttr {class this name} {
  1675.     set this [JVGGenAssocAttr::constructor $class $this $name]
  1676.     # Start constructor user section
  1677.     # End constructor user section
  1678.     return $this
  1679. }
  1680.  
  1681. method JVGQualAttr::destructor {this} {
  1682.     # Start destructor user section
  1683.     # End destructor user section
  1684. }
  1685.  
  1686. method JVGQualAttr::generate {this} {
  1687.     if [[$this ooplClass] isInterface] {
  1688.         return
  1689.     }
  1690.  
  1691.     $this generateAssociationVariable
  1692.  
  1693.     if {[$this getAccessorAccess r] != "none"} {
  1694.         $this generateGetQualifiedAccessor
  1695.     }
  1696.  
  1697.     if {[$this getAccessorAccess w] != "none"} {
  1698.         if {[$this getMultiplicity] == "one"} {
  1699.         $this generateSetQualifiedAccessor
  1700.         } else {
  1701.         $this generateAddAccessor
  1702.         }
  1703.  
  1704.         $this generateRemoveQualifiedAccessor
  1705.     }
  1706. }
  1707.  
  1708. method JVGQualAttr::generateGetQualifiedAccessor {this} {
  1709.     set varName [$this getAssocVariable]
  1710.     set assocType [$this ooplType]
  1711.     set accessor [JavaAccMethod new "get[cap $varName]"]
  1712.  
  1713.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1714.  
  1715.     if {[$this getMultiplicity] == "many"} {
  1716.         [[$this ooplClass] container] needsVector 1
  1717.         set assocTypeName "Vector"
  1718.     } else {
  1719.         set assocTypeName [$assocType getName]
  1720.     }
  1721.  
  1722.     set access [$this getAccessorAccess r]
  1723.  
  1724.     if {$access != "none"} {
  1725.         $accessor access [JavaAccess new $access]
  1726.     }
  1727.  
  1728.     $accessor type [JavaType new $assocTypeName]
  1729.  
  1730.     set qualifier [$this qualifier]
  1731.     set qualName [$qualifier getName]
  1732.     set qualType [$qualifier ooplType]
  1733.     set qualTypeName [$qualType getName]
  1734.     set type [JavaType new $qualTypeName]
  1735.     set qualId "${qualName}_"
  1736.  
  1737.     $accessor addParameter [JavaParameter new $qualId $type]
  1738.  
  1739.     #
  1740.     #    Check if qualifier has one of the Java builtin types.
  1741.     #    The type of a qualifier must be derived from Object.
  1742.     #
  1743.  
  1744.     set wrongTypes "byte short int long char float double boolean"
  1745.  
  1746.     if {[lsearch $wrongTypes $qualTypeName] != -1} {
  1747.         set item [[$this smConnector] getItem]
  1748.  
  1749.         if [$item isNil] {
  1750.         set itemName ""
  1751.         } else {
  1752.         set itemName [$item name]
  1753.         }
  1754.  
  1755.         m4_warning $W_QUALWRONGTYPE $qualName $itemName [$this getName] $qualTypeName
  1756.         m4_warning $W_NOTCOMPILE
  1757.     }
  1758.  
  1759.     set body [TextSection new]
  1760.  
  1761.     $body append "Object object = $varName.get($qualId);\n"
  1762.     $body append "if (object != null)\n"
  1763.     $body append "    return (($assocTypeName) object);\n"
  1764.     $body append "return null;\n"
  1765.  
  1766.     $accessor generatorBody $body 
  1767. }
  1768.  
  1769. method JVGQualAttr::generateRemoveQualifiedAccessor {this} {
  1770.     set ident [$this getAssocIdentifier]
  1771.     set accessor [JavaAccMethod new "remove[cap $ident]"]
  1772.  
  1773.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1774.  
  1775.     $accessor type [JavaType new "void"]
  1776.  
  1777.     set access [$this getAccessorAccess w]
  1778.  
  1779.     if {$access != "none"} {
  1780.         $accessor access [JavaAccess new $access]
  1781.     }
  1782.  
  1783.     set qualType [JavaType new [[[$this qualifier] ooplType] getName]]
  1784.     set qualId "[[$this qualifier] getName]_"
  1785.  
  1786.     $accessor addParameter [JavaParameter new $qualId $qualType]
  1787.  
  1788.     set body [TextSection new]
  1789.  
  1790.     set paramId "${ident}_"
  1791.     set opposite [$this opposite]
  1792.     set varName [$this getAssocVariable]
  1793.  
  1794.     if {[$this getMultiplicity] == "one"} {
  1795.         $body append "Object object = $varName.get($qualId);\n"
  1796.         $body append "if (object == null)\n"
  1797.         $body append "    return;\n"
  1798.         $body append [$this reduceAssociation]
  1799.  
  1800.         if {$opposite != ""} {
  1801.         set typeName [[$this ooplType] getName]
  1802.         $body append "$typeName $paramId = ($typeName) object;\n"
  1803.         }
  1804.     } else {
  1805.         [[$this ooplClass] container] needsVector 1
  1806.         set type [JavaType new [[$this ooplType] getName]]
  1807.         $accessor addParameter [JavaParameter new $paramId $type]
  1808.  
  1809.         $body append "if ($paramId == null)\n"
  1810.         $body append "    return;\n"
  1811.         $body append "Vector vector = (Vector) $varName.get($qualId);\n";
  1812.         $body append "if (vector != null)\n";
  1813.         $body append "    vector.removeElement($paramId);\n"
  1814.     }
  1815.  
  1816.     if {$opposite != ""} {
  1817.         $body append [$opposite reduceAssociation $paramId]
  1818.     }
  1819.  
  1820.     $accessor generatorBody $body 
  1821. }
  1822.  
  1823. method JVGQualAttr::generateSetQualifiedAccessor {this} {
  1824.     set ident [$this getAssocIdentifier]
  1825.     set accessor [JavaAccMethod new "set[cap $ident]"]
  1826.     set qualifier [$this qualifier]
  1827.     set qualType [JavaType new [[$qualifier ooplType] getName]]
  1828.     set qualId "[$qualifier getName]_"
  1829.  
  1830.     [[$this ooplClass] container] addAssociationAccessor $accessor
  1831.  
  1832.     $accessor addParameter [JavaParameter new $qualId $qualType]
  1833.     $accessor type [JavaType new "void"]
  1834.  
  1835.     set paramId "${ident}_"
  1836.     set type [JavaType new [[$this ooplType] getName]]
  1837.  
  1838.     $accessor addParameter [JavaParameter new $paramId $type]
  1839.  
  1840.     set access [$this getAccessorAccess w]
  1841.  
  1842.     if {$access != "none"} {
  1843.         $accessor access [JavaAccess new $access]
  1844.     }
  1845.  
  1846.     set body [TextSection new]
  1847.  
  1848.     $body append "if ($paramId == null)\n"
  1849.     $body append "    return;\n"
  1850.     $body append "$ident.put($qualId, $paramId);\n"
  1851.  
  1852.     set opposite [$this opposite]
  1853.  
  1854.     if {$opposite != ""} {
  1855.         $body append [$opposite extendAssociation $paramId]
  1856.     }
  1857.  
  1858.     $accessor generatorBody $body 
  1859. }
  1860.  
  1861. # Do not delete this line -- regeneration end marker
  1862.  
  1863. Class JVGQualAttrD : {JVGQualAttr OPQualAttr} {
  1864. }
  1865.  
  1866. selfPromoter OPQualAttr {this} {
  1867.     JVGQualAttrD promote $this
  1868. }
  1869.  
  1870. #      File:           @(#)jvgreverse.tcl    /main/hindenburg/1
  1871.  
  1872.  
  1873. Class JVGReverseLinkAttr : {JVGGenAssocAttr} {
  1874.     constructor
  1875.     method destructor
  1876.     method generate
  1877. }
  1878.  
  1879. constructor JVGReverseLinkAttr {class this name} {
  1880.     set this [JVGGenAssocAttr::constructor $class $this $name]
  1881.     # Start constructor user section
  1882.     # End constructor user section
  1883.     return $this
  1884. }
  1885.  
  1886. method JVGReverseLinkAttr::destructor {this} {
  1887.     # Start destructor user section
  1888.     # End destructor user section
  1889. }
  1890.  
  1891. method JVGReverseLinkAttr::generate {this} {
  1892.     if [[$this ooplClass] isInterface] {
  1893.         return
  1894.     }
  1895.  
  1896.     $this generateAssociationVariable
  1897.  
  1898.     if {[$this getMultiplicity] == "one"} {
  1899.         $this generateGetAccessor
  1900.     } else {
  1901.         $this generateGetManyAccessor
  1902.     }
  1903. }
  1904.  
  1905. # Do not delete this line -- regeneration end marker
  1906.  
  1907. Class JVGReverseLinkAttrD : {JVGReverseLinkAttr OPReverseLinkAttr} {
  1908. }
  1909.  
  1910. selfPromoter OPReverseLinkAttr {this} {
  1911.     JVGReverseLinkAttrD promote $this
  1912. }
  1913.  
  1914. #      File:           @(#)jvgqualass.tcl    /main/hindenburg/1
  1915.  
  1916.  
  1917. Class JVGQualAssocAttr : {JVGQualAttr} {
  1918.     constructor
  1919.     method destructor
  1920.     method generate
  1921. }
  1922.  
  1923. constructor JVGQualAssocAttr {class this name} {
  1924.     set this [JVGQualAttr::constructor $class $this $name]
  1925.     # Start constructor user section
  1926.     # End constructor user section
  1927.     return $this
  1928. }
  1929.  
  1930. method JVGQualAssocAttr::destructor {this} {
  1931.     # Start destructor user section
  1932.     # End destructor user section
  1933. }
  1934.  
  1935. method JVGQualAssocAttr::generate {this} {
  1936.     $this JVGQualAttr::generate
  1937. }
  1938.  
  1939. # Do not delete this line -- regeneration end marker
  1940.  
  1941. Class JVGQualAssocAttrD : {JVGQualAssocAttr OPQualAssocAttr} {
  1942. }
  1943.  
  1944. selfPromoter OPQualAssocAttr {this} {
  1945.     JVGQualAssocAttrD promote $this
  1946. }
  1947.  
  1948. #      File:           @(#)jvgquallin.tcl    /main/hindenburg/1
  1949.  
  1950.  
  1951. Class JVGQualLinkAttr : {JVGQualAttr} {
  1952.     constructor
  1953.     method destructor
  1954.     method generate
  1955. }
  1956.  
  1957. constructor JVGQualLinkAttr {class this name} {
  1958.     set this [JVGQualAttr::constructor $class $this $name]
  1959.     # Start constructor user section
  1960.     # End constructor user section
  1961.     return $this
  1962. }
  1963.  
  1964. method JVGQualLinkAttr::destructor {this} {
  1965.     # Start destructor user section
  1966.     # End destructor user section
  1967. }
  1968.  
  1969. method JVGQualLinkAttr::generate {this} {
  1970.     $this JVGQualAttr::generate
  1971. }
  1972.  
  1973. # Do not delete this line -- regeneration end marker
  1974.  
  1975. Class JVGQualLinkAttrD : {JVGQualLinkAttr OPQualLinkAttr} {
  1976. }
  1977.  
  1978. selfPromoter OPQualLinkAttr {this} {
  1979.     JVGQualLinkAttrD promote $this
  1980. }
  1981.