void UmlClass::import(QTextOStream & f, const QCString & indent) { QCString s; if (!isJavaExternal()) { UmlArtifact * cp = associatedArtifact(); UmlPackage * pack = (UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package(); if ((s = pack->javaPackage()).isEmpty()) return; QCString s2 = name(); UmlItem * p = this; while ((p = p->parent())->kind() == aClass) s2 = p->name() + dot + s2; s += dot + s2; } else if ((s = package()->javaPackage()).isEmpty()) return; else s += dot + name(); if (! UmlArtifact::generated_one()->is_imported(s)) { f << indent << "import " << s << ";\n"; UmlArtifact::generated_one()->imported(s); } }
void UmlClass::generate() { if (! managed) { managed = TRUE; if (!isJavaExternal() && !javaDecl().isEmpty()) { if (associatedArtifact() != 0) associatedArtifact()->generate(); else if ((children().size() != 0) && verbose()) UmlCom::trace(QCString("<hr><font face=helvetica><i> ") + name() + " : </i> does not have associated <i>artifact</i></font><br>"); } } }
void UmlClass::uml2java(bool rec) { if (isJavaExternal()) set_JavaDecl(JavaSettings::externalClassDecl()); else { QCString st = JavaSettings::classStereotype(stereotype()); UmlItem * pack = parent()->parent(); while (pack->kind() != aPackage) pack = pack->parent(); if ((st == "stereotype") || (st == "metaclass") || (pack->stereotype() == "profile")) { set_CppDecl(""); return; } if (st == "enum_pattern") set_JavaDecl(JavaSettings::enumPatternDecl()); else if (st == "enum") set_JavaDecl(JavaSettings::enumDecl()); else if (st == "interface") set_JavaDecl(JavaSettings::interfaceDecl()); else if (st == "@interface") { QCString s = JavaSettings::interfaceDecl(); int index = s.find("interface"); if (index != -1) s.insert(index, '@'); set_JavaDecl(s); } else if (st == "ignored") { set_JavaDecl(""); return; } else set_JavaDecl(JavaSettings::classDecl()); if (rec) { const QVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->uml2java(rec); } if (parent()->kind() == aClassView) // not nested artifact()->set_JavaSource(JavaSettings::sourceContent()); } }
void UmlClass::write(QTextOStream & f) { if (isJavaExternal()) { QCString s = javaDecl().stripWhiteSpace(); int index; if ((index = s.find("${name}")) != -1) s.replace(index, 7, name()); else if ((index = s.find("${Name}")) != -1) s.replace(index, 7, capitalize(name())); else if ((index = s.find("${NAME}")) != -1) s.replace(index, 7, name().upper()); else if ((index = s.find("${nAME}")) != -1) s.replace(index, 7, name().lower()); f << s; } else { UmlClass * toplevel = this; UmlItem * p; QCString s2; while ((p = toplevel->parent())->kind() == aClass) { toplevel = (UmlClass *) p; s2 = dot + p->name() + s2; } UmlArtifact * cp = toplevel->associatedArtifact(); UmlPackage * pack = (UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) toplevel)->package(); if (pack != UmlArtifact::generation_package()) { QCString s = pack->javaPackage(); if (! s.isEmpty() && (s != "java.lang") && (s.left(10) != "java.lang.")) { s += s2; if (JavaSettings::isForcePackagePrefixGeneration() || !UmlArtifact::generated_one()->is_imported(s, name())) f << s << '.'; } } else if (! s2.isEmpty()) f << s2.mid(1) << '.'; f << name(); } }