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 >
Wrap
Text File
|
1997-05-16
|
48KB
|
1,981 lines
#--------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: %W%
# Author: <generated>
#
#--------------------------------------------------------------------------
# File: @(#)jvgclass.tcl /main/hindenburg/14
Class JVGClass : {Object} {
constructor
method destructor
method generate
method generateClass
method generateInterface
method generateAccess
method generateComment
method generateContainer
method generateModifier
method generatePackages
method getModifier
method isExternal
method isInterface
attribute isMaster
attribute unit
attribute container
}
constructor JVGClass {class this name} {
set this [Object::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGClass::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGClass::generate {this model} {
if {[$this isExternal] || [$this container] != ""} {
return
}
set unitName [$this getPropertyValue "source_file"]
if {$unitName == ""} {
set unitName [$this getName]
}
$this unit [$model getCompilationUnit $unitName]
if [$this isInterface] {
$this generateInterface
} else {
$this generateClass
}
}
method JVGClass::generateClass {this} {
$this container [JavaClass new $this]
$this generateContainer
$this generatePackages
$this generateComment
$this generateAccess
$this generateModifier
set javaContainer [$this container]
foreach genNode [$this genNodeSet] {
set super [$genNode superClass]
set superName [$super getName]
if [$super isInterface] {
$javaContainer addInterface $superName
} elseif {[$javaContainer superClass] != ""} {
m4_error $E_NOMULTINH [$this getName] $superName [$javaContainer superClass]
} else {
$javaContainer superClass $superName
}
}
if {[$this constructor] != ""} {
[$this constructor] generate
}
foreach dataAttr [$this dataAttrSet] {
$dataAttr generate
}
foreach method [$this operationSet] {
$method generate
}
foreach assocAttr [$this genAssocAttrSet] {
$assocAttr generate
}
}
method JVGClass::generateInterface {this} {
$this container [JavaInterface new $this]
$this generateContainer
$this generatePackages
$this generateComment
$this generateAccess
$this generateModifier
foreach genNode [$this genNodeSet] {
set super [$genNode superClass]
set superName [$super getName]
if [$super isInterface] {
[$this container] addInterface $superName
} else {
m4_error $E_INTFROMCLASS [$this getName] $superName
}
}
foreach dataAttr [$this dataAttrSet] {
$dataAttr generate
}
foreach method [$this operationSet] {
if {[$method isClassFeature] && [$method getName] == "create"} {
m4_warning $W_INTNOCONSTR [$this getName]
} else {
$method generate
}
}
foreach assocAttr [$this genAssocAttrSet] {
set item [[$assocAttr smConnector] getItem]
if [$item isNil] {
set itemName ""
} else {
set itemName [$item name]
}
m4_warning $W_INTASSOCATTR [$assocAttr getName] $itemName [$this getName]
}
}
method JVGClass::generateAccess {this} {
set access [string tolower [$this getPropertyValue class_access]]
if {$access != "none"} {
if [$this isMaster] {
if {$access == ""} {
set access "public"
}
} else {
if {$access == "public"} {
m4_warning $W_NOTPUBLIC [$this getName] [[$this unit] name]
set access ""
}
}
if {$access != ""} {
[$this container] access [JavaAccess new $access]
}
}
}
method JVGClass::generateComment {this} {
set text [$this getPropertyValue freeText]
if {$text == ""} {
return
}
set type [$this getPropertyValue comment_type]
switch $type {
Block {[$this container] comment [JavaBlockComment new $text]}
Document {[$this container] comment [JavaDocComment new $text]}
default {[$this container] comment [JavaLineComment new $text]}
}
}
method JVGClass::generateContainer {this} {
set unit [$this unit]
$unit addContainer [$this container]
if {[$this getName] == [$unit name]} {
$this isMaster 1
$unit masterContainer [$this container]
set packageStatement [$this getPropertyValue package_stmnt]
if {$packageStatement != ""} {
$unit packageStatement [JavaPackageName new "$packageStatement"]
}
} else {
$this isMaster 0
}
}
method JVGClass::generateModifier {this} {
set modifier [$this getModifier]
if {$modifier != ""} {
if {[$this isInterface] && $modifier == "final"} {
m4_warning $W_INTNOTFINAL [$this getName]
} else {
[$this container] modifier [JavaModifier new $modifier]
}
}
}
method JVGClass::generatePackages {this} {
set unit [$this unit]
foreach importPackage [$this getPropertyValue import_package] {
$unit addImportPackage [JavaPackageName new $importPackage]
}
foreach importType [$this getPropertyValue import_type] {
$unit addImportType [JavaPackageName new $importType]
}
foreach importOnDemand [$this getPropertyValue import_ondemand] {
$unit addImportOnDemand [JavaPackageName new $importOnDemand]
}
}
method JVGClass::getModifier {this} {
return [string tolower [$this getPropertyValue class_modifier]]
}
method JVGClass::isExternal {this} {
if {[$this OPClass::isExternal] ||
[$this getPropertyValue interface_type] == "External"} {
return 1
}
return 0
}
method JVGClass::isInterface {this} {
if {[$this getPropertyValue class_interface] == "Interface"} {
return 1
}
return 0
}
# Do not delete this line -- regeneration end marker
Class JVGClassD : {JVGClass OPClass} {
}
selfPromoter OPClass {this} {
JVGClassD promote $this
}
# File: @(#)jvgfeature.tcl /main/hindenburg/3
Class JVGFeature : {Object} {
constructor
method destructor
method generate
method getComment
method getMethodAccess
method getTypeName
method isFinal
method isNative
method isSynchronized
method isThreadsafe
method isTransient
method isVolatile
}
constructor JVGFeature {class this name} {
set this [Object::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGFeature::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGFeature::generate {this} {
# !! Implement this function !!
}
method JVGFeature::getComment {this} {
set text [$this getPropertyValue freeText]
if {$text == ""} {
return ""
}
set type [$this getPropertyValue comment_type]
switch $type {
Block {return [JavaBlockComment new $text]}
Document {return [JavaDocComment new $text]}
default {return [JavaLineComment new $text]}
}
}
method JVGFeature::getMethodAccess {this} {
return [string tolower [$this getPropertyValue method_access]]
}
method JVGFeature::getTypeName {this} {
if {[$this ooplType] == ""} {
return ""
}
return [[$this ooplType] getName]
}
method JVGFeature::isFinal {this} {
if {[$this getPropertyValue is_final] == "1"} {
return "1"
}
return "0"
}
method JVGFeature::isNative {this} {
if {[$this getPropertyValue is_native] == "1"} {
return "1"
}
return "0"
}
method JVGFeature::isSynchronized {this} {
if {[$this getPropertyValue is_synchronized] == "1"} {
return "1"
}
return "0"
}
method JVGFeature::isThreadsafe {this} {
if {[$this getPropertyValue is_threadsafe] == "1"} {
return "1"
}
return "0"
}
method JVGFeature::isTransient {this} {
if {[$this getPropertyValue is_transient] == "1"} {
return "1"
}
return "0"
}
method JVGFeature::isVolatile {this} {
if {[$this getPropertyValue is_volatile] == "1"} {
return "1"
}
return "0"
}
# Do not delete this line -- regeneration end marker
Class JVGFeatureD : {JVGFeature OPFeature} {
}
selfPromoter OPFeature {this} {
JVGFeatureD promote $this
}
# File: @(#)jvgtype.tcl /main/hindenburg/1
Class JVGType : {Object} {
constructor
method destructor
}
constructor JVGType {class this name} {
set this [Object::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGType::destructor {this} {
# Start destructor user section
# End destructor user section
}
# Do not delete this line -- regeneration end marker
Class JVGTypeD : {JVGType OPType} {
}
selfPromoter OPType {this} {
JVGTypeD promote $this
}
# File: @(#)jvgclassen.tcl /main/hindenburg/1
Class JVGClassEnum : {JVGClass} {
constructor
method destructor
method generate
}
constructor JVGClassEnum {class this name} {
set this [JVGClass::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGClassEnum::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGClassEnum::generate {this model} {
$this JVGClass::generate $model
}
# Do not delete this line -- regeneration end marker
Class JVGClassEnumD : {JVGClassEnum OPClassEnum} {
}
selfPromoter OPClassEnum {this} {
JVGClassEnumD promote $this
}
# File: @(#)jvgclassge.tcl /main/hindenburg/1
Class JVGClassGenericTypeDef : {JVGClass} {
constructor
method destructor
method generate
}
constructor JVGClassGenericTypeDef {class this name} {
set this [JVGClass::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGClassGenericTypeDef::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGClassGenericTypeDef::generate {this model} {
$this JVGClass::generate $model
}
# Do not delete this line -- regeneration end marker
Class JVGClassGenericTypeDefD : {JVGClassGenericTypeDef OPClassGenericTypeDef} {
}
selfPromoter OPClassGenericTypeDef {this} {
JVGClassGenericTypeDefD promote $this
}
# File: @(#)jvgclasstd.tcl /main/hindenburg/1
Class JVGClassTDef : {JVGClass} {
constructor
method destructor
method generate
}
constructor JVGClassTDef {class this name} {
set this [JVGClass::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGClassTDef::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGClassTDef::generate {this model} {
$this JVGClass::generate $model
}
# Do not delete this line -- regeneration end marker
Class JVGClassTDefD : {JVGClassTDef OPClassTDef} {
}
selfPromoter OPClassTDef {this} {
JVGClassTDefD promote $this
}
# File: @(#)jvglinkcla.tcl /main/hindenburg/1
Class JVGLinkClass : {JVGClass} {
constructor
method destructor
method generate
}
constructor JVGLinkClass {class this name} {
set this [JVGClass::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGLinkClass::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGLinkClass::generate {this model} {
$this JVGClass::generate $model
}
# Do not delete this line -- regeneration end marker
Class JVGLinkClassD : {JVGLinkClass OPLinkClass} {
}
selfPromoter OPLinkClass {this} {
JVGLinkClassD promote $this
}
# File: @(#)jvgattribu.tcl /main/hindenburg/3
Class JVGAttribute : {JVGFeature} {
constructor
method destructor
method generate
method getAccessorAccess
method getAttributeAccess
}
constructor JVGAttribute {class this name} {
set this [JVGFeature::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGAttribute::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGAttribute::generate {this} {
# !! Implement this function !!
}
method JVGAttribute::getAccessorAccess {this mode} {
set manip [string tolower [$this getPropertyValue attrib_manipulator]]
if {$manip == ""} {
return "public"
}
set rwAccessList [split $manip -]
if {[llength $rwAccessList] == 2} {
if {$mode == "r"} {
return [lindex $rwAccessList 0]
}
return [lindex $rwAccessList 1]
}
return $manip
}
method JVGAttribute::getAttributeAccess {this} {
return [string tolower [$this getPropertyValue attrib_access]]
}
# Do not delete this line -- regeneration end marker
Class JVGAttributeD : {JVGAttribute OPAttribute} {
}
selfPromoter OPAttribute {this} {
JVGAttributeD promote $this
}
# File: @(#)jvgconstru.tcl /main/hindenburg/3
Class JVGConstructor : {JVGFeature} {
constructor
method destructor
method generate
}
constructor JVGConstructor {class this name} {
set this [JVGFeature::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGConstructor::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGConstructor::generate {this} {
set class [$this ooplClass]
if [$class isInterface] {
return
}
set container [$class container]
set constructor [JavaConstructor new [$class getName]]
$container defaultConstructor $constructor
$container addConstructor $constructor
foreach param [$class creationParamSet] {
set paramType [JavaType new [[$param ooplType] getName]]
set javaParam [JavaParameter new [$param getName]_ $paramType]
$constructor addParameter $javaParam
}
set genBody [TextSection new]
$constructor generatorBody $genBody
set superInitList ""
foreach scInitializer [$this superClassInitializerSet] {
foreach param [$scInitializer parameterSet] {
lappend superInitList "[$param getName]_"
}
}
if {$superInitList != ""} {
$genBody append "super([join $superInitList ", "]);\n"
}
foreach initializer [$this initializerSet] {
set initType [$initializer get_obj_type]
if {$initType != "sc_init" && $initType != "qual_init"} {
set ident [$initializer getName]
$genBody append "$ident = ${ident}_;\n"
}
}
foreach assoc [$class genAssocAttrSet] {
set var [$assoc getAssocVariable]
if [$assoc isQualified] {
$genBody append "$var = new Hashtable();\n"
} elseif {[$assoc getMultiplicity] == "many"} {
if {[$assoc isOrdered]} {
$genBody append "$var = new Queue();\n"
} else {
$genBody append "$var = new Vector();\n"
}
}
if [$assoc isReverseLinkAttr] {
set opposite [$assoc opposite]
if {$opposite != ""} {
$genBody append [$opposite extendAssociation $var]
}
}
}
set access [$this getMethodAccess]
if {$access == ""} {
set access "public"
}
$constructor access [JavaAccess new $access]
}
# Do not delete this line -- regeneration end marker
Class JVGConstructorD : {JVGConstructor OPConstructor} {
}
selfPromoter OPConstructor {this} {
JVGConstructorD promote $this
}
# File: @(#)jvgoperati.tcl /main/hindenburg/5
Class JVGOperation : {JVGFeature} {
constructor
method destructor
method generate
method generateClassMethod
method generateExceptions
method generateInterfaceMethod
method generateParameters
method generateStaticInitializer
method generateUserConstructor
}
constructor JVGOperation {class this name} {
set this [JVGFeature::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGOperation::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGOperation::generate {this} {
if {[$this getPropertyValue is_static] != ""} {
m4_warning $W_OLDPROPERTY is_static
}
set name [$this getName]
if {[$this isClassFeature] && $name == "create"} {
$this generateUserConstructor
} elseif {$name == "static"} {
$this generateStaticInitializer
} else {
if [[$this ooplClass] isInterface] {
$this generateInterfaceMethod
} else {
$this generateClassMethod
}
}
}
method JVGOperation::generateClassMethod {this} {
set class [$this ooplClass]
set container [$class container]
set method [JavaUserMethod new [$this getName]]
$container addMethod $method
$method comment [$this getComment]
if {[$this getTypeName] == ""} {
$method type [JavaType new "void"]
} else {
$method type [JavaType new [$this getTypeName]]
}
set access [$this getMethodAccess]
if {[$this isAbstract] &&
($access == "private" || $access == "private protected")} {
m4_warning $W_ABSPRIVMETH $access [$this getName] [$class getName]
set access "none"
}
if {$access != "none"} {
if {$access == ""} {
set access "public"
}
$method access [JavaAccess new $access]
}
if [$this isAbstract] {
if {[$class getModifier] != "abstract"} {
m4_warning $W_ABSTRACTMETH [$class getName] [$this getName]
m4_warning $W_NOTCOMPILE
}
$method addModifier [JavaModifier new "abstract"]
$method hasBody 0
} else {
if [$this isClassFeature] {
$method addModifier [JavaModifier new "static"]
}
if [$this isFinal] {
$method addModifier [JavaModifier new "final"]
}
}
if [$this isNative] {
$method addModifier [JavaModifier new "native"]
$method hasBody 0
}
if [$this isSynchronized] {
$method addModifier [JavaModifier new "synchronized"]
}
$this generateParameters $method
$this generateExceptions $method
}
method JVGOperation::generateExceptions {this method} {
foreach throwException [$this getPropertyValue method_exceptions] {
$method addThrow [JavaException new $throwException]
}
}
method JVGOperation::generateInterfaceMethod {this} {
set class [$this ooplClass]
set container [$class container]
set method [JavaUserMethod new [$this getName]]
$container addMethod $method
$method hasBody 0
$method comment [$this getComment]
if {[$this getTypeName] == ""} {
$method type [JavaType new "void"]
} else {
$method type [JavaType new [$this getTypeName]]
}
set access [$this getMethodAccess]
if {$access == "private" || $access == "protected" ||
$access == "private protected"} {
m4_warning $W_INVINTDECL $access [$this getName] [$class getName]
}
if {$access != "none"} {
set access "public"
$method access [JavaAccess new $access]
}
if [$this isNative] {
m4_warning $W_INVINTDECL native [$this getName] [$class getName]
}
if [$this isClassFeature] {
m4_warning $W_INVINTDECL static [$this getName] [$class getName]
}
if [$this isSynchronized] {
m4_warning $W_INVINTDECL synchronized [$this getName] [$class getName]
}
if [$this isFinal] {
m4_warning $W_INVINTDECL final [$this getName] [$class getName]
}
if [$this isAbstract] {
$method addModifier [JavaModifier new "abstract"]
$method hasBody 0
}
$this generateParameters $method
$this generateExceptions $method
}
method JVGOperation::generateParameters {this method} {
foreach param [$this parameterSet] {
set paramType [JavaType new [[$param ooplType] getName]]
set javaParam [JavaParameter new [$param getName] $paramType]
$method addParameter $javaParam
}
}
method JVGOperation::generateStaticInitializer {this} {
set container [[$this ooplClass] container]
set initializer [JavaStaticInitializer new "static"]
$container addMethod $initializer
$initializer comment [$this getComment]
}
method JVGOperation::generateUserConstructor {this} {
set class [$this ooplClass]
set container [$class container]
set constructor [JavaUserConstructor new [$class getName]]
$container addUserConstructor $constructor
$container addConstructor $constructor
$constructor comment [$this getComment]
foreach param [$this parameterSet] {
set paramType [JavaType new [[$param ooplType] getName]]
set javaParam [JavaParameter new [$param getName] $paramType]
$constructor addParameter $javaParam
}
foreach throwException [$this getPropertyValue method_exceptions] {
$constructor addThrow [JavaException new $throwException]
}
set access [$this getMethodAccess]
if {$access == "" || $access == "none"} {
set access "public"
}
$constructor access [JavaAccess new $access]
}
# Do not delete this line -- regeneration end marker
Class JVGOperationD : {JVGOperation OPOperation} {
}
selfPromoter OPOperation {this} {
JVGOperationD promote $this
}
# File: @(#)jvgbasetyp.tcl /main/hindenburg/1
Class JVGBaseType : {JVGType} {
constructor
method destructor
method getName
}
constructor JVGBaseType {class this name} {
set this [JVGType::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGBaseType::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGBaseType::getName {this} {
set name [$this getType3GL]
if {$name != ""} {
return $name
}
return [$this OPType::getName]
}
# Do not delete this line -- regeneration end marker
Class JVGBaseTypeD : {JVGBaseType OPBaseType} {
}
selfPromoter OPBaseType {this} {
JVGBaseTypeD promote $this
}
# File: @(#)jvgdataatt.tcl /main/hindenburg/4
Class JVGDataAttr : {JVGAttribute} {
constructor
method destructor
method generate
method generateClassVariable
method generateInterfaceVariable
method getVariableInitializer
}
constructor JVGDataAttr {class this name} {
set this [JVGAttribute::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGDataAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGDataAttr::generate {this} {
if {[$this getPropertyValue is_static] != ""} {
m4_warning $W_OLDPROPERTY is_static
}
set class [$this ooplClass]
if [$class isInterface] {
$this generateInterfaceVariable
} else {
$this generateClassVariable
}
}
method JVGDataAttr::generateClassVariable {this} {
set class [$this ooplClass]
set container [$class container]
set variable [JavaVariable new [$this getName]]
$container addVariable $variable
$variable type [JavaType new [$this getTypeName]]
$variable comment [$this getComment]
$variable initializer [$this getVariableInitializer]
if {[$this isFinal] && [$variable initializer] == ""} {
m4_warning $W_FINALVAR [$this getName] [$class getName]
m4_warning $W_NOTCOMPILE
}
set access [$this getAttributeAccess]
if {$access != "none"} {
if {$access == ""} {
set access "private"
}
$variable access [JavaAccess new $access]
}
if [$this isClassFeature] {
$variable addModifier [JavaModifier new "static"]
}
if [$this isFinal] {
$variable addModifier [JavaModifier new "final"]
}
if [$this isThreadsafe] {
$variable addModifier [JavaModifier new "threadsafe"]
}
if [$this isTransient] {
if {[$this isClassFeature] || [$this isFinal]} {
m4_warning $W_TRANSIENTVAR [$this getName] [$class getName]
m4_warning $W_NOTCOMPILE
}
$variable addModifier [JavaModifier new "transient"]
}
if [$this isVolatile] {
$variable addModifier [JavaModifier new "volatile"]
}
#
# Generate accessor methods
#
set access [$this getAccessorAccess "r"]
if {$access != "none"} {
set ident [$this getName]
set genBody [TextSection new]
set accessor [JavaAccMethod new "get[cap $ident]"]
if [$this isClassFeature] {
$accessor addModifier [JavaModifier new "static"]
}
$accessor type [JavaType new [$this getTypeName]]
$container addAttributeAccessor $accessor
$accessor access [JavaAccess new $access]
$accessor generatorBody $genBody
$genBody append "return $ident;\n"
}
set access [$this getAccessorAccess "w"]
if {![$this isFinal] && $access != "none"} {
set ident [$this getName]
set paramId "${ident}_"
set genBody [TextSection new]
set accessor [JavaAccMethod new "set[cap $ident]"]
set type [JavaType new [$this getTypeName]]
set parameter [JavaParameter new $paramId $type]
if [$this isClassFeature] {
$accessor addModifier [JavaModifier new "static"]
}
$container addAttributeAccessor $accessor
$accessor type [JavaType new "void"]
$accessor addParameter $parameter
$accessor access [JavaAccess new $access]
$accessor generatorBody $genBody
$genBody append "$ident = $paramId;\n"
}
}
method JVGDataAttr::generateInterfaceVariable {this} {
set class [$this ooplClass]
set container [$class container]
set variable [JavaVariable new [$this getName]]
$container addVariable $variable
$variable type [JavaType new [$this getTypeName]]
$variable comment [$this getComment]
$variable access [JavaAccess new "public"]
$variable initializer [$this getVariableInitializer]
if {[$variable initializer] == ""} {
m4_warning $W_INTVARNOASSGN [$this getName]
m4_warning $W_NOTCOMPILE
}
if [$this isClassFeature] {
$variable addModifier [JavaModifier new "static"]
}
if [$this isFinal] {
$variable addModifier [JavaModifier new "final"]
}
}
method JVGDataAttr::getVariableInitializer {this} {
if {[$this getPropertyValue default_value] != ""} {
m4_warning $W_OLDPROPERTY default_value
}
if {[set initVal [$this getPropertyValue initial_value]] != ""} {
return [JavaInitializer new $initVal]
}
if {[set initVal [$this getPropertyValue array_initialization]] != ""} {
return [JavaInitializer new $initVal]
}
return ""
}
# Do not delete this line -- regeneration end marker
Class JVGDataAttrD : {JVGDataAttr OPDataAttr} {
}
selfPromoter OPDataAttr {this} {
JVGDataAttrD promote $this
}
# File: @(#)jvggenasso.tcl /main/hindenburg/7
Class JVGGenAssocAttr : {JVGAttribute} {
constructor
method destructor
method generate
method generateAddAccessor
method generateGetAccessor
method generateGetManyAccessor
method generateRemoveAccessor
method generateSetAccessor
method generateAssociationVariable
method getAssocIdentifier
method getAssocVariable
method isClassFeature
method extendAssociation
method reduceAssociation
method setAssociation
}
constructor JVGGenAssocAttr {class this name} {
set this [JVGAttribute::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGGenAssocAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGGenAssocAttr::generate {this} {
# !! Implement this function !!
}
method JVGGenAssocAttr::generateAddAccessor {this} {
set ident [$this getAssocIdentifier]
if [$this isOrdered] {
set accessor [JavaAccMethod new "append[cap $ident]"]
} else {
set accessor [JavaAccMethod new "add[cap $ident]"]
}
[[$this ooplClass] container] addAssociationAccessor $accessor
$accessor type [JavaType new "void"]
if [$this isQualified] {
set qualifier [$this qualifier]
set qualTypeName [[$qualifier ooplType] getName]
set qualId "[$qualifier getName]_"
set type [JavaType new $qualTypeName]
$accessor addParameter [JavaParameter new $qualId $type]
}
set opposite [$this opposite]
if {$opposite != "" && [$opposite isQualified]} {
set qualTypeName [[[$opposite qualifier] ooplType] getName]
set qualId "[[$opposite qualifier] getName]_"
set type [JavaType new $qualTypeName]
$accessor addParameter [JavaParameter new $qualId $type]
}
set paramId "${ident}_"
set type [JavaType new [[$this ooplType] getName]]
$accessor addParameter [JavaParameter new $paramId $type]
set body [TextSection new]
$accessor generatorBody $body
$body append "if ($paramId == null)\n"
$body append " return;\n";
if {$opposite != ""} {
if {[$opposite getMultiplicity] == "one" &&
![$opposite isQualified] && ![$this isQualified]} {
$body append [$opposite setAssociation $paramId]
}
$body append [$opposite extendAssociation $paramId]
}
if [$this isQualified] {
[[$this ooplClass] container] needsVector 1
set varName [$this getAssocVariable]
$body append "// You must supply a hashCode and equals method for Object\n"
$body append "// [[$this qualifier] getName] for java.util.Hashtable usage.\n"
$body append "Vector vector = (Vector) $varName.get($qualId);\n"
$body append "if (vector == null) {\n"
$body append " vector = new Vector();\n"
$body append " $varName.put($qualId, vector);\n"
$body append "}\n"
$body append "vector.addElement($paramId);\n"
} else {
$body append [$this extendAssociation "" $paramId]
}
set access [$this getAccessorAccess w]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
}
method JVGGenAssocAttr::generateGetAccessor {this} {
set varName [$this getAssocVariable]
set accessor [JavaAccMethod new "get[cap $varName]"]
[[$this ooplClass] container] addAssociationAccessor $accessor
$accessor type [JavaType new [[$this ooplType] getName]]
set access [$this getAccessorAccess r]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
set body [TextSection new]
$body append "return $varName;\n"
$accessor generatorBody $body
}
method JVGGenAssocAttr::generateGetManyAccessor {this} {
set varName [$this getAssocVariable]
set accessor [JavaAccMethod new "get[cap $varName]"]
[[$this ooplClass] container] addAssociationAccessor $accessor
if [$this isOrdered] {
$accessor type [JavaType new "Queue"]
} else {
[[$this ooplClass] container] needsVector 1
$accessor type [JavaType new "Vector"]
}
set access [$this getAccessorAccess r]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
set body [TextSection new]
$body append "return $varName;\n"
$accessor generatorBody $body
}
method JVGGenAssocAttr::generateRemoveAccessor {this} {
set ident [$this getAssocIdentifier]
set opposite [$this opposite]
set accessor [JavaAccMethod new "remove[cap $ident]"]
[[$this ooplClass] container] addAssociationAccessor $accessor
$accessor type [JavaType new "void"]
if {$opposite != "" && [$opposite isQualified]} {
set qualifier [$opposite qualifier]
set type [JavaType new [[$qualifier ooplType] getName]]
set qualId "[$qualifier getName]_"
$accessor addParameter [JavaParameter new $qualId $type]
}
set paramId "${ident}_"
set type [JavaType new [[$this ooplType] getName]]
$accessor addParameter [JavaParameter new $paramId $type]
set body [TextSection new]
$accessor generatorBody $body
$body append "if ($paramId == null)\n"
$body append " return;\n"
if {$opposite != ""} {
$body append [$opposite reduceAssociation $paramId]
}
$body append [$this reduceAssociation "" $paramId]
set access [$this getAccessorAccess w]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
}
method JVGGenAssocAttr::generateSetAccessor {this} {
set opposite [$this opposite]
set ident [$this getAssocIdentifier]
set paramId "${ident}_"
set accessor [JavaAccMethod new "set[cap $ident]"]
[[$this ooplClass] container] addAssociationAccessor $accessor
$accessor type [JavaType new "void"]
set access [$this getAccessorAccess w]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
if {$opposite != "" && [$opposite isQualified]} {
set qualifier [$opposite qualifier]
set type [JavaType new [[$qualifier ooplType] getName]]
set parameter [JavaParameter new "[$qualifier getName]_" $type]
$accessor addParameter $parameter
}
set type [JavaType new [[$this ooplType] getName]]
$accessor addParameter [JavaParameter new $paramId $type]
set body [TextSection new]
$accessor generatorBody $body
if {$opposite != ""} {
if [$opposite isQualified] {
$body append "if ($paramId != null)\n"
$body append " [$opposite extendAssociation $paramId]"
} else {
$body append "if ($ident != null)\n"
$body append " [$opposite reduceAssociation $ident]"
if {[$opposite getMultiplicity] == "one"} {
$body append "if ($paramId != null) {\n"
$body append " [$opposite setAssociation $paramId]"
$body append " [$opposite extendAssociation $paramId]"
$body append "}\n"
}
if {[$opposite getMultiplicity] == "many"} {
$body append "if ($paramId != null)\n"
$body append " [$opposite extendAssociation $paramId]"
}
}
}
$body append "$ident = $paramId;\n"
}
method JVGGenAssocAttr::generateAssociationVariable {this} {
set assocVar [JavaVariable new [$this getAssocVariable]]
if [$this isQualified] {
[[$this ooplClass] container] needsHashtable 1
$assocVar type [JavaType new "Hashtable"]
} elseif {[$this getMultiplicity] == "many"} {
if [$this isOrdered] {
$assocVar type [JavaType new "Queue"]
} else {
[[$this ooplClass] container] needsVector 1
$assocVar type [JavaType new "Vector"]
}
} else {
$assocVar type [JavaType new [[$this ooplType] getName]]
}
[[$this ooplClass] container] addAssocVariable $assocVar
if {[$this opposite] != ""} {
set access "public"
} else {
set access [$this getAttributeAccess]
}
if {$access != "none"} {
if {$access == ""} {
set access "private"
}
$assocVar access [JavaAccess new $access]
}
if [$this isClassFeature] {
$assocVar addModifier [JavaModifier new "static"]
}
if [$this isThreadsafe] {
$assocVar addModifier [JavaModifier new "threadsafe"]
}
if [$this isTransient] {
$assocVar addModifier [JavaModifier new "transient"]
}
if [$this isVolatile] {
$assocVar addModifier [JavaModifier new "volatile"]
}
}
method JVGGenAssocAttr::getAssocIdentifier {this} {
if [$this isLinkAttr] {
return [uncap [[$this ooplType] getName]Of[cap [$this getName]]]
}
return [$this getName]
}
method JVGGenAssocAttr::getAssocVariable {this} {
if {[$this getMultiplicity] == "many"} {
return [$this getAssocIdentifier]Set
}
return [$this getAssocIdentifier]
}
method JVGGenAssocAttr::isClassFeature {this} {
if {[$this getPropertyValue "is_static"] == "1"} {
return "1"
}
return "0"
}
method JVGGenAssocAttr::extendAssociation {this {prefix ""} {element "this"}} {
set sect [TextSection new]
if {$prefix != ""} {
set prefix ${prefix}.
}
set varName [$this getAssocVariable]
if [$this isQualified] {
set qualId "[[$this qualifier] getName]_"
if {[$this getMultiplicity] == "one"} {
return "$prefix$varName.put($qualId, $element);\n"
}
set ident [$this getAssocIdentifier]
return "${prefix}add[cap $ident]($qualId, $element);\n"
}
if {[$this getMultiplicity] == "one"} {
return "$prefix$varName = $element;\n"
}
if [$this isOrdered] {
return "$prefix$varName.append($element);\n"
}
return "$prefix$varName.addElement($element);\n"
}
method JVGGenAssocAttr::reduceAssociation {this {prefix ""} {element "this"}} {
if {$prefix != ""} {
set prefix "${prefix}."
}
set varName [$this getAssocVariable]
if [$this isQualified] {
set qualId "[[$this qualifier] getName]_"
if {[$this getMultiplicity] == "one"} {
return "$prefix$varName.remove($qualId);\n"
}
set ident [$this getAssocIdentifier]
return "${prefix}remove[cap $ident]($qualId, $element);\n"
}
if {[$this getMultiplicity] == "one"} {
return "$prefix$varName = null;\n"
}
return "$prefix$varName.removeElement($element);\n"
}
method JVGGenAssocAttr::setAssociation {this {prefix ""} {element "null"}} {
if {$prefix != ""} {
set prefix "${prefix}."
}
return "${prefix}set[cap [$this getAssocIdentifier]]($element);\n"
}
# Do not delete this line -- regeneration end marker
Class JVGGenAssocAttrD : {JVGGenAssocAttr OPGenAssocAttr} {
}
selfPromoter OPGenAssocAttr {this} {
JVGGenAssocAttrD promote $this
}
# File: @(#)jvgassocat.tcl /main/hindenburg/3
Class JVGAssocAttr : {JVGGenAssocAttr} {
constructor
method destructor
method generate
}
constructor JVGAssocAttr {class this name} {
set this [JVGGenAssocAttr::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGAssocAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGAssocAttr::generate {this} {
if [[$this ooplClass] isInterface] {
return
}
$this generateAssociationVariable
if {[$this getMultiplicity] == "one"} {
if {[$this getAccessorAccess r] != "none"} {
$this generateGetAccessor
}
if {[$this getAccessorAccess w] != "none"} {
$this generateSetAccessor
}
} else {
if {[$this getAccessorAccess w] != "none"} {
$this generateAddAccessor
$this generateRemoveAccessor
}
if {[$this getAccessorAccess r] != "none"} {
$this generateGetManyAccessor
}
}
}
# Do not delete this line -- regeneration end marker
Class JVGAssocAttrD : {JVGAssocAttr OPAssocAttr} {
}
selfPromoter OPAssocAttr {this} {
JVGAssocAttrD promote $this
}
# File: @(#)jvglinkatt.tcl /main/hindenburg/1
Class JVGLinkAttr : {JVGGenAssocAttr} {
constructor
method destructor
method generate
}
constructor JVGLinkAttr {class this name} {
set this [JVGGenAssocAttr::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGLinkAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGLinkAttr::generate {this} {
if [[$this ooplClass] isInterface] {
return
}
$this generateAssociationVariable
if {[$this getMultiplicity] == "one"} {
$this generateGetAccessor
} else {
$this generateGetManyAccessor
}
}
# Do not delete this line -- regeneration end marker
Class JVGLinkAttrD : {JVGLinkAttr OPLinkAttr} {
}
selfPromoter OPLinkAttr {this} {
JVGLinkAttrD promote $this
}
# File: @(#)jvgqualatt.tcl /main/hindenburg/4
Class JVGQualAttr : {JVGGenAssocAttr} {
constructor
method destructor
method generate
method generateGetQualifiedAccessor
method generateRemoveQualifiedAccessor
method generateSetQualifiedAccessor
}
constructor JVGQualAttr {class this name} {
set this [JVGGenAssocAttr::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGQualAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGQualAttr::generate {this} {
if [[$this ooplClass] isInterface] {
return
}
$this generateAssociationVariable
if {[$this getAccessorAccess r] != "none"} {
$this generateGetQualifiedAccessor
}
if {[$this getAccessorAccess w] != "none"} {
if {[$this getMultiplicity] == "one"} {
$this generateSetQualifiedAccessor
} else {
$this generateAddAccessor
}
$this generateRemoveQualifiedAccessor
}
}
method JVGQualAttr::generateGetQualifiedAccessor {this} {
set varName [$this getAssocVariable]
set assocType [$this ooplType]
set accessor [JavaAccMethod new "get[cap $varName]"]
[[$this ooplClass] container] addAssociationAccessor $accessor
if {[$this getMultiplicity] == "many"} {
[[$this ooplClass] container] needsVector 1
set assocTypeName "Vector"
} else {
set assocTypeName [$assocType getName]
}
set access [$this getAccessorAccess r]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
$accessor type [JavaType new $assocTypeName]
set qualifier [$this qualifier]
set qualName [$qualifier getName]
set qualType [$qualifier ooplType]
set qualTypeName [$qualType getName]
set type [JavaType new $qualTypeName]
set qualId "${qualName}_"
$accessor addParameter [JavaParameter new $qualId $type]
#
# Check if qualifier has one of the Java builtin types.
# The type of a qualifier must be derived from Object.
#
set wrongTypes "byte short int long char float double boolean"
if {[lsearch $wrongTypes $qualTypeName] != -1} {
set item [[$this smConnector] getItem]
if [$item isNil] {
set itemName ""
} else {
set itemName [$item name]
}
m4_warning $W_QUALWRONGTYPE $qualName $itemName [$this getName] $qualTypeName
m4_warning $W_NOTCOMPILE
}
set body [TextSection new]
$body append "Object object = $varName.get($qualId);\n"
$body append "if (object != null)\n"
$body append " return (($assocTypeName) object);\n"
$body append "return null;\n"
$accessor generatorBody $body
}
method JVGQualAttr::generateRemoveQualifiedAccessor {this} {
set ident [$this getAssocIdentifier]
set accessor [JavaAccMethod new "remove[cap $ident]"]
[[$this ooplClass] container] addAssociationAccessor $accessor
$accessor type [JavaType new "void"]
set access [$this getAccessorAccess w]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
set qualType [JavaType new [[[$this qualifier] ooplType] getName]]
set qualId "[[$this qualifier] getName]_"
$accessor addParameter [JavaParameter new $qualId $qualType]
set body [TextSection new]
set paramId "${ident}_"
set opposite [$this opposite]
set varName [$this getAssocVariable]
if {[$this getMultiplicity] == "one"} {
$body append "Object object = $varName.get($qualId);\n"
$body append "if (object == null)\n"
$body append " return;\n"
$body append [$this reduceAssociation]
if {$opposite != ""} {
set typeName [[$this ooplType] getName]
$body append "$typeName $paramId = ($typeName) object;\n"
}
} else {
[[$this ooplClass] container] needsVector 1
set type [JavaType new [[$this ooplType] getName]]
$accessor addParameter [JavaParameter new $paramId $type]
$body append "if ($paramId == null)\n"
$body append " return;\n"
$body append "Vector vector = (Vector) $varName.get($qualId);\n";
$body append "if (vector != null)\n";
$body append " vector.removeElement($paramId);\n"
}
if {$opposite != ""} {
$body append [$opposite reduceAssociation $paramId]
}
$accessor generatorBody $body
}
method JVGQualAttr::generateSetQualifiedAccessor {this} {
set ident [$this getAssocIdentifier]
set accessor [JavaAccMethod new "set[cap $ident]"]
set qualifier [$this qualifier]
set qualType [JavaType new [[$qualifier ooplType] getName]]
set qualId "[$qualifier getName]_"
[[$this ooplClass] container] addAssociationAccessor $accessor
$accessor addParameter [JavaParameter new $qualId $qualType]
$accessor type [JavaType new "void"]
set paramId "${ident}_"
set type [JavaType new [[$this ooplType] getName]]
$accessor addParameter [JavaParameter new $paramId $type]
set access [$this getAccessorAccess w]
if {$access != "none"} {
$accessor access [JavaAccess new $access]
}
set body [TextSection new]
$body append "if ($paramId == null)\n"
$body append " return;\n"
$body append "$ident.put($qualId, $paramId);\n"
set opposite [$this opposite]
if {$opposite != ""} {
$body append [$opposite extendAssociation $paramId]
}
$accessor generatorBody $body
}
# Do not delete this line -- regeneration end marker
Class JVGQualAttrD : {JVGQualAttr OPQualAttr} {
}
selfPromoter OPQualAttr {this} {
JVGQualAttrD promote $this
}
# File: @(#)jvgreverse.tcl /main/hindenburg/1
Class JVGReverseLinkAttr : {JVGGenAssocAttr} {
constructor
method destructor
method generate
}
constructor JVGReverseLinkAttr {class this name} {
set this [JVGGenAssocAttr::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGReverseLinkAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGReverseLinkAttr::generate {this} {
if [[$this ooplClass] isInterface] {
return
}
$this generateAssociationVariable
if {[$this getMultiplicity] == "one"} {
$this generateGetAccessor
} else {
$this generateGetManyAccessor
}
}
# Do not delete this line -- regeneration end marker
Class JVGReverseLinkAttrD : {JVGReverseLinkAttr OPReverseLinkAttr} {
}
selfPromoter OPReverseLinkAttr {this} {
JVGReverseLinkAttrD promote $this
}
# File: @(#)jvgqualass.tcl /main/hindenburg/1
Class JVGQualAssocAttr : {JVGQualAttr} {
constructor
method destructor
method generate
}
constructor JVGQualAssocAttr {class this name} {
set this [JVGQualAttr::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGQualAssocAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGQualAssocAttr::generate {this} {
$this JVGQualAttr::generate
}
# Do not delete this line -- regeneration end marker
Class JVGQualAssocAttrD : {JVGQualAssocAttr OPQualAssocAttr} {
}
selfPromoter OPQualAssocAttr {this} {
JVGQualAssocAttrD promote $this
}
# File: @(#)jvgquallin.tcl /main/hindenburg/1
Class JVGQualLinkAttr : {JVGQualAttr} {
constructor
method destructor
method generate
}
constructor JVGQualLinkAttr {class this name} {
set this [JVGQualAttr::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method JVGQualLinkAttr::destructor {this} {
# Start destructor user section
# End destructor user section
}
method JVGQualLinkAttr::generate {this} {
$this JVGQualAttr::generate
}
# Do not delete this line -- regeneration end marker
Class JVGQualLinkAttrD : {JVGQualLinkAttr OPQualLinkAttr} {
}
selfPromoter OPQualLinkAttr {this} {
JVGQualLinkAttrD promote $this
}