View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2004/08/12 23:23:19
    6    */
    7   package org.asyrinx.joey.gen.model.java;
    8
    9   import java.util.ArrayList;
    10  import java.util.Iterator;
    11  import java.util.List;
    12
    13  import org.asyrinx.joey.gen.model.Element;
    14
    15  /***
    16   * @author akima
    17   */
    18  public class AppDomain extends Element {
    19
    20      /***
    21       *
    22       */
    23      public AppDomain() {
    24          super();
    25      }
    26
    27      /***
    28       *
    29       */
    30      public AppDomain(String name) {
    31          super(name);
    32      }
    33
    34      /*
    35       * (non-Javadoc)
    36       *
    37       * @see org.asyrinx.joey.gen.model.Element#add(org.asyrinx.joey.gen.model.Element)
    38       */
    39      public void add(Element element) {
    40          if (element instanceof Entity)
    41              classes.add((Entity) element);
    42          else if (element instanceof JavaEnumeration)
    43              enumerations.add((JavaEnumeration) element);
    44          else
    45              super.add(element);
    46      }
    47
    48      private final EntitySet classes = new EntitySet(this);
    49
    50      private final JavaEnumerationSet enumerations = new JavaEnumerationSet(this);
    51
    52      /***
    53       * @return Returns the classes.
    54       */
    55      public EntitySet getClasses() {
    56          return classes;
    57      }
    58
    59      /***
    60       * @return Returns the enumerations.
    61       */
    62      public JavaEnumerationSet getEnumerations() {
    63          return enumerations;
    64      }
    65
    66      /***
    67       * @param property
    68       * @return
    69       */
    70      public List getReferencesContainedAsForeign(Property property) {
    71          final List result = new ArrayList();
    72          for (Iterator i = getClasses().iterator(); i.hasNext();) {
    73              final Entity javaClass = (Entity) i.next();
    74              for (Iterator j = javaClass.getReferences().iterator(); j.hasNext();) {
    75                  final Reference reference = (Reference) j.next();
    76                  if (reference.containsAsForeign(property))
    77                      result.add(reference);
    78              }
    79          }
    80          return result;
    81      }
    82
    83      /***
    84       * @param class1
    85       * @return
    86       */
    87      public List getReferencesContainedAsForeign(Entity javaClass) {
    88          final List result = new ArrayList();
    89          for (Iterator i = this.getClasses().iterator(); i.hasNext();) {
    90              final Entity class1 = (Entity) i.next();
    91              class1.findReferencesContainedAsForeign(javaClass, result);
    92          }
    93          return result;
    94      }
    95
    96      /***
    97       * @param parent
    98       * @return
    99       */
    100     public List getReferencesContainedAsLocal(Entity javaClass) {
    101         final List result = new ArrayList();
    102         for (Iterator i = this.getClasses().iterator(); i.hasNext();) {
    103             final Entity class1 = (Entity) i.next();
    104             class1.findReferencesContainedAsLocal(javaClass, result);
    105         }
    106         return result;
    107     }
    108
    109     public List findReferences(Entity local, Entity foreign) {
    110         final List result = new ArrayList();
    111         for (Iterator i = getReferencesContainedAsLocal(local).iterator(); i.hasNext();) {
    112             final Reference reference = (Reference) i.next();
    113             if (reference.getReferenceClass() == foreign)
    114                 result.add(reference);
    115         }
    116         return result;
    117     }
    118
    119 }