QString CPPCodeClassField::getInitialValue() { if (parentIsAttribute()) { UMLAttribute * at = dynamic_cast<UMLAttribute*>( getParentObject() ); if (at) { return fixInitialStringDeclValue(at->getInitialValue(), getTypeName()); } else { kError() << "CPPCodeClassField::getInitialValue: parent object is not a UMLAttribute" << endl; return ""; } } else { if(fieldIsSingleValue()) { // FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1, // then we can just return 'empty' string (minor problem). return ""; } else { return " new "+getListFieldClassName()+"( )"; } } }
void XMLSchemaWriter::writeAttributeDecl(UMLAttribute *attrib, QTextStream &XMLschema ) { QString documentation = attrib->getDoc(); QString typeName = fixTypeName(attrib->getTypeName()); bool isStatic = attrib->getStatic(); QString initialValue = fixInitialStringDeclValue(attrib->getInitialValue(), typeName); if(!documentation.isEmpty()) writeComment(documentation, XMLschema); XMLschema<<getIndent()<<"<"<<makeSchemaTag("attribute") <<" name=\""<<cleanName(attrib->getName())<<"\"" <<" type=\""<<typeName<<"\""; // default value? if(!initialValue.isEmpty()) { // IF its static, then we use "fixed", otherwise, we use "default" decl. // For the default decl, we _must_ use "optional" decl if(isStatic) XMLschema<<" use=\"required\" fixed=\""<<initialValue<<"\""; else XMLschema<<" use=\"optional\" default=\""<<initialValue<<"\""; } // finish decl XMLschema<<"/>"<<m_endl; }
QString JavaCodeClassField::getInitialValue() { if (parentIsAttribute()) { UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject()); if (at) { return fixInitialStringDeclValue(at->getInitialValue(), getTypeName()); } else { uError() << "parent object is not a UMLAttribute"; return QString(); } } else { if(fieldIsSingleValue()) { // FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1, // then we can just return 'empty' string (minor problem). return QString(); } else { return QLatin1String(" new ") + JavaCodeGenerator::getListFieldClassName() + QLatin1String("()"); } } }