KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > catalog > TypeDescriptor


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

21
22 package org.apache.derby.catalog;
23
24 /**
25  *
26  * An interface for describing types in Cloudscape systems.
27  *
28  *
29  * <p>The values in system catalog DATATYPE columns are of type
30  * TypeDescriptor.
31  */

32
33 public interface TypeDescriptor
34 {
35     ///////////////////////////////////////////////////////////////////////
36
//
37
// CONSTANTS
38
//
39
///////////////////////////////////////////////////////////////////////
40

41
42     /**
43       The return value from getMaximumWidth() for types where the maximum
44       width is unknown.
45      */

46
47     public static int MAXIMUM_WIDTH_UNKNOWN = -1;
48
49
50     ///////////////////////////////////////////////////////////////////////
51
//
52
// METHODS
53
//
54
///////////////////////////////////////////////////////////////////////
55

56     /**
57      * Get the jdbc type id for this type. JDBC type can be
58      * found in java.sql.Types.
59      *
60      * @return a jdbc type, e.g. java.sql.Types.DECIMAL
61      *
62      * @see java.sql.Types
63      */

64     public int getJDBCTypeId();
65
66     /**
67       Returns the maximum width of the type. This may have
68       different meanings for different types. For example, with char,
69       it means the maximum number of characters, while with int, it
70       is the number of bytes (i.e. 4).
71
72       @return the maximum length of this Type; -1 means "unknown/no max length"
73       */

74     public int getMaximumWidth();
75
76
77     /**
78       Returns the maximum width of the type IN BYTES. This is the
79       maximum number of bytes that could be returned for this type
80       if the corresponding getXXX() method is used. For example,
81       if we have a CHAR type, then we want the number of bytes
82       that would be returned by a ResultSet.getString() call.
83
84       @return the maximum length of this Type IN BYTES;
85                 -1 means "unknown/no max length"
86       */

87     public int getMaximumWidthInBytes();
88
89
90     /**
91       Returns the number of decimal digits for the type, if applicable.
92      
93       @return The number of decimal digits for the type. Returns
94             zero for non-numeric types.
95       */

96     public int getPrecision();
97
98
99     /**
100       Returns the number of digits to the right of the decimal for
101       the type, if applicable.
102      
103       @return The number of digits to the right of the decimal for
104             the type. Returns zero for non-numeric types.
105       */

106     public int getScale();
107
108
109     /**
110       Gets the nullability that values of this type have.
111       
112
113       @return true if values of this type may be null. false otherwise
114       */

115     public boolean isNullable();
116
117     /**
118       Gets the name of this type.
119       
120
121       @return the name of this type
122       */

123     public String JavaDoc getTypeName();
124
125
126     /**
127       Converts this type descriptor (including length/precision)
128       to a string suitable for appearing in a SQL type specifier. E.g.
129      
130                 VARCHAR(30)
131
132       or
133
134                  java.util.Hashtable
135      
136      
137       @return String version of type, suitable for running through
138                 a SQL Parser.
139      
140      */

141     public String JavaDoc getSQLstring();
142
143 }
144
145
Popular Tags