umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
JavaWriter Class Reference

#include <javawriter.h>

Inheritance diagram for JavaWriter:
Collaboration diagram for JavaWriter:

Public Member Functions

 JavaWriter ()
 
virtual ~JavaWriter ()
 
virtual void writeClass (UMLClassifier *c)
 
virtual Uml::ProgrammingLanguage::Enum language () const
 
QStringList defaultDatatypes () const
 
- Public Member Functions inherited from SimpleCodeGenerator
 SimpleCodeGenerator (bool createDirHierarchyForPackages=true)
 
virtual ~SimpleCodeGenerator ()
 
void writeCodeToFile (UMLClassifierList &concepts)
 
void writeCodeToFile ()
 
- Public Member Functions inherited from CodeGenerator
 CodeGenerator ()
 
virtual ~CodeGenerator ()
 
bool addCodeDocument (CodeDocument *add_object)
 
bool removeCodeDocument (CodeDocument *remove_object)
 
CodeDocumentListgetCodeDocumentList ()
 
QString getUniqueID (CodeDocument *codeDoc)
 
virtual void saveToXMI (QXmlStreamWriter &writer)
 
CodeDocumentfindCodeDocumentByID (const QString &id)
 
void setIncludeHeadings (bool i)
 
bool includeHeadings () const
 
void setHeadingFileDir (const QString &)
 
QString headingFileDir () const
 
void setForceDoc (bool f)
 
bool forceDoc () const
 
void setForceSections (bool f)
 
bool forceSections () const
 
virtual QString getHeadingFile (const QString &file)
 
QString findFileName (CodeDocument *codeDocument)
 
virtual void loadFromXMI (QDomElement &element)
 
CodeDocumentfindCodeDocumentByClassifier (UMLClassifier *classifier)
 
virtual bool isReservedKeyword (const QString &keyword)
 
virtual QStringList reservedKeywords () const
 
virtual void createDefaultStereotypes ()
 

Private Member Functions

void writeClassDecl (UMLClassifier *c, QTextStream &java)
 
void writeConstructor (UMLClassifier *c, QTextStream &java)
 
void getSuperImplementedOperations (UMLClassifier *c, UMLOperationList &yetImplementedOpList, UMLOperationList &toBeImplementedOpList, bool noClassInPath=true)
 
void getInterfacesOperationsToBeImplemented (UMLClassifier *c, UMLOperationList &opl)
 
void writeOperations (UMLClassifier *c, QTextStream &j)
 
void writeOperations (UMLOperationList &oplist, QTextStream &j)
 
void writeAttributeDecls (UMLAttributeList &atpub, UMLAttributeList &atprot, UMLAttributeList &atpriv, QTextStream &java)
 
void writeAssociationDecls (UMLAssociationList associations, Uml::ID::Type id, QTextStream &java)
 
void writeAssociationRoleDecl (QString fieldClassName, QString roleName, QString multi, QString doc, Uml::Visibility::Enum visib, QTextStream &java)
 
void writeAttributeMethods (UMLAttributeList &atpub, Uml::Visibility::Enum visibility, QTextStream &java)
 
void writeAssociationMethods (UMLAssociationList associations, UMLClassifier *thisClass, QTextStream &java)
 
void writeAssociationRoleMethod (QString fieldClassName, QString roleName, QString multi, QString description, Uml::Visibility::Enum visib, Uml::Changeability::Enum change, QTextStream &java)
 
void writeSingleAttributeAccessorMethods (QString fieldClassName, QString fieldVarName, QString fieldName, QString description, Uml::Visibility::Enum visibility, Uml::Changeability::Enum change, bool isFinal, QTextStream &java)
 
void writeVectorAttributeAccessorMethods (QString fieldClassName, QString fieldVarName, QString fieldName, QString description, Uml::Visibility::Enum visibility, Uml::Changeability::Enum change, QTextStream &java)
 
void writeComment (const QString &text, const QString &indent, QTextStream &java, bool javaDocStyle=false)
 
void writeDocumentation (QString header, QString body, QString end, QString indent, QTextStream &java)
 
QString getUMLObjectName (UMLObject *obj)
 
QString fixTypeName (const QString &string)
 
QString fixInitialStringDeclValue (const QString &val, const QString &type)
 
void writeBlankLine (QTextStream &java)
 

Static Private Member Functions

static bool compareJavaMethod (UMLOperation *op1, UMLOperation *op2)
 
static bool javaMethodInList (UMLOperation *umlOp, UMLOperationList &opl)
 

Private Attributes

QString m_startline
 a
, used at the end of each line More...
 
bool m_isInterface
 whether or not this concept is an interface More...
 

Additional Inherited Members

- Public Types inherited from CodeGenerator
enum  GenerationState { Generated , Failed , Skipped }
 
- Public Slots inherited from SimpleCodeGenerator
virtual void syncCodeToDocument ()
 
- Public Slots inherited from CodeGenerator
virtual void syncCodeToDocument ()
 
