rubycodeclassfield.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "rubycodeclassfield.h"
00022
00023
00024 #include <qregexp.h>
00025 #include <kdebug.h>
00026
00027
00028 #include "rubycodecomment.h"
00029 #include "rubycodegenerator.h"
00030
00031 #include "../attribute.h"
00032 #include "../umlobject.h"
00033 #include "../umlrole.h"
00034 #include "../uml.h"
00035
00036 #include "rubyclassifiercodedocument.h"
00037
00038
00039
00040
00041 RubyCodeClassField::RubyCodeClassField (ClassifierCodeDocument * parentDoc, UMLRole * role)
00042 : CodeClassField(parentDoc, role)
00043 {
00044
00045 }
00046
00047 RubyCodeClassField::RubyCodeClassField (ClassifierCodeDocument * parentDoc, UMLAttribute * attrib)
00048 : CodeClassField(parentDoc, attrib)
00049 {
00050
00051 }
00052
00053 RubyCodeClassField::~RubyCodeClassField ( ) { }
00054
00055
00056
00057
00058
00059
00060
00061
00062 QString RubyCodeClassField::getFieldName() {
00063 if (parentIsAttribute())
00064 {
00065 UMLAttribute * at = (UMLAttribute*) getParentObject();
00066 return cleanName(at->getName());
00067 }
00068 else
00069 {
00070 UMLRole * role = (UMLRole*) getParentObject();
00071 QString roleName = role->getName();
00072 if(fieldIsSingleValue()) {
00073 return roleName.replace(0, 1, roleName.left(1).lower());
00074 } else {
00075 return roleName.lower() + "Array";
00076 }
00077 }
00078 }
00079
00080
00081 QString RubyCodeClassField::getInitialValue() {
00082
00083 if (parentIsAttribute())
00084 {
00085 UMLAttribute * at = dynamic_cast<UMLAttribute*>( getParentObject() );
00086 if (at) {
00087 return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
00088 } else {
00089 kError() << "RubyodeClassField::getInitialValue: parent object is not a UMLAttribute"
00090 << endl;
00091 return "";
00092 }
00093 return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
00094 }
00095 else
00096 {
00097 if(fieldIsSingleValue()) {
00098
00099
00100 return QString("");
00101 } else {
00102 return RubyCodeGenerator::getListFieldClassName()+".new()";
00103 }
00104 }
00105
00106 }
00107
00108 QString RubyCodeClassField::getTypeName ( )
00109 {
00110 return RubyCodeGenerator::cppToRubyType(CodeClassField::getTypeName());
00111 }
00112
00113 #include "rubycodeclassfield.moc"
This file is part of the documentation for umbrello Version 3.1.0.