001    package org.kuali.common.impex.model;
002    
003    import javax.xml.bind.annotation.XmlAccessType;
004    import javax.xml.bind.annotation.XmlAccessorType;
005    import javax.xml.bind.annotation.XmlAttribute;
006    
007    /**
008     * This interface provides an implementation-independent API to access database column model information
009     */
010    @XmlAccessorType(XmlAccessType.PROPERTY)
011    public class Column implements NamedElement {
012    
013            public static final Boolean DEFAULT_NULLABLE_VALUE = true;
014            public static final Boolean DEFAULT_PRIMARY_KEY_VALUE = false;
015    
016            String name;
017            DataType type;
018            DataTypeSize size;
019            String defaultValue;
020            String description;
021            Boolean primaryKey = DEFAULT_PRIMARY_KEY_VALUE;
022            Boolean nullable = DEFAULT_NULLABLE_VALUE;
023    
024            /**
025             * This is a copy constructor. It must create a perfect, deep, copy of this object
026             */
027            public Column(Column column) {
028                    this.name = column.getName();
029                    this.type = column.getType();
030                    this.size = new DataTypeSize(column.getSize());
031                    this.defaultValue = column.getDefaultValue();
032                    this.description = column.getDescription();
033                    this.primaryKey = column.isPrimaryKey();
034                    this.nullable = column.isNullable();
035            }
036    
037            public Column() {
038                    this(null, null);
039            }
040    
041            /**
042             * Create a new instance of a Column
043             * 
044             * All values are initialized, with a special note that nullable is initially set to true
045             */
046            public Column(String name, DataType dataType) {
047                    this.name = name;
048                    this.type = dataType;
049            }
050    
051            @XmlAttribute
052            public DataType getType() {
053                    return type;
054            }
055    
056            @Override
057            @XmlAttribute
058            public String getName() {
059                    return name;
060            }
061    
062            @XmlAttribute
063            public Boolean isPrimaryKey() {
064                    return primaryKey;
065            }
066    
067            @XmlAttribute
068            public Boolean isNullable() {
069                    return nullable;
070            }
071    
072            @XmlAttribute
073            public String getDescription() {
074                    return description;
075            }
076    
077            public void setPrimaryKey(Boolean primaryKey) {
078                    this.primaryKey = primaryKey;
079            }
080    
081            public DataTypeSize getSize() {
082                    return size;
083            }
084    
085            public void setSize(DataTypeSize typeSize) {
086                    this.size = typeSize;
087            }
088    
089            public String getDefaultValue() {
090                    return defaultValue;
091            }
092    
093            public void setDefaultValue(String defaultValue) {
094                    this.defaultValue = defaultValue;
095            }
096    
097            public void setNullable(Boolean nullable) {
098                    this.nullable = nullable;
099            }
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    }