- Signals inherited from CodeGenerator
void codeGenerated (UMLClassifier *concept, bool generated)
 
void codeGenerated (UMLClassifier *concept, CodeGenerator::GenerationState result)
 
void showGeneratedFile (const QString &filename)
 
- Static Public Member Functions inherited from CodeGenerator
static QString cleanName (const QString &name)
 
static QString formatDoc (const QString &text, const QString &linePrefix=QLatin1String(" *"), int lineWidth=80)
 
static QString formatSourceCode (const QString &code, const QString &indentation)
 
static void findObjectsRelated (UMLClassifier *c, UMLPackageList &cList)
 
- Protected Member Functions inherited from SimpleCodeGenerator
QString findFileName (UMLPackage *concept, const QString &ext)
 
QString overwritableName (UMLPackage *concept, const QString &name, const QString &ext)
 
bool hasDefaultValueAttr (UMLClassifier *c)
 
bool hasAbstractOps (UMLClassifier *c)
 
QString indent ()
 
virtual void initFromParentDocument ()
 
- Protected Member Functions inherited from CodeGenerator
QString overwritableName (const QString &name, const QString &extension)
 
bool openFile (QFile &file, const QString &name)
 
void writeListedCodeDocsToFile (CodeDocumentList *docs)
 
virtual void finalizeRun ()
 
- Protected Attributes inherited from SimpleCodeGenerator
QString className_
 
QString fileName_
 
QMap< UMLPackage *, QString > m_fileMap
 
bool m_createDirHierarchyForPackages
 
QString m_indentation
 
int m_indentLevel
 
QString m_endl
 
- Protected Attributes inherited from CodeGenerator
QHash< QString, CodeDocument * > m_codeDocumentDictionary
 
bool m_applyToAllRemaining
 
UMLDocm_document
 

Detailed Description

Class JavaWriter is a code generator for UMLClassifier objects. Create an instance of this class, and feed it a UMLClassifier when calling writeClass and it will generate a java source file for that concept. This is the "old" code generator that does not support code editing in the Modeller but uses significantly less file space because the source code is not replicated in the XMI file.

Constructor & Destructor Documentation

◆ JavaWriter()

JavaWriter::JavaWriter ( )

Constructor, initialises a couple of variables.

◆ ~JavaWriter()

JavaWriter::~JavaWriter ( )
virtual

Destructor, empty.

Member Function Documentation

◆ compareJavaMethod()

bool JavaWriter::compareJavaMethod ( UMLOperation op1,
UMLOperation op2 
)
staticprivate

Return true if the two operations have the same name and the same parameters.

Parameters
op1first operation to be compared
op2second operation to be compared
Here is the call graph for this function:

◆ defaultDatatypes()

QStringList JavaWriter::defaultDatatypes ( ) const
virtual

Overrides method from class CodeGenerator.

Returns
the list of default datatypes

Reimplemented from CodeGenerator.

◆ fixInitialStringDeclValue()

QString JavaWriter::fixInitialStringDeclValue ( const QString &  val,
const QString &  type 
)
private

Check that initial values of strings have quotes around them.

◆ fixTypeName()

QString JavaWriter::fixTypeName ( const QString &  string)
private

