javacodeclassfielddeclarationblock.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "javacodeclassfielddeclarationblock.h"
00018
00019 #include "javacodeclassfield.h"
00020 #include "javaclassifiercodedocument.h"
00021 #include "javacodegenerationpolicy.h"
00022 #include "../codegenerator.h"
00023 #include "../classifier.h"
00024 #include "../umlrole.h"
00025 #include "../uml.h"
00026
00027
00028
00029
00030 JavaCodeClassFieldDeclarationBlock::JavaCodeClassFieldDeclarationBlock ( CodeClassField * parent )
00031 : CodeClassFieldDeclarationBlock ( parent )
00032 {
00033 setOverallIndentationLevel(1);
00034 updateContent();
00035 }
00036
00037 JavaCodeClassFieldDeclarationBlock::~JavaCodeClassFieldDeclarationBlock ( ) { }
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00050 void JavaCodeClassFieldDeclarationBlock::updateContent( )
00051 {
00052
00053 CodeClassField * cf = getParentClassField();
00054 ClassifierCodeDocument * doc = cf->getParentDocument();
00055 JavaCodeClassField * jcf = dynamic_cast<JavaCodeClassField*>(cf);
00056 JavaClassifierCodeDocument* jdoc = dynamic_cast<JavaClassifierCodeDocument*>(doc);
00057 CodeGenerationPolicy * commonpolicy = UMLApp::app()->getCommonPolicy();
00058
00059 CodeGenerationPolicy::ScopePolicy scopePolicy = commonpolicy->getAssociationFieldScope();
00060
00061
00062 QString notes = getParentObject()->getDoc();
00063 getComment()->setText(notes);
00064
00065
00066 QString staticValue = getParentObject()->getStatic() ? "static " : "";
00067 QString scopeStr = jdoc->scopeToJavaDecl(getParentObject()->getVisibility());
00068
00069
00070 if(!jcf->parentIsAttribute())
00071 {
00072 switch (scopePolicy) {
00073 case CodeGenerationPolicy::Public:
00074 case CodeGenerationPolicy::Private:
00075 case CodeGenerationPolicy::Protected:
00076 scopeStr = jdoc->scopeToJavaDecl((Uml::Visibility::Value) scopePolicy);
00077 break;
00078 default:
00079 case CodeGenerationPolicy::FromParent:
00080
00081 break;
00082 }
00083 }
00084
00085 QString typeName = jcf->getTypeName();
00086 QString fieldName = jcf->getFieldName();
00087 QString initialV = jcf->getInitialValue();
00088
00089 if (!cf->parentIsAttribute() && !cf->fieldIsSingleValue())
00090 typeName = "List";
00091
00092 QString body = staticValue+scopeStr+' '+typeName+' '+fieldName;
00093 if (!initialV.isEmpty())
00094 body.append(" = " + initialV);
00095 else if (!cf->parentIsAttribute())
00096 {
00097 UMLRole * role = dynamic_cast<UMLRole*>(cf->getParentObject());
00098 if (role->getObject()->getBaseType() == Uml::ot_Interface)
00099 {
00100
00101 } else {
00102
00103
00104
00105 if(cf->fieldIsSingleValue())
00106 {
00107 if(!typeName.isEmpty())
00108 body.append(" = new " + typeName + " ( )");
00109 } else
00110 body.append(" = new Vector ( )");
00111 }
00112 }
00113
00114 setText(body+';');
00115
00116 }
00117
00118 #include "javacodeclassfielddeclarationblock.moc"
This file is part of the documentation for umbrello Version 3.1.0.