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