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:24:33
6    */
7   package org.asyrinx.joey.gen.model.java;
8   
9   import org.asyrinx.joey.gen.model.ElementSet;
10  
11  /***
12   * @author takeshi
13   */
14  public class EntityKey extends ElementSet {
15  
16      /***
17       * @param parent
18       */
19      public EntityKey(Entity parent) {
20          super(parent);
21      }
22  
23      /***
24       * @param parent
25       * @param name
26       */
27      public EntityKey(Entity parent, String name) {
28          super(parent, name);
29      }
30  
31      public Entity getParent() {
32          return (Entity) super.getParentElement();
33      }
34  
35      private EntityKeyType keyType = EntityKeyType.INDEX;
36  
37      /*
38       * (non-Javadoc)
39       * 
40       * @see org.asyrinx.joey.gen.model.ElementSet#isEntity()
41       */
42      public boolean isEntity() {
43          return true;
44      }
45  
46      public void add(EntityKeyEntry entry) {
47          super.add(entry);
48      }
49  
50      /*
51       * (non-Javadoc)
52       * 
53       * @see org.asyrinx.joey.gen.model.ElementSet#contains(org.asyrinx.joey.gen.model.Element)
54       */
55      public boolean contains(EntityKeyEntry entry) {
56          return super.contains(entry);
57      }
58  
59      /*
60       * (non-Javadoc)
61       * 
62       * @see org.asyrinx.joey.gen.model.ElementSet#getElement(int)
63       */
64      public EntityKeyEntry getEntry(int index) {
65          return (EntityKeyEntry) super.getElement(index);
66      }
67  
68      /*
69       * (non-Javadoc)
70       * 
71       * @see org.asyrinx.joey.gen.model.ElementSet#get(java.lang.String)
72       */
73      public EntityKeyEntry getEntry(String name) {
74          return (EntityKeyEntry) super.getElement(name);
75      }
76  
77      /*
78       * (non-Javadoc)
79       * 
80       * @see org.asyrinx.joey.gen.model.ElementSet#remove(java.lang.String)
81       */
82      public EntityKeyEntry removeEntry(String name) {
83          return (EntityKeyEntry) super.removeElement(name);
84      }
85  
86      /***
87       * @return Returns the primaryKey.
88       */
89      public boolean isPrimaryKey() {
90          return getKeyType() == EntityKeyType.PK;
91      }
92  
93      public boolean isUniqueKey() {
94          return getKeyType() == EntityKeyType.UNIQUE;
95      }
96  
97      public EntityKeyType getKeyType() {
98          return keyType;
99      }
100 
101     public void setKeyType(EntityKeyType keyType) {
102         this.keyType = keyType;
103     }
104 }