1 21 package oracle.toplink.essentials.internal.databaseaccess; 23 24 import java.io.*; 25 import oracle.toplink.essentials.internal.helper.*; 26 27 37 public class FieldTypeDefinition implements Serializable { 38 protected String name; 39 protected int defaultSize; 40 protected int defaultSubSize; 41 protected boolean isSizeAllowed; 42 protected boolean isSizeRequired; 43 protected int maxPrecision; 44 protected int minScale; 45 protected int maxScale; 46 protected boolean shouldAllowNull; 48 public FieldTypeDefinition() { 49 defaultSize = 10; 50 isSizeRequired = false; 51 isSizeAllowed = true; 52 maxPrecision = 10; 53 minScale = 0; 54 maxScale = 0; 55 shouldAllowNull = true; 56 } 57 58 62 public FieldTypeDefinition(String databaseTypeName) { 63 this(); 64 name = databaseTypeName; 65 } 66 67 70 public FieldTypeDefinition(String databaseTypeName, int defaultSize) { 71 this(); 72 this.name = databaseTypeName; 73 this.defaultSize = defaultSize; 74 this.isSizeRequired = true; 75 setMaxPrecision(defaultSize); 76 } 77 78 81 public FieldTypeDefinition(String databaseTypeName, int defaultSize, int defaultSubSize) { 82 this(); 83 this.name = databaseTypeName; 84 this.defaultSize = defaultSize; 85 this.defaultSubSize = defaultSubSize; 86 this.isSizeRequired = true; 87 setMaxPrecision(defaultSize); 88 setMaxScale(defaultSubSize); 89 } 90 91 94 public FieldTypeDefinition(String databaseTypeName, boolean allowsSize) { 95 this(); 96 this.name = databaseTypeName; 97 this.isSizeAllowed = allowsSize; 98 } 99 100 103 public FieldTypeDefinition(String databaseTypeName, boolean allowsSize, boolean allowsNull) { 104 this(databaseTypeName, allowsSize); 105 this.shouldAllowNull = allowsNull; 106 } 107 108 113 public int getDefaultSize() { 114 return defaultSize; 115 } 116 117 122 public int getDefaultSubSize() { 123 return defaultSubSize; 124 } 125 126 public int getMaxPrecision() { 127 return maxPrecision; 128 } 129 130 public int getMaxScale() { 131 return maxScale; 132 } 133 134 public int getMinScale() { 135 return minScale; 136 } 137 138 163 public String getName() { 164 return name; 165 } 166 167 170 public boolean isSizeAllowed() { 171 return isSizeAllowed; 172 } 173 174 177 public boolean isSizeRequired() { 178 return isSizeRequired; 179 } 180 181 184 public boolean shouldAllowNull() { 185 return this.shouldAllowNull; 186 } 187 188 193 public void setDefaultSize(int defaultSize) { 194 this.defaultSize = defaultSize; 195 } 196 197 202 public void setDefaultSubSize(int defaultSubSize) { 203 this.defaultSubSize = defaultSubSize; 204 } 205 206 209 public void setIsSizeAllowed(boolean aBoolean) { 210 isSizeAllowed = aBoolean; 211 } 212 213 216 public void setIsSizeRequired(boolean aBoolean) { 217 isSizeRequired = aBoolean; 218 } 219 220 223 public void setShouldAllowNull(boolean allowsNull) { 224 this.shouldAllowNull = allowsNull; 225 } 226 227 231 public FieldTypeDefinition setLimits(int maxPrecision, int minScale, int maxScale) { 232 setMaxPrecision(maxPrecision); 233 setMinScale(minScale); 234 setMaxScale(maxScale); 235 return this; 236 } 237 238 public void setMaxPrecision(int maximum) { 239 maxPrecision = maximum; 240 } 241 242 public void setMaxScale(int maximum) { 243 maxScale = maximum; 244 } 245 246 public void setMinScale(int minimum) { 247 minScale = minimum; 248 } 249 250 275 public void setName(String name) { 276 this.name = name; 277 } 278 279 282 public void setSizeDisallowed() { 283 setIsSizeAllowed(false); 284 } 285 286 289 public void setSizeOptional() { 290 setIsSizeRequired(false); 291 setIsSizeAllowed(true); 292 } 293 294 297 public void setSizeRequired() { 298 setIsSizeRequired(true); 299 } 300 301 public String toString() { 302 return Helper.getShortClassName(getClass()) + "(" + getName() + ")"; 303 } 304 } 305 | Popular Tags |