WrapperStr UmlOperation::compute_name() { WrapperStr get_set_spec = javaNameSpec(); if (! get_set_spec.isEmpty()) { UmlClassMember * it; if ((it = getOf()) == 0) it = setOf(); int index; WrapperStr s = (it->kind() == aRelation) ? ((UmlRelation *) it)->roleName() : it->name(); if ((index = get_set_spec.find("${name}")) != -1) get_set_spec.replace(index, 7, s); else if ((index = get_set_spec.find("${Name}")) != -1) get_set_spec.replace(index, 7, capitalize(s)); else if ((index = s.find("${NAME}")) != -1) get_set_spec.replace(index, 7, s.upper()); else if ((index = s.find("${nAME}")) != -1) get_set_spec.replace(index, 7, s.lower()); return get_set_spec; } else return name(); }
void UmlOperation::gen_java_decl(QByteArray s, bool descr) { const char * p = bypass_comment(s); const QList<UmlParameter> & pa = params(); unsigned npa = pa.count(); unsigned rank; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${final}", 8)) { p += 8; if (isJavaFinal()) fw.write("final "); } else if (!strncmp(p, "${visibility}", 13)) { p += 13; UmlItem::write(visibility(), javaLanguage); fw.write(' '); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract()) fw.write("abstract "); } else if (!strncmp(p, "${synchronized}", 15)) { p += 15; if (isJavaSynchronized()) fw.write("synchronized "); } else if (!strncmp(p, "${type}", 7)) { p += 7; write(returnType(), javaLanguage); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(compute_name(javaNameSpec())); } else if (!strncmp(p, "${(}", 4)) { p += 4; fw.write('('); } else if (!strncmp(p, "${)}", 4)) { p += 4; fw.write(')'); } else if (!strncmp(p, "${throws}", 9)) { p += 9; const char * sep = " throws "; const QList<UmlTypeSpec> e = exceptions(); unsigned n = e.count(); for (unsigned index2 = 0; index2 != n; index2 += 1) { fw.write(sep); sep = ", "; write(e[index2], javaLanguage); } } else if (!strncmp(p, "${staticnl}", 11)) break; else if (sscanf(p, "${t%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) write(pa[rank].type, javaLanguage); else fw.write("???"); } else if (sscanf(p, "${p%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) writeq(pa[rank].name); else fw.write("???"); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; // get/set relation with multiplicity > 1 UmlClassMember * m = getOf(); if ((m != 0) || ((m = setOf()) != 0)) writeq(JavaSettings::relationAttributeStereotype(m->stereotype())); } else if (!strncmp(p, "${association}", 14)) { p += 14; // get/set relation with multiplicity > 1 UmlClassMember * m = getOf(); if (((m != 0) || ((m = setOf()) != 0)) && (m->kind() == aRelation)) write(((UmlRelation *) m)->association(), javaLanguage); } 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++); } }