javaclassdeclarationblock.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "javaclassdeclarationblock.h"
00017 #include "javacodedocumentation.h"
00018 #include "../codegenerator.h"
00019 #include "../codegenerationpolicy.h"
00020 #include "../uml.h"
00021
00022
00023
00024
00025 JavaClassDeclarationBlock::JavaClassDeclarationBlock
00026 ( JavaClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
00027 : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
00028 {
00029 init(parentDoc, comment);
00030 }
00031
00032 JavaClassDeclarationBlock::~JavaClassDeclarationBlock ( ) { }
00033
00034
00035
00036
00037
00041 void JavaClassDeclarationBlock::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00042 QDomElement blockElement = doc.createElement( "javaclassdeclarationblock" );
00043
00044 setAttributesOnNode(doc, blockElement);
00045
00046 root.appendChild( blockElement );
00047 }
00048
00052 void JavaClassDeclarationBlock::loadFromXMI ( QDomElement & root )
00053 {
00054 setAttributesFromNode(root);
00055 }
00056
00057
00058
00059
00060
00061
00062
00066 void JavaClassDeclarationBlock::updateContent ( )
00067 {
00068
00069 JavaClassifierCodeDocument *parentDoc = dynamic_cast<JavaClassifierCodeDocument*>(getParentDocument());
00070 UMLClassifier *c = parentDoc->getParentClassifier();
00071 CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
00072 QString endLine = commonPolicy->getNewLineEndingChars();
00073 bool isInterface = parentDoc->parentIsInterface();
00074 QString JavaClassName = parentDoc->getJavaClassName(c->getName());
00075
00076
00077 if(isInterface)
00078 getComment()->setText("Interface "+JavaClassName+endLine+c->getDoc());
00079 else
00080 getComment()->setText("Class "+JavaClassName+endLine+c->getDoc());
00081
00082 bool forceDoc = UMLApp::app()->getCommonPolicy()->getCodeVerboseDocumentComments();
00083 if(forceDoc || !c->getDoc().isEmpty())
00084 getComment()->setWriteOutText(true);
00085 else
00086 getComment()->setWriteOutText(false);
00087
00088
00089
00090 QString startText = "";
00091
00092 if (c->getAbstract() && !isInterface)
00093 startText.append("abstract ");
00094
00095 if (c->getVisibility() != Uml::Visibility::Public) {
00096
00097
00098
00099
00100
00101 } else
00102 startText.append("public ");
00103
00104 if(parentDoc->parentIsInterface())
00105 startText.append("interface ");
00106 else
00107 startText.append("class ");
00108
00109 startText.append(JavaClassName);
00110
00111
00112 UMLClassifierList superclasses =
00113 c->findSuperClassConcepts(UMLClassifier::CLASS);
00114 UMLClassifierList superinterfaces =
00115 c->findSuperClassConcepts(UMLClassifier::INTERFACE);
00116 int nrof_superclasses = superclasses.count();
00117 int nrof_superinterfaces = superinterfaces.count();
00118
00119
00120 int i = 0;
00121 if(nrof_superclasses >0)
00122 startText.append(" extends ");
00123 for (UMLClassifier * concept= superclasses.first(); concept; concept = superclasses.next())
00124 {
00125 startText.append(parentDoc->cleanName(concept->getName()));
00126 if(i != (nrof_superclasses-1))
00127 startText.append(", ");
00128 i++;
00129 }
00130
00131
00132 i = 0;
00133 if(nrof_superinterfaces >0)
00134 {
00135
00136 if(isInterface)
00137 startText.append(" extends ");
00138 else
00139 startText.append(" implements ");
00140 }
00141 for (UMLClassifier * concept= superinterfaces.first(); concept; concept = superinterfaces.next())
00142 {
00143 startText.append(parentDoc->cleanName(concept->getName()));
00144 if(i != (nrof_superinterfaces-1))
00145 startText.append(", ");
00146 i++;
00147 }
00148
00149
00150 setStartText(startText+" {");
00151
00152
00153
00154 }
00155
00156 void JavaClassDeclarationBlock::init (JavaClassifierCodeDocument *parentDoc, const QString &comment)
00157 {
00158
00159 setComment(new JavaCodeDocumentation(parentDoc));
00160 getComment()->setText(comment);
00161
00162 setEndText("}");
00163
00164 updateContent();
00165
00166 }
00167
00168
00169 #include "javaclassdeclarationblock.moc"
This file is part of the documentation for umbrello Version 3.1.0.