IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Eclipse Java Discussion :

emf : containment="true"


Sujet :

Eclipse Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 42
    Par défaut emf : containment="true"
    salut,
    je comprends pas à quoi sert la propriété containment ???

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    In the UML model above, the links with black diamonds on them are containment 
    relations. 
    For example, an Individual can be contained either by a Family or by a 
    FamilyTree. 
    An object can only have one container. For example, the relations between 
    Family and Individual defined in the previous section are not containment
     relations - because people can be married more than once (even if generally 
    not at the same time). 
    When instances of this model are created using the editor generated by EMF,
     there will be a single top-level FamilyTree object and all the other objects 
    in the model will be contained by it, directly or indirectly. The model 
    cannot be saved correctly if there are objects which have no container. 
     
    Add the following methods to FamilyTree to define its containment relations: 
     
         /**
          * Return a list of contained families
       * @model type="Family" containment="true"
          **/
         java.util.List getFamilies();
     
          /**
           * Return a list of contained individuals
           * @model type="Individual" containment="true"
           **/
          java.util.List getIndividuals();
     
    Unlike the simple references defined in the previous section, these methods 
    return Lists - thats because a FamilyTree can contain multiple Families and
     Individuals. The return type must be java.util.List or 
    org.eclipse.emf.common.util.EList so that EMF recognizes that 
    this is meant to be multi-valued. Notice the @model tag  declares the type of
     object that can appear in the List. In addition, the flag containment="true" 
    indicates that this is a containment relation.
    merci

  2. #2
    Membre chevronné Avatar de Jean-Philippe Shields
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    278
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Canada

    Informations forums :
    Inscription : Novembre 2005
    Messages : 278
    Par défaut
    J'essaie une réponse.

    Je crois que le containment est le fait de choisir quel container va englober les instances multiples 1..* de tes classes. Le containment que tu donnes dans ton exemple est java.util.List. Tu pourrais aussi bien utiliser les Vector ou les ArrayList.

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo