1 package uba.db.column;
2
3 import java.io.Serializable;
4
5 import uba.db.table.Table;
6
7 /***
8 * Clase base para facilitar la implementación de la interfaz
9 * {@link uba.db.column.ColumnSpecification}.
10 *
11 * @version $Revision: 1.3 $
12 */
13 public abstract class ColumnSpecificationBehavior
14 implements ColumnSpecification, Serializable {
15 private String name;
16 private String dataTypeDisplayString;
17 private ColumnConstraint constraint;
18
19 /***
20 * Las sub-clases deben invocar este constructor para especificar ciertas propieades
21 * de esta especificación de columna.
22 *
23 * @param dataTypeDisplayString
24 * especifica el valor retornado por
25 * {@link #dataTypeDisplayString}
26 * @param name
27 * nombre de la columna.
28 * @param constraint
29 * constraint para esta columna (si admite o no valores nulos,
30 */
31 public ColumnSpecificationBehavior(String dataTypeDisplayString, String name,
32 ColumnConstraint constraint) {
33 this.dataTypeDisplayString = dataTypeDisplayString;
34 this.name = name;
35 this.constraint = constraint;
36 }
37
38 /***
39 * @see uba.db.column.ColumnSpecification#notNull()
40 */
41 public boolean notNull() {
42 return constraint.notNull();
43 }
44
45 /***
46 * @see uba.db.column.ColumnSpecification#name()
47 */
48 public String name() {
49 return name;
50 }
51
52 /***
53 * @see uba.db.column.ColumnSpecification#constraint()
54 */
55 public ColumnConstraint constraint() {
56 return constraint;
57 }
58
59 /***
60 * @see uba.db.column.ColumnSpecification#isNamed(java.lang.String)
61 */
62 public boolean isNamed(String nameToTest) {
63 return name.equalsIgnoreCase(nameToTest);
64 }
65
66 /***
67 * @see uba.db.column.ColumnSpecification#dataTypeDisplayString()
68 */
69 public String dataTypeDisplayString() {
70 return dataTypeDisplayString;
71 }
72
73 /***
74 * @see uba.db.column.ColumnSpecification#asColumnFor(uba.db.table.Table)
75 */
76 public Column asColumnFor(Table table) {
77 return new Column(table, this);
78 }
79 }