View Javadoc

1   package org.kuali.common.impex.model;
2   
3   import javax.xml.bind.annotation.XmlAccessType;
4   import javax.xml.bind.annotation.XmlAccessorType;
5   import javax.xml.bind.annotation.XmlAttribute;
6   
7   /**
8    * This interface provides an implementation-independent API to access database column model information
9    */
10  @XmlAccessorType(XmlAccessType.PROPERTY)
11  public class Column implements NamedElement {
12  
13  	public static final Boolean DEFAULT_NULLABLE_VALUE = true;
14  	public static final Boolean DEFAULT_PRIMARY_KEY_VALUE = false;
15  
16  	String name;
17  	DataType type;
18  	DataTypeSize size;
19  	String defaultValue;
20  	String description;
21  	Boolean primaryKey = DEFAULT_PRIMARY_KEY_VALUE;
22  	Boolean nullable = DEFAULT_NULLABLE_VALUE;
23  
24  	/**
25  	 * This is a copy constructor. It must create a perfect, deep, copy of this object
26  	 */
27  	public Column(Column column) {
28  		this.name = column.getName();
29  		this.type = column.getType();
30  		this.size = new DataTypeSize(column.getSize());
31  		this.defaultValue = column.getDefaultValue();
32  		this.description = column.getDescription();
33  		this.primaryKey = column.isPrimaryKey();
34  		this.nullable = column.isNullable();
35  	}
36  
37  	public Column() {
38  		this(null, null);
39  	}
40  
41  	/**
42  	 * Create a new instance of a Column
43  	 * 
44  	 * All values are initialized, with a special note that nullable is initially set to true
45  	 */
46  	public Column(String name, DataType dataType) {
47  		this.name = name;
48  		this.type = dataType;
49  	}
50  
51  	@XmlAttribute
52  	public DataType getType() {
53  		return type;
54  	}
55  
56  	@Override
57  	@XmlAttribute
58  	public String getName() {
59  		return name;
60  	}
61  
62  	@XmlAttribute
63  	public Boolean isPrimaryKey() {
64  		return primaryKey;
65  	}
66  
67  	@XmlAttribute
68  	public Boolean isNullable() {
69  		return nullable;
70  	}
71  
72  	@XmlAttribute
73  	public String getDescription() {
74  		return description;
75  	}
76  
77  	public void setPrimaryKey(Boolean primaryKey) {
78  		this.primaryKey = primaryKey;
79  	}
80  
81  	public DataTypeSize getSize() {
82  		return size;
83  	}
84  
85  	public void setSize(DataTypeSize typeSize) {
86  		this.size = typeSize;
87  	}
88  
89  	public String getDefaultValue() {
90  		return defaultValue;
91  	}
92  
93  	public void setDefaultValue(String defaultValue) {
94  		this.defaultValue = defaultValue;
95  	}
96  
97  	public void setNullable(Boolean nullable) {
98  		this.nullable = nullable;
99  	}
100 
101 	public void setDescription(String description) {
102 		this.description = description;
103 	}
104 
105 	public void setType(DataType columnDataType) {
106 		this.type = columnDataType;
107 	}
108 
109 	public void setName(String name) {
110 		this.name = name;
111 	}
112 }