void UmlClass::gen_java_decl(QCString s, bool descr) { const char * p = bypass_comment(s); UmlRelation * extend = 0; while (*p != 0) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${public}", 9)) { p += 9; if (isJavaPublic()) fw.write("public "); } else if (!strncmp(p, "${visibility}", 13)) { p += 13; UmlItem::write(visibility(), javaLanguage); fw.write(' '); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isJavaFinal()) fw.write("final "); } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract()) fw.write("abstract "); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(name()); generics(); } else if (!strncmp(p, "${extends}", 10)) { p += 10; const QVector<UmlItem> ch = children(); for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if (((k == aGeneralisation) || (k == aRealization)) && (!rel->javaDecl().isEmpty()) && ((JavaSettings::classStereotype(stereotype()) == "interface") || (JavaSettings::classStereotype(rel->roleType()->stereotype()) != "interface"))) { extend = rel; fw.write(" extends "); rel->roleType()->write(); generate(actuals(), rel->roleType(), FALSE); break; } } } } else if (!strncmp(p, "${implements}", 13)) { p += 13; const QVector<UmlItem> ch = children(); const char * sep = " implements "; for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if ((rel != extend) && ((k == aGeneralisation) || (k == aRealization)) && (!rel->javaDecl().isEmpty())) { fw.write(sep); sep = ", "; rel->roleType()->write(); generate(actuals(), rel->roleType(), FALSE); } } } } else if (!strncmp(p, "${@}", 4)) p += 4; else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if ((*p == '{') || (*p == ';')) { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
// not from a form 'generic<...C...> var' where C is a class bool UmlRelation::new_one(Class * container, const WrapperStr & name, UmlTypeSpec & dest, WrapperStr str_actuals, aVisibility visibility, bool staticp, bool constp, bool transientp, bool volatilep, const WrapperStr & array, const WrapperStr & value, WrapperStr comment, WrapperStr description, WrapperStr annotation #ifdef ROUNDTRIP , bool roundtrip, QList<UmlItem *> & expected_order #endif ) { #ifdef TRACE QLOG_INFO() << "RELATION '" << name << "' from '" << cl->Name() << "' to '" << dest.type->Name() << "' array '" << array << "'\n"; #endif if ( #ifdef REVERSE container->from_libp() && #endif (visibility == PrivateVisibility)) { Lex::finish_line(); Lex::clear_comments(); return TRUE; } UmlClass * cl = container->get_uml(); UmlRelation * rel; #ifdef ROUNDTRIP bool created; if (!roundtrip || ((rel = search_rel(container, name, dest.type, "")) == 0)) { #endif rel = UmlBaseRelation::create(aDirectionalAssociation, cl, dest.type); if (rel == 0) { JavaCatWindow::trace(WrapperStr("<font face=helvetica><b>cannot add relation <i>") + name + "</i> in <i>" + cl->name() + "</i> to <i>" + dest.type->name() + "</i></b></font><br>"); return FALSE; } #ifdef REVERSE # ifndef ROUNDTRIP Statistic::one_relation_more(); # else if (roundtrip) container->set_updated(); created = TRUE; } else created = FALSE; # endif #endif WrapperStr decl = JavaSettings::relationDecl(array); UmlClass::manage_generic(decl, dest, str_actuals, "${type}"); Lex::finish_line(); comment = Lex::get_comments(comment); description = Lex::get_description(description); #ifdef ROUNDTRIP if (roundtrip && !created) { if (rel->visibility() != visibility) { rel->set_Visibility(visibility); container->set_updated(); } if (decl.find("${description}") != -1) { if (nequal(rel->description(), description)) { rel->set_Description(description); container->set_updated(); } } else if (nequal(rel->description(), Lex::simplify_comment(comment))) { rel->set_Description(comment); // comment was set container->set_updated(); } if (rel->isReadOnly() != constp) { rel->set_isReadOnly(constp); container->set_updated(); } if (rel->isJavaTransient() != transientp) { rel->set_isJavaTransient(transientp); container->set_updated(); } if (rel->isVolatile() != volatilep) { rel->set_isVolatile(volatilep); container->set_updated(); } if (rel->isClassMember() != staticp) { rel->set_isClassMember(staticp); container->set_updated(); } if (neq(rel->multiplicity(), array)) { rel->set_Multiplicity(array); container->set_updated(); } WrapperStr v = rel->defaultValue(); if (!v.isEmpty() && (((const char *) v)[0] == '=')) v = v.mid(1); if (nequal(v, value)) { rel->set_DefaultValue(value); container->set_updated(); } if (nequal(rel->javaAnnotations(), annotation)) { rel->set_JavaAnnotations(annotation); container->set_updated(); } if (neq(rel->javaDecl(), decl)) { rel->set_JavaDecl(decl); container->set_updated(); } rel->set_usefull(); expected_order.append(rel); } else { #endif rel->set_Visibility(visibility); if (!comment.isEmpty()) rel->set_Description((decl.find("${description}") != -1) ? description : comment); if (constp) rel->set_isReadOnly(TRUE); if (transientp) rel->set_isJavaTransient(TRUE); if (volatilep) rel->set_isVolatile(TRUE); if (staticp) rel->set_isClassMember(TRUE); if (!array.isEmpty()) rel->set_Multiplicity(array); if (! value.isEmpty()) rel->set_DefaultValue(value); if (! annotation.isEmpty()) rel->set_JavaAnnotations(annotation); rel->set_JavaDecl(decl); rel->set_RoleName(name); #ifdef ROUNDTRIP if (roundtrip) expected_order.append(rel); } #endif return TRUE; }
// from a form 'generic<...C...> var' where C is a class bool UmlRelation::new_one(Class * container, const QCString & name, UmlClass * type, QCString type_def, QCString genericname, aVisibility visibility, bool staticp, bool constp, bool transientp, bool volatilep, const QCString & array, const QCString & value, QCString comment, QCString description, QCString annotation #ifdef ROUNDTRIP , bool roundtrip, QList<UmlItem> & expected_order #endif ) { #ifdef TRACE cout << "RELATION '" << name << "' from '" << cl->Name() << "' to '" << type->Name() << "' array '" << array << "'\n"; #endif if ( #ifdef REVERSE container->from_libp() && #endif (visibility == PrivateVisibility)) { Lex::finish_line(); Lex::clear_comments(); return TRUE; } QCString st = JavaSettings::umlType(genericname); if (st.isEmpty()) st = genericname; UmlClass * cl = container->get_uml(); UmlRelation * rel; #ifdef ROUNDTRIP bool created; if (!roundtrip || ((rel = search_rel(container, name, type, st)) == 0)) { #endif rel = UmlBaseRelation::create(aDirectionalAssociation, cl, type); if (rel == 0) { JavaCatWindow::trace(QCString("<font face=helvetica><b>cannot add relation <i>") + name + "</i> in <i>" + cl->name() + "</i> to <i>" + type->name() + "</i></b></font><br>"); return FALSE; } #ifdef REVERSE # ifndef ROUNDTRIP Statistic::one_relation_more(); # else if (roundtrip) container->set_updated(); created = TRUE; } else created = FALSE; # endif #endif Lex::finish_line(); comment = Lex::get_comments(comment); description = Lex::get_description(description); QCString decl = JavaSettings::relationDecl(array); type_def.replace(0, genericname.length(), "${stereotype}"); decl.replace(decl.find("${type}"), 7, type_def); #ifdef ROUNDTRIP if (roundtrip && !created) { if (rel->visibility() != visibility) { rel->set_Visibility(visibility); container->set_updated(); } if (decl.find("${description}") != -1) { if (nequal(rel->description(), description)) { rel->set_Description(description); container->set_updated(); } } else if (nequal(rel->description(), Lex::simplify_comment(comment))) { rel->set_Description(comment); // comment was set container->set_updated(); } if (rel->isReadOnly() != constp) { rel->set_isReadOnly(constp); container->set_updated(); } if (rel->isJavaTransient() != transientp) { rel->set_isJavaTransient(transientp); container->set_updated(); } if (rel->isVolatile() != volatilep) { rel->set_isVolatile(volatilep); container->set_updated(); } if (rel->isClassMember() != staticp) { rel->set_isClassMember(staticp); container->set_updated(); } if (neq(rel->multiplicity(), array)) { rel->set_Multiplicity(array); container->set_updated(); } if (neq(rel->defaultValue(), value)) { rel->set_DefaultValue(value); container->set_updated(); } if (nequal(rel->javaAnnotations(), annotation)) { rel->set_JavaAnnotations(annotation); container->set_updated(); } if (neq(rel->stereotype(), st) && (rel->stereotype().isEmpty() || (JavaSettings::relationAttributeStereotype(rel->stereotype()) != st))) { rel->set_Stereotype(st); container->set_updated(); } if (neq(rel->javaDecl(), decl)) { rel->set_JavaDecl(decl); container->set_updated(); } // role name is the right one rel->set_usefull(); expected_order.append(rel); } else { #endif rel->set_Visibility(visibility); if (!comment.isEmpty()) rel->set_Description((decl.find("${description}") != -1) ? description : Lex::simplify_comment(comment)); if (constp) rel->set_isReadOnly(TRUE); if (transientp) rel->set_isJavaTransient(TRUE); if (volatilep) rel->set_isVolatile(TRUE); if (staticp) rel->set_isClassMember(TRUE); if (!array.isEmpty()) rel->set_Multiplicity(array); if (! value.isEmpty()) rel->set_DefaultValue(value); if (! annotation.isEmpty()) rel->set_JavaAnnotations(annotation); rel->set_Stereotype(st); rel->set_JavaDecl(decl); rel->set_RoleName(name); #ifdef ROUNDTRIP if (roundtrip) expected_order.append(rel); } #endif return TRUE; }