[Uml-devel] [Bug 53374] Java interface inheritance, abstract classes and generics in code generation
Oliver Kellogg
okellogg at users.sourceforge.net
Mon Feb 19 20:54:11 UTC 2007
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=53374
okellogg users sourceforge net changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From okellogg users sourceforge net 2007-02-19 21:54 -------
SVN commit 635329 by okellogg:
Apply attachment 19724 from Antoine Dopffer.
> I couldn't manage to design a generic method with umbrello [...]
> so I couldn't update the java generator for handling generic method.
>
If anybody needs this they should open a new wish.
BUG:53374
M +4 -1 ChangeLog
M +4 -2 umbrello/classifier.cpp
M +47 -9 umbrello/codegenerators/javawriter.cpp
--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #635328:635329
@ -2,6 +2,8 @
* Bugs/wishes from http://bugs.kde.org:
* C# Code Generation and export (53368)
+* Java interface inheritance, abstract classes and generics in code generation
+ (53376)
* %date% and %time% not being parsed (96612)
* Relationships for entities do not live outside of the diagram (125146)
* Javascript wrong Code Generation (135527)
@ -10,7 +12,8 @
* Associations not updated during move of class on diagram (140709)
* Crash when deleting the link between a package and a class (141602)
* Ada95 Code Generation Errors for Aggregation (141644)
-* Unable to delete multiplicity information or lable from an association (141813)
+* Unable to delete multiplicity information or lable from an association
+ (141813)
Version 1.5.61
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/classifier.cpp #635328:635329
@ -381,7 +381,8 @
UMLObject* obj = a->getObject(A);
UMLClassifier *concept = dynamic_cast<UMLClassifier*>(obj);
if (concept && (type == ALL || (!concept->isInterface() && type == CLASS)
- || (concept->isInterface() && type == INTERFACE)))
+ || (concept->isInterface() && type == INTERFACE))
+ && (inheritingConcepts.findRef(concept) == -1))
inheritingConcepts.append(concept);
}
}
@ -409,7 +410,8 @
UMLObject* obj = a->getObject(B);
UMLClassifier *concept = dynamic_cast<UMLClassifier*>(obj);
if (concept && (type == ALL || (!concept->isInterface() && type == CLASS)
- || (concept->isInterface() && type == INTERFACE)))
+ || (concept->isInterface() && type == INTERFACE))
+ && (parentConcepts.findRef(concept) == -1))
parentConcepts.append(concept);
}
}
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javawriter.cpp #635328:635329
@ -31,6 +31,8 @
#include "../operation.h"
#include "../attribute.h"
#include "../association.h"
+#include "../template.h"
+#include "../umltemplatelist.h"
JavaWriter::JavaWriter() {
startline = m_endl + m_indentation;
@ -280,7 +282,7 @
} else
scope = "public ";
- java<<(c->getAbstract()?QString("abstract "):QString(""))<<scope;
+ java<<((c->getAbstract() && !isInterface) ? QString("abstract ") : QString(""))<<scope;
if(isInterface)
java<<"interface ";
else
@ -288,23 +290,59 @
java<<classname;
+ // Generics
+ UMLTemplateList template_params = c->getTemplateList();
+ if (template_params.count()) {
+ java << "<";
+ for (UMLTemplate *t = template_params.first(); t; ) {
+ QString formalName = t->getName();
+ java << formalName;
+ if ((t = template_params.next()) != NULL)
+ java << ", ";
+ }
+ java << ">" << m_endl;
+ }
// write inheritances out
UMLClassifier *concept;
- UMLClassifierList superclasses = c->findSuperClassConcepts();
+ UMLClassifierList superclasses = c->findSuperClassConcepts(UMLClassifier::CLASS);
- if(superclasses.count()>0)
- java<<" extends ";
-
- // Q: Where is 'implements' ??
-
int i = 0;
for (concept= superclasses.first(); concept; concept = superclasses.next())
{
- java<<cleanName(concept->getName())<<(i>0?", ":"");
+ if (i == 0)
+ {
+ java<< " extends ";
+ }
+ else
+ {
+ //The java generated code is wrong ! : No multiple inheritence of class
+ java<< ", " ;
+ }
+ java<< cleanName(concept->getName());
i++;
}
+ UMLClassifierList superInterfaces = c->findSuperClassConcepts(UMLClassifier::INTERFACE);
+ i = 0;
+ for (concept= superInterfaces.first(); concept; concept = superInterfaces.next())
+ {
+ if (i == 0)
+ {
+ if (isInterface)
+ java<< " extends ";
+ else
+ java<< " implements ";
+ }
+ else
+ {
+ //The java generated code is OK ! : multiple inheritence of interface
+ java<< ", " ;
+ }
+ java<< cleanName(concept->getName());
+ i++;
+ }
+
}
void JavaWriter::writeAttributeDecls(UMLAttributeList &atpub, UMLAttributeList &atprot,
@ -740,7 +778,7 @
returnStr += " return "+methodReturnType+"\n";
str = ""; // reset for next method
- str += ((op->getAbstract() || isInterface) ? "abstract ":"");
+ str += ((op->getAbstract() && !isInterface) ? "abstract ":"");
str += scopeToJavaDecl(op->getVisibility()) + ' ';
str += (op->getStatic() ? "static ":"");
str += methodReturnType + ' ' +cleanName(op->getName()) + "( ";
More information about the umbrello-devel
mailing list