PyutClass.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » PyutClass.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

__version__ = "$Revision: 1.7 $"
__author__ = "EI5, eivd, Group Burgbacher - Waelti"
__date__ = "2001-12-05"

from PyutLinkedObject import *
from types import *
from PyutStereotype import *
#import wx

class PyutClass(PyutLinkedObject):
    """
    A standard class representation.

    A PyutClass represents a UML class in Pyut. It manages its:
        - object data fields (`PyutField`)
        - methods (`PyutMethod`)
        - fathers (`PyutClass`)(classes from which this one inherits)
        - stereotype (`PyutStereotype`)
        - a description (`string`)

    Example::
        myClass = PyutClass("Foo") # this will create a `Foo` class
        myClass.setDescription("Example class")
        fields = myClass.getFields() # this is the original fields []
        fields.append(PyutField("bar", "int"))

    :version: $Revision: 1.7 $
    :author: Laurent Burgbacher
    :contact: lb@alawa.ch
    """

    def __init__(self, name=""):
        """
        Constructor.

        @param string name : class name
        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        PyutLinkedObject.__init__(self, name)
        self._fields = []
        self._methods = []
        self._description = ""
        self._stereotype = None

        # Display properties
        self._showStereotype = True
        self._showMethods = True
        self._showFields = True

    #>------------------------------------------------------------------------

    def __getstate__(self):
        """
        For deepcopy operations, tells which fields to avoid copying.
        Deepcopy must not copy the links to other classes, or it would result
        in copying all the diagram.

        @since 1.5
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        dict = self.__dict__.copy()
        dict["_fathers"]    = []
        return dict

    #>------------------------------------------------------------------------

    def __str__(self):
        """
        String representation.

        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        return _("Class : %s") % (self.getName())

    #>------------------------------------------------------------------------

    def setDescription(self, description):
        """
        Description field.
        This description may be inserted just after the class declaration when
        using python code generation, for example.

        @param String description : description string
        @since 1.15
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        self._description = description

    #>------------------------------------------------------------------------

    def getDescription(self):
        """
        Returns the description field.
        This description may be inserted just after the class declaration when
        using python code generation, for example.

        @return String : Description string
        @since 1.15
        @author Philippe Waelti <pwaelti@eivd.ch>
        """
        return self._description

    #>------------------------------------------------------------------------

    def getFields(self):
        """
        Return a list of the fields. 
        This is not a copy, but the original one. Any change made to it is
        directly made on the class.

        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        return self._fields

    #>------------------------------------------------------------------------

    def setFields(self, fields):
        """
        Replace the actual fields by those given in the list.
        The methods passed are not copied, but used directly.

        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        self._fields = fields

    #>------------------------------------------------------------------------

    def addField(self, field):
        """
        Add a field
        @author C.Dutoit
        """
        self._fields.append(field)

    #>------------------------------------------------------------------------

    def getMethods(self):
        """
        Return a list of the methods. 
        This is not a copy, but the original one. Any change made to it is
        directly made on the interface.

        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        return self._methods

    #>------------------------------------------------------------------------

    def setMethods(self, methods):
        """
        Replace the actual methods by those given in the list.
        The methods passed are not copied, but used directly.

        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        self._methods = methods

    #>------------------------------------------------------------------------

    def getStereotype(self):
        """
        Return the stereotype used, or None if there's no stereotype.

        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        return self._stereotype

    #>------------------------------------------------------------------------

    def setStereotype(self, stereotype):
        """
        Replace the actual stereotype by the one given.

        @param String or Unicode or PyutStereotype stereotype
        @since 1.0
        @author Laurent Burgbacher <lb@alawa.ch>
        """
        if type(stereotype) == StringType or type(stereotype) == UnicodeType:
            stereotype = getPyutStereotype(stereotype)
        self._stereotype = stereotype


    #>------------------------------------------------------------------------
    
    def getShowStereotype(self):
        """
        Return True if we must display the stereotype

        @return boolean indicating if we must display the stereotype
        @since 1.1.1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        return self._showStereotype

    #>------------------------------------------------------------------------
    
    def setShowStereotype(self, value):
        """
        Define the showStereotype property

        @param value : boolean indicating if we must display the stereotype
        @since 1.1.1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        self._showStereotype = value

    #>------------------------------------------------------------------------
    
    def getShowMethods(self):
        """
        Return True if we must display the methods

        @return boolean indicating if we must display the methods
        @since 1.1.1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        return self._showMethods

    #>------------------------------------------------------------------------
    
    def setShowMethods(self, value):
        """
        Define the showMethods property

        @param value : boolean indicating if we must display the methods
        @since 1.1.1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        self._showMethods = value

    #>------------------------------------------------------------------------
    
    def getShowFields(self):
        """
        Return True if we must display the fields

        @return boolean indicating if we must display the fields
        @since 1.1.1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        return self._showFields

    #>------------------------------------------------------------------------
    
    def setShowFields(self, value):
        """
        Define the showFields property

        @param value : boolean indicating if we must display the fields
        @since 1.1.1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        self._showFields = value

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.