preparing new release
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / model / ColumnImpl.java
1 package com.quantum.model;
2
3 import com.quantum.util.sql.TypesHelper;
4
5 /**
6  * @author BC
7  */
8 class ColumnImpl implements Column, Comparable {
9
10     private long size;
11     private boolean nullable;
12     private int primaryKeyOrder;
13     private String name;
14     private Entity entity;
15     private int numberOfFractionalDigits;
16     private String typeName;
17     private int type;
18     private int position;
19     private String remarks;
20     
21     ColumnImpl(Entity entity, String name, String typeName, int type, 
22         long size, int numberOfFractionalDigits, boolean nullable, int position,
23         String remarks) {
24            
25         this.entity = entity;
26         this.name = name;
27         this.typeName = typeName;
28         this.type = type;
29         this.size = size;
30         this.numberOfFractionalDigits = numberOfFractionalDigits;
31         this.nullable = nullable;
32         this.position = position;
33         this.remarks = remarks;
34     }
35
36     /**
37      * @see com.quantum.model.Column#getPrimaryKeyOrder()
38      */
39     public int getPrimaryKeyOrder() {
40         return this.primaryKeyOrder;
41     }
42
43     /**
44      * @see com.quantum.model.Column#isPrimaryKey()
45      */
46     public boolean isPrimaryKey() {
47         return getPrimaryKeyOrder() > 0;
48     }
49
50     /**
51      * @see com.quantum.model.Column#getName()
52      */
53     public String getName() {
54         return this.name;
55     }
56
57     /**
58      * @see com.quantum.model.Column#getTypeName()
59      */
60     public String getTypeName() {
61         return this.typeName;
62     }
63
64     /**
65      * @see com.quantum.model.Column#isReal()
66      */
67     public boolean isReal() {
68         return false;
69     }
70
71     /**
72      * @see com.quantum.model.Column#isNullable()
73      */
74     public boolean isNullable() {
75         return this.nullable;
76     }
77
78     /**
79      * @see com.quantum.model.Column#isNumeric()
80      */
81     public boolean isNumeric() {
82         return TypesHelper.isNumeric(this.type);
83     }
84
85     /**
86      * @see com.quantum.model.Column#getType()
87      */
88     public int getType() {
89         return this.type;
90     }
91
92     /**
93      * @see com.quantum.model.Column#getParentEntity()
94      */
95     public Entity getParentEntity() {
96         return this.entity;
97     }
98
99     /**
100      * @see com.quantum.model.Column#getQualifiedTableName()
101      */
102     public String getQualifiedTableName() {
103         return this.entity.getQualifiedName();
104     }
105     /**
106      * @param i
107      */
108     void setPrimaryKeyOrder(int i) {
109         this.primaryKeyOrder = i;
110     }
111
112     /**
113      * @see java.lang.Comparable#compareTo(java.lang.Object)
114      */
115     public int compareTo(Object o) {
116         ColumnImpl that = (ColumnImpl) o;
117         if (this.isPrimaryKey() && that.isPrimaryKey()) {
118             return this.primaryKeyOrder - that.primaryKeyOrder;
119         } else if (this.isPrimaryKey()) {
120             return -1;
121         } else if (that.isPrimaryKey()) {
122             return 1;
123         } else {
124             return this.position - that.position;
125         }
126     }
127     /**
128      * @return
129      */
130     public long getSize() {
131         return size;
132     }
133
134     /**
135      * @return
136      */
137     public int getNumberOfFractionalDigits() {
138         return numberOfFractionalDigits;
139     }
140
141     /**
142      * @return
143      */
144     public String getRemarks() {
145         return this.remarks == null ? "" : this.remarks;
146     }
147
148 }