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/11/07 21:25:09
    6    */
    7   package org.asyrinx.joey.gen.model.java;
    8
    9   import java.util.Iterator;
    10
    11  import org.asyrinx.joey.gen.model.Element;
    12  import org.asyrinx.joey.gen.model.ElementSet;
    13
    14  /***
    15   * @author takeshi
    16   */
    17  public class EntityKeySet extends ElementSet {
    18
    19      /***
    20       * @param parent
    21       */
    22      public EntityKeySet(Element parent) {
    23          super(parent);
    24      }
    25
    26      /*
    27       * (non-Javadoc)
    28       *
    29       * @see org.asyrinx.joey.gen.model.Element#isEntity()
    30       */
    31      public boolean isEntity() {
    32          return false;
    33      }
    34
    35      public void add(EntityKey key) {
    36          super.add(key);
    37      }
    38
    39      /*
    40       * (non-Javadoc)
    41       *
    42       * @see org.asyrinx.joey.gen.model.ElementSet#contains(org.asyrinx.joey.gen.model.Element)
    43       */
    44      public boolean contains(EntityKey key) {
    45          return super.contains(key);
    46      }
    47
    48      /*
    49       * (non-Javadoc)
    50       *
    51       * @see org.asyrinx.joey.gen.model.ElementSet#getElement(int)
    52       */
    53      public EntityKey getKey(int index) {
    54          return (EntityKey) super.getElement(index);
    55      }
    56
    57      /*
    58       * (non-Javadoc)
    59       *
    60       * @see org.asyrinx.joey.gen.model.ElementSet#get(java.lang.String)
    61       */
    62      public EntityKey getKey(String name) {
    63          return (EntityKey) super.getElement(name);
    64      }
    65
    66      /*
    67       * (non-Javadoc)
    68       *
    69       * @see org.asyrinx.joey.gen.model.ElementSet#remove(java.lang.String)
    70       */
    71      public EntityKey removeKey(String name) {
    72          return (EntityKey) super.removeElement(name);
    73      }
    74
    75      /***
    76       * @return
    77       */
    78      public EntityKey getPrimaryKey() {
    79          for (Iterator i = this.iterator(); i.hasNext();) {
    80              final EntityKey key = (EntityKey) i.next();
    81              if (key.isPrimaryKey())
    82                  return key;
    83          }
    84          return null;
    85      }
    86  }