KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > jpa > map > JpaColumn


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20
21 package org.apache.cayenne.jpa.map;
22
23 import javax.persistence.Column;
24
25 public class JpaColumn {
26
27     protected String JavaDoc name;
28     protected boolean unique;
29     protected boolean nullable;
30     protected boolean insertable;
31     protected boolean updatable;
32     protected String JavaDoc columnDefinition;
33     protected String JavaDoc table;
34     protected int length;
35     protected int precision;
36     protected int scale;
37
38     public JpaColumn() {
39
40     }
41
42     public JpaColumn(Column annotation) {
43         if (!"".equals(annotation.name())) {
44             name = annotation.name();
45         }
46
47         unique = annotation.unique();
48         nullable = annotation.nullable();
49         insertable = annotation.insertable();
50         updatable = annotation.updatable();
51
52         if (!"".equals(annotation.columnDefinition())) {
53             columnDefinition = annotation.columnDefinition();
54         }
55
56         if (!"".equals(annotation.table())) {
57             table = annotation.table();
58         }
59
60         length = annotation.length();
61         precision = annotation.precision();
62         scale = annotation.scale();
63     }
64
65     public String JavaDoc getColumnDefinition() {
66         return columnDefinition;
67     }
68
69     public void setColumnDefinition(String JavaDoc columnDefinition) {
70         this.columnDefinition = columnDefinition;
71     }
72
73     public boolean isInsertable() {
74         return insertable;
75     }
76
77     public void setInsertable(boolean insertable) {
78         this.insertable = insertable;
79     }
80
81     public int getLength() {
82         return length;
83     }
84
85     public void setLength(int length) {
86         this.length = length;
87     }
88
89     public String JavaDoc getName() {
90         return name;
91     }
92
93     public void setName(String JavaDoc name) {
94         this.name = name;
95     }
96
97     public boolean isNullable() {
98         return nullable;
99     }
100
101     public void setNullable(boolean nullable) {
102         this.nullable = nullable;
103     }
104
105     public int getPrecision() {
106         return precision;
107     }
108
109     public void setPrecision(int precision) {
110         this.precision = precision;
111     }
112
113     public int getScale() {
114         return scale;
115     }
116
117     public void setScale(int scale) {
118         this.scale = scale;
119     }
120
121     public String JavaDoc getTable() {
122         return table;
123     }
124
125     public void setTable(String JavaDoc table) {
126         this.table = table;
127     }
128
129     public boolean isUnique() {
130         return unique;
131     }
132
133     public void setUnique(boolean unique) {
134         this.unique = unique;
135     }
136
137     public boolean isUpdatable() {
138         return updatable;
139     }
140
141     public void setUpdatable(boolean updateable) {
142         this.updatable = updateable;
143     }
144     
145     @Override JavaDoc
146     public String JavaDoc toString() {
147         String JavaDoc className = getClass().getName();
148         return className.substring(className.lastIndexOf('.') + 1) + ":" + name;
149     }
150 }
151
Popular Tags