001    /*
002     * JBoss DNA (http://www.jboss.org/dna)
003     * See the COPYRIGHT.txt file distributed with this work for information
004     * regarding copyright ownership.  Some portions may be licensed
005     * to Red Hat, Inc. under one or more contributor license agreements.
006     * See the AUTHORS.txt file in the distribution for a full listing of 
007     * individual contributors. 
008     *
009     * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
010     * is licensed to you under the terms of the GNU Lesser General Public License as
011     * published by the Free Software Foundation; either version 2.1 of
012     * the License, or (at your option) any later version.
013     *
014     * JBoss DNA is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017     * Lesser General Public License for more details.
018     *
019     * You should have received a copy of the GNU Lesser General Public
020     * License along with this software; if not, write to the Free
021     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022     * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
023     */
024    package org.jboss.dna.common.jdbc.model.spi;
025    
026    import org.jboss.dna.common.jdbc.model.api.NullabilityType;
027    import org.jboss.dna.common.jdbc.model.api.SearchabilityType;
028    import org.jboss.dna.common.jdbc.model.api.SqlType;
029    import org.jboss.dna.common.jdbc.model.api.SqlTypeInfo;
030    
031    /**
032     * Provides RDBMS supported standatd SQL types info.
033     * 
034     * @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy Litsenko</a>
035     */
036    public class SqlTypeInfoBean extends DatabaseNamedObjectBean implements SqlTypeInfo {
037        private static final long serialVersionUID = -3336885010975318256L;
038        private String localizedTypeName;
039        private NullabilityType nullabilityType;
040        private SqlType sqlType;
041        private Long precision;
042        private Boolean fixedPrecisionScale;
043        private Integer numberPrecisionRadix;
044        private Integer minScale;
045        private Integer maxScale;
046        private String literalPrefix;
047        private String literalSuffix;
048        private String createParams;
049        private Boolean caseSensitive;
050        private SearchabilityType searchabilityType;
051        private Boolean unsigned;
052        private Boolean autoIncrement;
053    
054        /**
055         * Default constructor
056         */
057        public SqlTypeInfoBean() {
058        }
059    
060        /**
061         * Returns localized version of type name (may be null). Type name is returned by DatabaseNamedObject.getName () method.
062         * 
063         * @return localized version of type name (may be null)
064         */
065        public String getLocalizedTypeName() {
066            return localizedTypeName;
067        }
068    
069        /**
070         * Sets localized version of type name (may be null). Type name is returned by DatabaseNamedObject.getName () method.
071         * 
072         * @param localizedTypeName localized version of type name (may be null)
073         */
074        public void setLocalizedTypeName( String localizedTypeName ) {
075            this.localizedTypeName = localizedTypeName;
076        }
077    
078        /**
079         * Gets SQL type nullability
080         * 
081         * @return SQL type nullability
082         */
083        public NullabilityType getNullabilityType() {
084            return nullabilityType;
085        }
086    
087        /**
088         * Sets SQL type nullability
089         * 
090         * @param nullabilityType SQL type nullability
091         */
092        public void setNullabilityType( NullabilityType nullabilityType ) {
093            this.nullabilityType = nullabilityType;
094        }
095    
096        /**
097         * Gets SQL type from java.sql.Types
098         * 
099         * @return SQL type from java.sql.Types
100         */
101        public SqlType getSqlType() {
102            return sqlType;
103        }
104    
105        /**
106         * Sets SQL type from java.sql.Types
107         * 
108         * @param sqlType the SQL type from java.sql.Types
109         */
110        public void setSqlType( SqlType sqlType ) {
111            this.sqlType = sqlType;
112        }
113    
114        /**
115         * Gets precision (number of fractional digits/scale) if applicable otherwise 0.
116         * 
117         * @return precision if applicable otherwise 0
118         */
119        public Long getPrecision() {
120            return precision;
121        }
122    
123        /**
124         * Sets precision (number of fractional digits/scale) if applicable otherwise 0.
125         * 
126         * @param precision precision if applicable otherwise 0
127         */
128        public void setPrecision( Long precision ) {
129            this.precision = precision;
130        }
131    
132        /**
133         * Returns true if sql type can be a money value, for instance
134         * 
135         * @return true if sql type can be a money value, for instance
136         */
137        public Boolean isFixedPrecisionScale() {
138            return fixedPrecisionScale;
139        }
140    
141        /**
142         * Sets true if sql type can be a money value, for instance
143         * 
144         * @param fixedPrecisionScale true if sql type can be a money value, for instance
145         */
146        public void setFixedPrecisionScale( Boolean fixedPrecisionScale ) {
147            this.fixedPrecisionScale = fixedPrecisionScale;
148        }
149    
150        /**
151         * Returns sql type precision radix (usually 2 or 10)
152         * 
153         * @return sql type precision radix (usually 2 or 10)
154         */
155        public Integer getNumberPrecisionRadix() {
156            return numberPrecisionRadix;
157        }
158    
159        /**
160         * sets sql type precision radix (usually 2 or 10)
161         * 
162         * @param numberPrecisionRadix the sql type precision radix (usually 2 or 10)
163         */
164        public void setNumberPrecisionRadix( Integer numberPrecisionRadix ) {
165            this.numberPrecisionRadix = numberPrecisionRadix;
166        }
167    
168        /**
169         * Returns minimum scale supported
170         * 
171         * @return minimum scale supported
172         */
173        public Integer getMinScale() {
174            return minScale;
175        }
176    
177        /**
178         * Sets minimum scale supported
179         * 
180         * @param minScale minimum scale supported
181         */
182        public void setMinScale( Integer minScale ) {
183            this.minScale = minScale;
184        }
185    
186        /**
187         * Returns maximum scale supported
188         * 
189         * @return maximum scale supported
190         */
191        public Integer getMaxScale() {
192            return maxScale;
193        }
194    
195        /**
196         * Sets maximum scale supported
197         * 
198         * @param maxScale the maximum scale supported
199         */
200        public void setMaxScale( Integer maxScale ) {
201            this.maxScale = maxScale;
202        }
203    
204        /**
205         * Returns prefix used to quote a literal (may be null)
206         * 
207         * @return prefix used to quote a literal (may be null)
208         */
209        public String getLiteralPrefix() {
210            return literalPrefix;
211        }
212    
213        /**
214         * Sets prefix used to quote a literal (may be null)
215         * 
216         * @param literalPrefix the prefix used to quote a literal (may be null)
217         */
218        public void setLiteralPrefix( String literalPrefix ) {
219            this.literalPrefix = literalPrefix;
220        }
221    
222        /**
223         * Returns suffix used to quote a literal (may be null)
224         * 
225         * @return suffix used to quote a literal (may be null)
226         */
227        public String getLiteralSuffix() {
228            return literalSuffix;
229        }
230    
231        /**
232         * Sets suffix used to quote a literal (may be null)
233         * 
234         * @param literalSuffix the suffix used to quote a literal (may be null)
235         */
236        public void setLiteralSuffix( String literalSuffix ) {
237            this.literalSuffix = literalSuffix;
238        }
239    
240        /**
241         * Returns parameters used in creating the type (may be null)
242         * 
243         * @return parameters used in creating the type (may be null)
244         */
245        public String getCreateParams() {
246            return createParams;
247        }
248    
249        /**
250         * Sets parameters used in creating the type (may be null)
251         * 
252         * @param createParams the parameters used in creating the type (may be null)
253         */
254        public void setCreateParams( String createParams ) {
255            this.createParams = createParams;
256        }
257    
258        /**
259         * Is sql type case sensitive
260         * 
261         * @return true if sql type case sensitive
262         */
263        public Boolean isCaseSensitive() {
264            return caseSensitive;
265        }
266    
267        /**
268         * Is sql type case sensitive
269         * 
270         * @param caseSensitive the true if sql type case sensitive
271         */
272        public void setCaseSensitive( Boolean caseSensitive ) {
273            this.caseSensitive = caseSensitive;
274        }
275    
276        /**
277         * Returns sql type searchability
278         * 
279         * @return sql type searchability
280         */
281        public SearchabilityType getSearchabilityType() {
282            return searchabilityType;
283        }
284    
285        /**
286         * Sets sql type searchability
287         * 
288         * @param searchabilityType the sql type searchability
289         */
290        public void setSearchabilityType( SearchabilityType searchabilityType ) {
291            this.searchabilityType = searchabilityType;
292        }
293    
294        /**
295         * Returns true if sql type is unsigned
296         * 
297         * @return true if sql type is unsigned
298         */
299        public Boolean isUnsigned() {
300            return unsigned;
301        }
302    
303        /**
304         * Sets true if sql type is unsigned
305         * 
306         * @param unsigned true if sql type is unsigned
307         */
308        public void setUnsigned( Boolean unsigned ) {
309            this.unsigned = unsigned;
310        }
311    
312        /**
313         * Returns true if sql type can be used for an auto-increment value.
314         * 
315         * @return true if sql type can be used for an auto-increment value.
316         */
317        public Boolean isAutoIncrement() {
318            return autoIncrement;
319        }
320    
321        /**
322         * Sets true if sql type can be used for an auto-increment value.
323         * 
324         * @param autoIncrement true if sql type can be used for an auto-increment value.
325         */
326        public void setAutoIncrement( Boolean autoIncrement ) {
327            this.autoIncrement = autoIncrement;
328        }
329    }