1 19 package org.openharmonise.commons.dsi.ddl; 20 21 28 public class ColumnDefinition { 29 30 33 static public int DATE = 0; 34 35 38 static public int TEXT = 1; 39 40 43 static public int NUMBER = 2; 44 45 48 static public int LONG_TEXT = 3; 49 50 53 static public int BOOLEAN = 4; 54 55 58 private String m_sColumnName = null; 59 60 63 private int m_nDataType = 1; 64 65 68 Object m_default = null; 69 70 73 boolean m_bAllowNull = false; 74 75 78 79 boolean m_bIsUnique = false; 80 81 84 boolean m_bIsPrimaryKey = false; 85 86 89 String m_sForeignKeyRef = null; 90 91 98 public ColumnDefinition(String sColName, int nDataType) { 99 m_sColumnName = sColName; 100 m_nDataType = nDataType; 101 } 102 103 111 public ColumnDefinition(String sColName, int nDataType,boolean bAllowNull) { 112 this(sColName,nDataType); 113 m_bAllowNull = bAllowNull; 114 } 115 116 123 public ColumnDefinition(String sColName, boolean bIsPrimaryKey, int nDataType) { 124 this(sColName,nDataType); 125 m_bIsPrimaryKey = bIsPrimaryKey; 126 } 127 128 136 public ColumnDefinition(String sColName, boolean bIsPrimaryKey, int nDataType, boolean bAllowNull) { 137 this(sColName,bIsPrimaryKey,nDataType); 138 m_bAllowNull = bAllowNull; 139 } 140 141 148 public ColumnDefinition(String sColName, int nDataType, Object defaultVal) { 149 this(sColName,nDataType); 150 m_default = defaultVal; 151 } 152 153 161 public ColumnDefinition(String sColName, boolean bIsPrimaryKey, int nDataType, Object defaultVal) { 162 this(sColName,nDataType,defaultVal); 163 m_bIsPrimaryKey = bIsPrimaryKey; 164 m_bIsUnique = true; 165 } 166 167 172 public String getName() { 173 return m_sColumnName; 174 } 175 176 181 public int getDataType() { 182 return m_nDataType; 183 } 184 185 190 public boolean isPrimaryKey() { 191 return m_bIsPrimaryKey; 192 } 193 194 199 public boolean isUnique() { 200 return m_bIsUnique; 201 } 202 203 208 public void setIsUnique(boolean bIsUnique) { 209 m_bIsUnique = bIsUnique; 210 } 211 212 217 public boolean allowNulls() { 218 return m_bAllowNull; 219 } 220 221 226 public Object getDefault() { 227 return m_default; 228 } 229 230 235 public boolean isForeignKey() { 236 return m_sForeignKeyRef != null; 237 } 238 239 244 public String getForeignKeyReference() { 245 return m_sForeignKeyRef; 246 } 247 248 253 public void addForeignKey(String sForeignKeyRef) { 254 m_sForeignKeyRef = sForeignKeyRef; 255 } 256 257 } 258 | Popular Tags |