Replaces `string' with `String' and `bool' with `boolean'. IF the type is "string" we need to declare it as the Java Object "String" (there is no string primitive in Java). Same thing again for "bool" to "boolean".

◆ getInterfacesOperationsToBeImplemented()

void JavaWriter::getInterfacesOperationsToBeImplemented ( UMLClassifier c,
UMLOperationList opList 
)
private

Get all operations which a given class inherit from all its super interfaces and that should be implemented.

Parameters
cthe class for which we are generating code
opListthe list of operations used to append the operations
Here is the call graph for this function:

◆ getSuperImplementedOperations()

void JavaWriter::getSuperImplementedOperations ( UMLClassifier c,
UMLOperationList yetImplementedOpList,
UMLOperationList toBeImplementedOpList,
bool  noClassInPath = true 
)
private

Get all operations which a given class inherit from all its super interfaces and get all operations which this given class inherit from all its super classes.

Parameters
cthe class for which we are generating code
yetImplementedOpListthe list of yet implemented operations
toBeImplementedOpListthe list of to be implemented operations
noClassInPathtells if there is a class between the base class and the current interface
Here is the call graph for this function:

◆ getUMLObjectName()

QString JavaWriter::getUMLObjectName ( UMLObject obj)
private

Returns the name of the given object (if it exists).

Here is the call graph for this function:

◆ javaMethodInList()

bool JavaWriter::javaMethodInList ( UMLOperation umlOp,
UMLOperationList opl 
)
staticprivate

Return true if the operation is in the list.

Parameters
umlOpoperation to be searched
opllist of operations
Here is the call graph for this function:

◆ language()

Uml::ProgrammingLanguage::Enum JavaWriter::language ( ) const
virtual

Returns "Java".

Returns
the programming language identifier

Implements CodeGenerator.

◆ writeAssociationDecls()

void JavaWriter::writeAssociationDecls ( UMLAssociationList  associations,
Uml::ID::Type  id,
QTextStream &  java 
)
private

Searches a list of associations for appropriate ones to write out as attributes.

Here is the call graph for this function:

◆ writeAssociationMethods()

void JavaWriter::writeAssociationMethods ( UMLAssociationList  associations,
UMLClassifier thisClass,
QTextStream &  java 
)
private

Calls writeAssociationRoleMethod() on each of the associations in the given list.

Here is the call graph for this function:

◆ writeAssociationRoleDecl()

void JavaWriter::writeAssociationRoleDecl ( QString  fieldClassName,
QString  roleName,
QString  multi,
QString  doc,
Uml::Visibility::Enum  visib,
QTextStream &  java 
)
private

Writes out an association as an attribute using Vector.

Here is the call graph for this function:

◆ writeAssociationRoleMethod()

void JavaWriter::writeAssociationRoleMethod ( QString  fieldClassName,
QString  roleName,
QString  multi,
QString  description,
Uml::Visibility::Enum  visib,
Uml::Changeability::Enum  change,
QTextStream &  java 
)
private

Calls writeSingleAttributeAccessorMethods() or writeVectorAttributeAccessorMethods() on the association role.

Here is the call graph for this function:

◆ writeAttributeDecls()

void JavaWriter::writeAttributeDecls ( UMLAttributeList atpub,
UMLAttributeList atprot,
UMLAttributeList atpriv,
QTextStream &  java 
)
private

Writes the Attribute declarations.

Parameters
atpublist of public attributes
atprotlist of protected attributes
atprivlist of private attributes
javatext stream
Here is the call graph for this function:

◆ writeAttributeMethods()

void JavaWriter::writeAttributeMethods ( UMLAttributeList atpub,
Uml::Visibility::Enum  visibility,
QTextStream &  java 
)
private

Calls writeSingleAttributeAccessorMethods() on each of the attributes in atpub.

Here is the call graph for this function:

◆ writeBlankLine()

void JavaWriter::writeBlankLine ( QTextStream &  java)
private

Write a blank line. Note: Methods like this _shouldn't_ be needed IF we properly did things thruought the code.

◆ writeClass()

void JavaWriter::writeClass ( UMLClassifier c)
virtual

Call this method to generate java code for a UMLClassifier.

Parameters
cthe class to generate code for

Implements SimpleCodeGenerator.

Here is the call graph for this function:

◆ writeClassDecl()

void JavaWriter::writeClassDecl ( UMLClassifier c,
QTextStream &  java 
)
private

Writes class's documentation then the class header "public abstract class Foo extents {".

Here is the call graph for this function:

◆ writeComment()

void JavaWriter::writeComment ( const QString &  comment,
const QString &  myIndent,
QTextStream &  java,
bool  javaDocStyle = false 
)
private

Writes a // style comment.

Here is the call graph for this function:

◆ writeConstructor()

void JavaWriter::writeConstructor ( UMLClassifier c,
QTextStream &  java 
)
private

Writes the comment and class constructor.

Here is the call graph for this function:

◆ writeDocumentation()

void JavaWriter::writeDocumentation ( QString  header,
QString  body,
QString  end,
QString  indent,
QTextStream &  java 
)
private

Writes a documentation comment.

Here is the call graph for this function:

◆ writeOperations() [1/2]

void JavaWriter::writeOperations ( UMLClassifier c,
QTextStream &  java 
)
private

Write all operations for a given class.

Parameters
cthe class for which we are generating code
javathe stream associated with the output file
Here is the call graph for this function:

◆ writeOperations() [2/2]

void JavaWriter::writeOperations ( UMLOperationList oplist,
QTextStream &  java 
)
private

Write a list of operations for a given class.

Parameters
oplistthe list of operations you want to write
javathe stream associated with the output file
Here is the call graph for this function:

◆ writeSingleAttributeAccessorMethods()

void JavaWriter::writeSingleAttributeAccessorMethods ( QString  fieldClassName,
QString  fieldVarName,
QString  fieldName,
QString  description,
Uml::Visibility::Enum  visibility,
Uml::Changeability::Enum  change,
bool  isFinal,
QTextStream &  java 
)
private

Writes getFoo() and setFoo() accessor methods for the attribute.

Here is the call graph for this function:

◆ writeVectorAttributeAccessorMethods()

void JavaWriter::writeVectorAttributeAccessorMethods ( QString  fieldClassName,
QString  fieldVarName,
QString  fieldName,
QString  description,
Uml::Visibility::Enum  visibility,
Uml::Changeability::Enum  changeType,
QTextStream &  java 
)
private

Writes addFoo() and removeFoo() accessor methods for the Vector attribute.

Here is the call graph for this function:

Member Data Documentation

◆ m_isInterface

bool JavaWriter::m_isInterface
private

whether or not this concept is an interface

◆ m_startline

QString JavaWriter::m_startline
private

a
, used at the end of each line


The documentation for this class was generated from the following files: