View Javadoc

1   package com.explosion.expfmodules.rdbmsconn.dbom;
2   
3   /*
4    * =============================================================================
5    * 
6    * Copyright 2004 Stephen Cowx
7    * 
8    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
9    * use this file except in compliance with the License. You may obtain a copy of
10   * 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, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   * 
20   * =============================================================================
21   */
22  
23  import java.sql.ResultSet;
24  import java.sql.ResultSetMetaData;
25  import java.sql.SQLException;
26  
27  /***
28   * Represents a column object as it is descibed by the ResultSet MetaData object
29   * 
30   * @author Stephen Cowx
31   */
32  public class DataSetColumn
33  {
34  
35      private boolean autoIncrement;
36      private boolean writable;
37      private boolean signed;
38      private boolean searchable;
39      private boolean readOnly;
40      private int nullable;
41      private boolean definitelyWritable;
42      private boolean currency;
43      private boolean caseSensitive;
44      private String columnName;
45      private int columnIndex;
46  
47      public DataSetColumn(ResultSet rs, int columnIndex) throws SQLException
48      {
49          ResultSetMetaData rsm = rs.getMetaData();
50  
51          this.autoIncrement = rsm.isAutoIncrement(columnIndex);
52          this.writable = rsm.isWritable(columnIndex);
53          this.signed = rsm.isSigned(columnIndex);
54          this.searchable = rsm.isSearchable(columnIndex);
55          this.readOnly = rsm.isReadOnly(columnIndex);
56          this.nullable = rsm.isNullable(columnIndex);
57          this.definitelyWritable = rsm.isDefinitelyWritable(columnIndex);
58          this.currency = rsm.isAutoIncrement(columnIndex);
59          this.caseSensitive = rsm.isAutoIncrement(columnIndex);
60          this.columnName = rsm.getColumnName(columnIndex);
61          this.columnIndex = columnIndex;
62      }
63      
64      /***
65       * Indicates whether the designated column is automatically numbered, thus
66       * read-only.
67       */
68      public boolean isAutoIncrement()
69      {
70          return autoIncrement;
71      }
72  
73      /*** Indicates whether a column's case matters. */
74      public boolean isCaseSensitive()
75      {
76          return caseSensitive;
77      }
78  
79      /*** Indicates whether the designated column is a cash value. */
80      public boolean isCurrency()
81      {
82          return currency;
83      }
84  
85      /***
86       * Indicates whether a write on the designated column will definitely
87       * succeed.
88       */
89      public boolean isDefinitelyWritable()
90      {
91          return definitelyWritable;
92      }
93  
94      /*** Indicates the nullability of values in the designated column. */
95      public int isNullable()
96      {
97          return nullable;
98      }
99  
100     /*** /** Indicates whether the designated column is definitely not writable. */
101     public boolean isReadOnly()
102     {
103         return readOnly;
104     }
105 
106     /*** Indicates whether the designated column can be used in a where clause. */
107     public boolean isSearchable()
108     {
109         return searchable;
110     }
111 
112     /*** Indicates whether values in the designated column are signed numbers. */
113     public boolean isSigned()
114     {
115         return signed;
116     }
117 
118     /*** Indicates whether or not this column is sortable using the order by statement. */
119     public boolean isSortable()
120     {
121         return signed;
122     }
123 
124     /***
125      * Indicates whether it is possible for a write on the designated column to
126      * succeed.
127      */
128     public boolean isWritable()
129     {
130         return writable;
131     }
132 
133     /***
134      * @return Returns the columnName.
135      */
136     public String getColumnName()
137     {
138         return columnName;
139     }
140 
141     /***
142      * @return Returns the columnIndex.
143      */
144     public int getColumnIndex()
145     {
146         return columnIndex;
147     }
148 }