From 18 Jan, 2021 0:00 UTC: All services will be temporary unavailable for maintenance
  • R/O
  • SSH

JdbcAcsess2: Commit

全てを再実装したJdbcAcsessです。


Commit MetaInfo

Revisionab92438e04367774ecab1b7d51ede94654208599 (tree)
Time2012-02-27 01:12:08
Authorshimakazuro
Commitershimakazuro

Log Message

ちょっと整理

Change Summary

Incremental Difference

diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/connect/ConnectView.java
--- a/src/jdbcacsess2/connect/ConnectView.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/connect/ConnectView.java Mon Feb 27 01:12:08 2012 +0900
@@ -40,7 +40,6 @@
4040 import javax.swing.JSplitPane;
4141 import javax.swing.JTextArea;
4242 import javax.swing.JTextField;
43-import javax.swing.SwingUtilities;
4443 import javax.swing.WindowConstants;
4544 import javax.swing.border.BevelBorder;
4645 import javax.swing.border.TitledBorder;
@@ -129,15 +128,6 @@
129128 setLocation(c.getX(), c.getY());
130129 setSize(c.getWidth(), c.getHeight());
131130
132- // setVisibleの中で、何故かx,y=(-6,-23)へ移動してしまう。
133- // とりあえず、画面移動がsetVisibleの後に行われることを期待してEDTへスレッドキューイング。
134- // 時々、ダメだけどかなりましになった。
135- SwingUtilities.invokeLater(new Runnable() {
136- @Override
137- public void run() {
138- setLocation(c.getX(), c.getY());
139- }
140- });
141131 }
142132
143133 /**
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/main/MainController.java
--- a/src/jdbcacsess2/main/MainController.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/main/MainController.java Mon Feb 27 01:12:08 2012 +0900
@@ -49,7 +49,6 @@
4949 import javax.swing.event.TreeSelectionEvent;
5050 import javax.swing.event.TreeSelectionListener;
5151 import javax.swing.event.TreeWillExpandListener;
52-import javax.swing.table.DefaultTableModel;
5352 import javax.swing.table.TableRowSorter;
5453 import javax.swing.text.BadLocationException;
5554 import javax.swing.text.JTextComponent;
@@ -680,25 +679,22 @@
680679 DBobjectMutableTreeTableNode node = (DBobjectMutableTreeTableNode) e.getPath().getLastPathComponent();
681680 DBObject dbObject = node.getDBObject();
682681
682+ // 出力したいProperty情報を持っている時のみ表示する
683+ if (dbObject.isPropertyEnable()) {
684+ JmyTable jTableProperty = view.getCurrentJPanelSession().getJTableProperty();
685+ jTableProperty.setModel(new PropertyDBObjectsTableModel(dbObject.getProperties()));
686+ }
687+
683688 // TABLEカラムの場合は親ノード(=TABLE)に書き換える
684689 if (dbObject instanceof DBObjectTableColumn) {
685690 DBobjectMutableTreeTableNode parent = (DBobjectMutableTreeTableNode) node.getParent();
686691 dbObject = parent.getDBObject();
687692 }
688693
689- // 出力したいProperty情報を持っている時のみ表示する
690- if (dbObject.isPropertyEnable()) {
691- JmyTable jTableProperty = view.getCurrentJPanelSession().getJTableProperty();
692- jTableProperty.setModel(new PropertyDBObjectsTableModel(dbObject.getProperties()));
693- }
694-
695694 // TABLE 系の時のみexportkey情報を表示する
696695 JmyTable jTable = view.getCurrentJPanelSession().getJTableExportedKey();
697696 if (dbObject instanceof DBObjectTable) {
698697 jTable.setModel(new PropertyExportedKeyTableModel(((DBObjectTable) dbObject).getExportedKey()));
699- } else {
700- // TABLE系以外なので空のモデルを設定する
701- jTable.setModel(new DefaultTableModel());
702698 }
703699 }
704700 };
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObject.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObject.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObject.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -21,6 +21,8 @@
2121
2222 import javax.swing.Icon;
2323
24+import jdbcacsess2.sqlService.ConstSqlTypes;
25+import jdbcacsess2.sqlService.ConstSqlTypes.Categoly;
2426 import jdbcacsess2.sqlService.DataBaseConnection;
2527
2628 abstract public class DBObject {
@@ -77,12 +79,16 @@
7779 }
7880
7981 static public class Property {
80- private String name;
81- private String value;
82+ private final String name;
83+ private final String value;
8284
8385 public Property(String name, String value) {
8486 this.name = name;
85- this.value = value;
87+ if (value == null) {
88+ this.value = "";
89+ } else {
90+ this.value = value;
91+ }
8692 }
8793 public String getName() {
8894 return name;
@@ -171,4 +177,29 @@
171177 */
172178 abstract public boolean isPropertyEnable();
173179
180+ /**
181+ * データ型の文字列表現を編集
182+ *
183+ * @param dataType
184+ * @param columnSize
185+ * @param decimalDigits
186+ * @return
187+ */
188+ public StringBuilder editAttrString(int dataType, int columnSize, int decimalDigits) {
189+ StringBuilder attr = new StringBuilder();
190+
191+ ConstSqlTypes constSqlTypes = ConstSqlTypes.searchTypes(dataType);
192+ attr.append(constSqlTypes.name()).append('(').append(columnSize);
193+
194+ if (constSqlTypes.getCategoly() == Categoly.NUM) {
195+ if (decimalDigits != 0) {
196+ attr.append('.').append(decimalDigits);
197+ }
198+ }
199+
200+ attr.append(')');
201+
202+ return attr;
203+
204+ }
174205 }
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectCatalogs.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectCatalogs.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectCatalogs.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -34,7 +34,7 @@
3434 public class DBObjectCatalogs extends DBObjects {
3535
3636
37- private ArrayList<DBObject> catalogs = new ArrayList<DBObject>();
37+ private final ArrayList<DBObject> catalogs = new ArrayList<DBObject>();
3838
3939 /**
4040 * コンストラクタ
@@ -67,18 +67,12 @@
6767 */
6868 public static class DBObjectCatalog extends DBObject {
6969
70- private String catalogName;
71-
7270 /**
73- * {@link DatabaseMetaData#getCatalogs()} の第1要素
74- *
75- * @return
71+ * カタログ名 {@link DatabaseMetaData#getCatalogs()} の第1要素
7672 */
77- public String getCatalogName() {
78- return catalogName;
79- }
73+ public String catalogName;
8074
81- private List<Property> properties = new ArrayList<Property>();
75+ private final List<Property> properties = new ArrayList<Property>();
8276
8377 @Override
8478 public List<Property> getProperties() {
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectProcedureColumns.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectProcedureColumns.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectProcedureColumns.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -23,8 +23,6 @@
2323
2424 import javax.swing.Icon;
2525
26-import jdbcacsess2.sqlService.ConstSqlTypes;
27-import jdbcacsess2.sqlService.ConstSqlTypes.Categoly;
2826 import jdbcacsess2.sqlService.dbobject.DBObjectProcedures.DBObjectProcedure;
2927 import jdbcacsess2.sqlService.dbobject.icon.DbObjectIconImage;
3028
@@ -37,7 +35,7 @@
3735 public class DBObjectProcedureColumns extends DBObjects {
3836
3937
40- private ArrayList<DBObjectProcedureColumn> procedureColumns = new ArrayList<DBObjectProcedureColumn>();
38+ private final ArrayList<DBObjectProcedureColumn> procedureColumns = new ArrayList<DBObjectProcedureColumn>();
4139
4240 /**
4341 * コンストラクタ
@@ -76,67 +74,37 @@
7674 *
7775 */
7876 public static class DBObjectProcedureColumn extends DBObject {
79- private String procedureCatalog;
80-
8177 /**
8278 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
8379 * の第1要素
84- *
85- * @return
8680 */
87- public String getProcedureCatalog() {
88- return procedureCatalog;
89- }
90-
91- private String procedureSchema;
81+ public String procedureCatalog;
9282
9383 /**
9484 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
9585 * の第2要素
96- *
97- * @return
9886 */
99- public String getProcedureSchema() {
100- return procedureSchema;
101- }
102-
103- private String procedureName;
87+ public String procedureSchema;
10488
10589 /**
10690 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
10791 * の第3要素
108- *
109- * @return
11092 */
111- public String getProcedureName() {
112- return procedureName;
113- }
114-
115- private String columnName;
93+ public String procedureName;
11694
11795 /**
11896 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
11997 * の第4要素
120- *
121- * @return
12298 */
123- public String getColumnName() {
124- return columnName;
125- }
126-
127- private Short columnType;
99+ public String columnName;
128100
129101 /**
130102 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
131103 * の第5要素
132- *
133- * @return
134104 */
135- public Short getColumnType() {
136- return columnType;
137- }
105+ public Short columnType;
138106
139- public String getColumnTypeName() {
107+ private String getColumnTypeName() {
140108 switch (columnType) {
141109 case DatabaseMetaData.procedureColumnUnknown:
142110 return "ColumnUnknown";
@@ -154,91 +122,50 @@
154122 return "?";
155123 }
156124
157- private int dataType;
158125
159126 /**
160127 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
161128 * の第6要素
162- *
163- * @return
164129 */
165- public int getDataType() {
166- return dataType;
167- }
168-
169- private String typeName;
130+ public int dataType;
170131
171132 /**
172133 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
173134 * の第7要素
174- *
175- * @return
176135 */
177- public String getTypeName() {
178- return typeName;
179- }
180-
181- private int precision;
136+ public String typeName;
182137
183138 /**
184139 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
185140 * の第8要素
186- *
187- * @return
188141 */
189- public int getPrecision() {
190- return precision;
191- }
192-
193- private int length;
142+ public int precision;
194143
195144 /**
196145 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
197146 * の第9要素
198- *
199- * @return
200147 */
201- public int getLength() {
202- return length;
203- }
204-
205- private short scale;
148+ public int length;
206149
207150 /**
208151 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
209152 * の第10要素
210- *
211- * @return
212153 */
213- public short getScale() {
214- return scale;
215- }
216-
217- private short radix;
154+ public short scale;
218155
219156 /**
220157 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
221158 * の第11要素
222- *
223- * @return
224159 */
225- public short getRadix() {
226- return radix;
227- }
228-
229- private short nullable;
160+ public short radix;
230161
231162 /**
232163 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
233164 * の第12要素
234- *
235- * @return
236165 */
237- public short getNullable() {
238- return nullable;
239- }
166+ public short nullable;
240167
241- public String getNullableName() {
168+ private String getNullableName() {
242169 switch (nullable) {
243170 case DatabaseMetaData.procedureNoNulls:
244171 return "NoNulls";
@@ -250,85 +177,51 @@
250177 return "?";
251178 }
252179
253- private String remarks;
254- private StringBuffer summary;
255-
256180 /**
257181 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
258182 * の第13要素
259- *
260- * @return remarks
261183 */
262- public String getRemarks() {
263- return remarks;
264- }
265-
266- private String columnDef;
184+ public String remarks;
267185
268186 /**
269187 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
270188 * の第14要素
271- *
272- * @return remarks
273189 */
274- public String getColumnDef() {
275- return columnDef;
276- }
277-
278- private int charOctetLength;
190+ public String columnDef;
279191
280192 /**
281193 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
282194 * の第17要素
283- *
284- * @return remarks
285195 */
286- public int getCharOctetLength() {
287- return charOctetLength;
288- }
289-
290- private int ordinalPosition;
196+ public int charOctetLength;
291197
292198 /**
293199 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
294200 * の第18要素
295- *
296- * @return remarks
297201 */
298- public int getOrdinalPosition() {
299- return ordinalPosition;
300- }
301-
302- private String isNullable;
202+ public int ordinalPosition;
303203
304204 /**
305205 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
306206 * の第19要素
307- *
308- * @return remarks
309207 */
310- public String getIsNullable() {
311- return isNullable;
312- }
313-
314- private String specificName;
208+ public String isNullable;
315209
316210 /**
317211 * {@link DatabaseMetaData#getProcedureColumns(String, String, String, String)}
318212 * の第20要素
319- *
320- * @return remarks
321213 */
322- public String getSpecificName() {
323- return specificName;
324- }
214+ public String specificName;
325215
326- private List<Property> properties = new ArrayList<Property>();
216+ private final StringBuilder attr;
217+
218+ private final List<Property> properties = new ArrayList<Property>();
327219
328220 @Override
329221 public List<Property> getProperties() {
330222 return properties;
331223 }
224+
332225 /**
333226 * コンストラクタ
334227 *
@@ -428,23 +321,10 @@
428321 specificName = rs.getString(++i);
429322 properties.add(new Property("SPECIFIC_NAME", specificName));
430323 }
431-
432324
433- summary = new StringBuffer();
434- summary.append(columnName);
435- summary.append(' ');
436- ConstSqlTypes constSqlTypes = ConstSqlTypes.searchTypes(dataType);
437- summary.append(constSqlTypes.name());
438- summary.append('(');
439- summary.append(precision);
440- if (constSqlTypes.getCategoly() == Categoly.NUM) {
441- if (scale != 0) {
442- summary.append('.');
443- summary.append(scale);
444- }
445- }
446- summary.append(')');
447- summary.append((remarks != null ? remarks : ""));
325+
326+ attr = editAttrString(dataType, precision, scale);
327+
448328 }
449329
450330 /*
@@ -509,6 +389,16 @@
509389 }
510390
511391 @Override
392+ public String getProperty1() {
393+ return attr.toString();
394+ }
395+
396+ @Override
397+ public String getProperty2() {
398+ return remarks;
399+ }
400+
401+ @Override
512402 public boolean isPropertyEnable() {
513403 return true;
514404 }
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectProcedures.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectProcedures.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectProcedures.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -35,7 +35,7 @@
3535 */
3636 public class DBObjectProcedures extends DBObjects {
3737
38- private ArrayList<DBObjectProcedure> procedures = new ArrayList<DBObjectProcedure>();
38+ private final ArrayList<DBObjectProcedure> procedures = new ArrayList<DBObjectProcedure>();
3939
4040 /**
4141 * コンストラクタ
@@ -49,12 +49,12 @@
4949
5050 String catalogName = null;
5151 if (catalog != null) {
52- catalogName = catalog.getCatalogName();
52+ catalogName = catalog.catalogName;
5353 }
5454
5555 String schemaName = null;
5656 if (schema != null) {
57- schemaName = schema.getSchemaName();
57+ schemaName = schema.schemaName;
5858 }
5959
6060 ResultSet rs = dmd.getProcedures(catalogName, schemaName, "%");
@@ -189,7 +189,7 @@
189189 return procedureCat + procedureSchem + procedureName;
190190 }
191191
192- private List<Property> properties = new ArrayList<Property>();
192+ private final List<Property> properties = new ArrayList<Property>();
193193
194194 @Override
195195 public List<Property> getProperties() {
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectSchemas.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectSchemas.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectSchemas.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -35,7 +35,7 @@
3535 public class DBObjectSchemas extends DBObjects {
3636
3737
38- private ArrayList<DBObjectSchema> schemas = new ArrayList<DBObjectSchema>();
38+ private final ArrayList<DBObjectSchema> schemas = new ArrayList<DBObjectSchema>();
3939
4040 DBObjectCatalog dbCatalog;
4141
@@ -73,29 +73,17 @@
7373 */
7474 public class DBObjectSchema extends DBObject {
7575
76- private String schemaName;
76+ /**
77+ * スキーマ名 {@link DatabaseMetaData#getSchemas()}の第1要素
78+ */
79+ public String schemaName;
7780
7881 /**
79- * スキーマ名
80- *
81- * @return {@link DatabaseMetaData#getSchemas()}の第1要素
82+ * カタログ名 {@link DatabaseMetaData#getSchemas()}の第2要素
8283 */
83- public String getSchemaName() {
84- return schemaName;
85- }
86-
87- private String catalogName;
84+ public String catalogName;
8885
89- /**
90- * カタログ名
91- *
92- * @return {@link DatabaseMetaData#getSchemas()}の第2要素
93- */
94- public String getCatalogName() {
95- return catalogName;
96- }
97-
98- private List<Property> properties = new ArrayList<Property>();
86+ private final List<Property> properties = new ArrayList<Property>();
9987
10088 @Override
10189 public List<Property> getProperties() {
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectTableColumns.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectTableColumns.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectTableColumns.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -26,9 +26,7 @@
2626 import javax.swing.Icon;
2727
2828 import jdbcacsess2.main.Jdbcacsess2;
29-import jdbcacsess2.sqlService.ConstSqlTypes;
3029 import jdbcacsess2.sqlService.ReferenceColumnResult;
31-import jdbcacsess2.sqlService.ConstSqlTypes.Categoly;
3230 import jdbcacsess2.sqlService.dbobject.DBObjectTables.DBObjectTable;
3331 import jdbcacsess2.sqlService.dbobject.icon.DbObjectIconImage;
3432
@@ -40,11 +38,11 @@
4038 */
4139 public class DBObjectTableColumns extends DBObjects {
4240
43- private ArrayList<DBObjectTableColumn> tableColumns = new ArrayList<DBObjectTableColumn>();
41+ private final ArrayList<DBObjectTableColumn> tableColumns = new ArrayList<DBObjectTableColumn>();
4442
4543
46- private boolean storesLowerCaseIdentifiers;
47- private boolean storesUpperCaseQuotedIdentifiers;
44+ private final boolean storesLowerCaseIdentifiers;
45+ private final boolean storesUpperCaseQuotedIdentifiers;
4846 /**
4947 * コンストラクタ
5048 *
@@ -59,7 +57,7 @@
5957
6058 //
6159 Map<String, Short> pkmap = new HashMap<String, Short>();
62- ResultSet pkrs = dmd.getPrimaryKeys(table.getTableCatalog(), table.getTableSchema(), table.getTableName());
60+ ResultSet pkrs = dmd.getPrimaryKeys(table.tableCatalog, table.tableSchema, table.getTableName());
6361 while (pkrs.next()) {
6462 pkmap.put(pkrs.getString(4), pkrs.getShort(5));
6563 }
@@ -67,7 +65,7 @@
6765
6866 // 外部参照キー情報を取得する
6967 Map<String, ReferenceColumnResult> fkmap = new HashMap<String, ReferenceColumnResult>();
70- ResultSet fkrs = dmd.getImportedKeys(table.getTableCatalog(), table.getTableSchema(), table.getTableName());
68+ ResultSet fkrs = dmd.getImportedKeys(table.tableCatalog, table.tableSchema, table.getTableName());
7169 List<ReferenceColumnResult> list = ReferenceColumnResult.convReferenceColumnResult(fkrs);
7270 for (ReferenceColumnResult rcr : list) {
7371 fkmap.put(rcr.getFkcolumnName(), rcr);
@@ -75,7 +73,7 @@
7573 fkrs.close();
7674
7775 //
78- ResultSet rs = dmd.getColumns(table.getTableCatalog(), table.getTableSchema(), table.getTableName(), null);
76+ ResultSet rs = dmd.getColumns(table.tableCatalog, table.tableSchema, table.getTableName(), null);
7977 while (rs.next()) {
8078 tableColumns.add(new DBObjectTableColumn(rs, pkmap, fkmap));
8179 }
@@ -101,129 +99,69 @@
10199 */
102100 public class DBObjectTableColumn extends DBObject {
103101
104- private String tableCatalog;
105-
106102 /**
107103 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
108104 * の第1要素
109- *
110- * @return
111105 */
112- public String getTableCatalog() {
113- return tableCatalog;
114- }
115-
116- private String tableSchema = "";
106+ public String tableCatalog;
117107
118108 /**
119109 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
120110 * の第2要素
121- *
122- * @return
123111 */
124- public String getTableSchema() {
125- return tableSchema;
126- }
127-
128- private String tableName = "";
112+ public String tableSchema;
129113
130114 /**
131115 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
132116 * の第3要素
133- *
134- * @return
135117 */
136- public String getTableName() {
137- return tableName;
138- }
139-
140- private String columnName = "";
118+ public String tableName = "";
141119
142120 /**
143121 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
144122 * の第4要素
145- *
146- * @return
147123 */
148- public String getColumnName() {
149- return columnName;
150- }
151-
152- private int dataType;
124+ public String columnName = "";
153125
154126 /**
155127 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
156128 * の第5要素
157- *
158- * @return
159129 */
160- public int getDataType() {
161- return dataType;
162- }
163-
164- private String typeName = "";
130+ public int dataType;
165131
166132 /**
167133 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
168134 * の第6要素
169- *
170- * @return
171135 */
172- public String getTypeName() {
173- return typeName;
174- }
175-
176- private int columnSize;
136+ public String typeName = "";
177137
178138 /**
179139 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
180140 * の第7要素
181- *
182- * @return
183141 */
184- public int getColumnSize() {
185- return columnSize;
186- }
142+ public int columnSize;
187143
188144 // - BUFFER_LENGTH;
189145
190- private int decimalDigits;
191-
192146 /**
193147 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
194148 * の第9要素
195- *
196- * @return
197149 */
198- public int getDecimalDigits() {
199- return decimalDigits;
200- }
201-
202- private int numPrecRadix;
150+ public int decimalDigits;
203151
204152 /**
205153 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
206154 * の第10要素
207- *
208- * @return
209155 */
210- public int getNumPrecRadix() {
211- return numPrecRadix;
212- }
213-
214- private int nullable;
156+ public int numPrecRadix;
215157
216158 /**
217159 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
218160 * の第11要素
219- *
220- * @return
221161 */
222- public int getNullable() {
223- return nullable;
224- }
162+ public int nullable;
225163
226- public String getNullableName() {
164+ private String getNullableName() {
227165 switch (nullable) {
228166 case DatabaseMetaData.columnNoNulls:
229167 return "NoNulls";
@@ -235,96 +173,50 @@
235173 return "?";
236174 }
237175
238- private String remarks;
239- private StringBuilder attr;
240-
241176 /**
242177 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
243178 * の第12要素
244- *
245- * @return
246179 */
247- public String getRemarks() {
248- if (remarks == null) {
249- return "";
250- }
251- return remarks;
252- }
253-
254- private String columnDef = "";
180+ public String remarks;
255181
256182 /**
257183 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
258184 * の第13要素
259- *
260- * @return
261185 */
262- public String getColumnDef() {
263- return columnDef;
264- }
186+ public String columnDef;
265187
266188
267- private int charOctetLength;
268189
269190 /**
270191 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
271192 * の第16要素
272- *
273- * @return
274193 */
275- public int getCharOctetLength() {
276- return charOctetLength;
277- }
194+ public int charOctetLength;
278195
279- private int ordinalPosition;
280196
281197 /**
282198 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
283199 * の第17要素
284- *
285- * @return
286200 */
287- public int getOrdinalPosition() {
288- return ordinalPosition;
289- }
290-
291- private String isNullable = "";
201+ public int ordinalPosition;
292202
293203 /**
294204 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
295205 * の第18要素
296- *
297- * @return
298206 */
299- public String getIsNullable() {
300- return isNullable;
301- }
302-
303- private String scopeCatalog = "";
207+ public String isNullable = "";
304208
305209 /**
306210 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
307211 * の第19要素
308- *
309- * @return
310212 */
311- public String getScopeCatalog() {
312- return scopeCatalog;
313- }
314-
315- private String scopeSchema = "";
213+ public String scopeCatalog = "";
316214
317215 /**
318216 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
319217 * の第20要素
320- *
321- * @return
322218 */
323- public String getScopeSchema() {
324- return scopeSchema;
325- }
326-
327- private String scopeTable = "";
219+ public String scopeSchema = "";
328220
329221 /**
330222 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
@@ -332,33 +224,19 @@
332224 *
333225 * @return
334226 */
335- public String getScopeTable() {
336- return scopeTable;
337- }
338-
339- private short sourceDataType;
227+ public String scopeTable = "";
340228
341229 /**
342230 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
343231 * の第22要素
344- *
345- * @return
346232 */
347- public short getSourceDataType() {
348- return sourceDataType;
349- }
350-
351- private String isAutoincrement = "";
233+ public short sourceDataType;
352234
353235 /**
354236 * {@link DatabaseMetaData#getColumns(String, String, String, String)}
355237 * の第23要素
356- *
357- * @return
358238 */
359- public String getIsAutoincrement() {
360- return isAutoincrement;
361- }
239+ public String isAutoincrement = "";
362240
363241 /**
364242 * {@link DatabaseMetaData#getPrimaryKeys(String, String, String)}
@@ -383,11 +261,13 @@
383261 return "";
384262 }
385263
386- private Short primaryKeySeqNo;
264+ private final StringBuilder attr;
387265
388- private ReferenceColumnResult forginKey;
266+ private final Short primaryKeySeqNo;
389267
390- private List<Property> properties = new ArrayList<Property>();
268+ private final ReferenceColumnResult forginKey;
269+
270+ private final List<Property> properties = new ArrayList<Property>();
391271
392272 @Override
393273 public List<Property> getProperties() {
@@ -401,7 +281,7 @@
401281 * @throws SQLException
402282 */
403283 public DBObjectTableColumn(ResultSet rs, Map<String, Short> pkmap, Map<String, ReferenceColumnResult> fkmap)
404- throws SQLException {
284+ throws SQLException {
405285 int colCnt = rs.getMetaData().getColumnCount();
406286 int i = 0;
407287 try {
@@ -436,7 +316,7 @@
436316 }
437317 if (colCnt > i) {
438318 ++i;
439- /* BUFFER_LENGTH */
319+ /* BUFFER_LENGTH */
440320
441321 }
442322 if (colCnt > i) {
@@ -462,7 +342,7 @@
462342 }
463343 if (colCnt > i) {
464344 ++i;
465- /* sqlDataType */
345+ /* sqlDataType */
466346 /*
467347 * properties.add(new
468348 * Property("SQL_DATA_TYPE",Integer.toString(sqlDataType)));
@@ -470,7 +350,7 @@
470350 }
471351 if (colCnt > i) {
472352 ++i;
473- /* sqlDatetimeSub */
353+ /* sqlDatetimeSub */
474354 /*
475355 * properties.add(new
476356 * Property("SQL_DATETIME_SUB",Integer.toString
@@ -525,18 +405,8 @@
525405 properties.add(new Property("forginKey", getForginKey()));
526406
527407 //
528- attr = new StringBuilder();
529- ConstSqlTypes constSqlTypes = ConstSqlTypes.searchTypes(dataType);
530- attr.append(constSqlTypes.name());
531- attr.append('(');
532- attr.append(columnSize);
533- if (constSqlTypes.getCategoly() == Categoly.NUM) {
534- if (decimalDigits != 0) {
535- attr.append('.');
536- attr.append(decimalDigits);
537- }
538- }
539- attr.append(')');
408+ attr = editAttrString(dataType, columnSize, decimalDigits);
409+
540410 }
541411
542412 /*
@@ -620,7 +490,7 @@
620490
621491 @Override
622492 public String getProperty2() {
623- return getRemarks();
493+ return remarks;
624494 }
625495
626496 @Override
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectTableTypes.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectTableTypes.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectTableTypes.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -37,10 +37,10 @@
3737 public class DBObjectTableTypes extends DBObjects {
3838
3939
40- private ArrayList<DBObjectTableType> tableTypes = new ArrayList<DBObjectTableType>();
40+ private final ArrayList<DBObjectTableType> tableTypes = new ArrayList<DBObjectTableType>();
4141
42- private DBObjectCatalog dbCatalog;
43- private DBObjectSchema dbObjectSchema;
42+ private final DBObjectCatalog dbCatalog;
43+ private final DBObjectSchema dbObjectSchema;
4444
4545 /**
4646 * コンストラクタ
@@ -50,7 +50,7 @@
5050 * @throws SQLException
5151 */
5252 public DBObjectTableTypes(DBObjectCatalog catalog, DBObjectSchema schema, DatabaseMetaData dmd)
53- throws SQLException {
53+ throws SQLException {
5454 dbCatalog = catalog;
5555 dbObjectSchema = schema;
5656
@@ -90,8 +90,6 @@
9090 */
9191 public class DBObjectTableType extends DBObject {
9292
93- private String tableTypeName;
94-
9593 public DBObjectTableType(String typeName) {
9694 tableTypeName = typeName;
9795 }
@@ -109,7 +107,7 @@
109107 }
110108 }
111109
112- private List<Property> properties = new ArrayList<Property>();
110+ private final List<Property> properties = new ArrayList<Property>();
113111
114112 @Override
115113 public List<Property> getProperties() {
@@ -117,13 +115,9 @@
117115 }
118116
119117 /**
120- * テーブルタイプ名
121- *
122- * @return {@link DatabaseMetaData#getTableTypes}の第1要素
118+ * テーブルタイプ名 {@link DatabaseMetaData#getTableTypes}の第1要素
123119 */
124- public String getTableTypeName() {
125- return tableTypeName;
126- }
120+ public String tableTypeName;
127121
128122 /*
129123 * (非 Javadoc)
diff -r e669d305514b -r ab92438e0436 src/jdbcacsess2/sqlService/dbobject/DBObjectTables.java
--- a/src/jdbcacsess2/sqlService/dbobject/DBObjectTables.java Sun Feb 19 21:33:45 2012 +0900
+++ b/src/jdbcacsess2/sqlService/dbobject/DBObjectTables.java Mon Feb 27 01:12:08 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -38,12 +38,12 @@
3838 */
3939 public class DBObjectTables extends DBObjects {
4040
41- private ArrayList<DBObject> tables = new ArrayList<DBObject>();
41+ private final ArrayList<DBObjectTable> tables = new ArrayList<DBObjectTable>();
4242
43- private boolean storesLowerCaseIdentifiers;
44- private boolean storesUpperCaseQuotedIdentifiers;
43+ private final boolean storesLowerCaseIdentifiers;
44+ private final boolean storesUpperCaseQuotedIdentifiers;
4545
46- private DBObjectTableType dbObTableType;
46+ private final DBObjectTableType dbObTableType;
4747
4848 /**
4949 * コンストラクタ
@@ -54,7 +54,7 @@
5454 * @throws SQLException
5555 */
5656 public DBObjectTables(DBObjectCatalog catalog, DBObjectSchema schema, DBObjectTableType tableType,
57- DatabaseMetaData dmd) throws SQLException {
57+ DatabaseMetaData dmd) throws SQLException {
5858
5959 storesLowerCaseIdentifiers = dmd.storesLowerCaseIdentifiers();
6060 storesUpperCaseQuotedIdentifiers = dmd.storesUpperCaseQuotedIdentifiers();
@@ -62,37 +62,30 @@
6262 dbObTableType = tableType;
6363
6464 String[] type = new String[1];
65- type[0] = tableType.getTableTypeName();
65+ type[0] = tableType.tableTypeName;
6666 ResultSet rs;
6767
6868 String catalogName = null;
6969 if (catalog != null) {
70- catalogName = catalog.getCatalogName();
70+ catalogName = catalog.catalogName;
7171 }
7272
7373 String schemaName = null;
7474 if (schema != null) {
75- schemaName = schema.getSchemaName();
75+ schemaName = schema.schemaName;
7676 }
7777
7878 rs = dmd.getTables(catalogName, schemaName, null, type);
7979 while (rs.next()) {
80- DBObjectTable e = new DBObjectTable(rs);
80+ DBObjectTable e = new DBObjectTable(rs, dmd);
8181 tables.add(e);
8282
83- ResultSet exportedKeys = dmd.getExportedKeys(catalogName, schemaName, e.tableName);
84- List<ReferenceColumnResult> rcr = ReferenceColumnResult.convReferenceColumnResult(exportedKeys);
85- if (rcr.size() != 0) {
86- Jdbcacsess2.logger.fine(rcr.toString());
87- }
88- exportedKeys.close();
89- e.setExportedKey(rcr);
9083 }
9184 rs.close();
9285 }
9386
9487 @Override
95- public ArrayList<DBObject> getDBObjects() {
88+ public ArrayList<DBObjectTable> getDBObjects() {
9689 return tables;
9790 }
9891
@@ -109,40 +102,24 @@
109102 */
110103 public class DBObjectTable extends DBObject {
111104
112- private List<ReferenceColumnResult> exportedKey;
113-
114- void setExportedKey(List<ReferenceColumnResult> rcr) {
115- exportedKey = rcr;
116- }
105+ private final List<ReferenceColumnResult> exportedKey;
117106
118107 public List<ReferenceColumnResult> getExportedKey() {
119108 return exportedKey;
120109 }
121110
122111
123- private String tableCatalog;
124-
125112 /**
126113 * {@link DatabaseMetaData#getTables(String, String, String, String[])}
127114 * の第1要素
128- *
129- * @return
130115 */
131- public String getTableCatalog() {
132- return tableCatalog;
133- }
134-
135- private String tableSchema;
116+ public String tableCatalog;
136117
137118 /**
138119 * {@link DatabaseMetaData#getTables(String, String, String, String[])}
139120 * の第2要素
140- *
141- * @return
142121 */
143- public String getTableSchema() {
144- return tableSchema;
145- }
122+ public String tableSchema;
146123
147124 private String tableName;
148125
@@ -243,7 +220,7 @@
243220 return refGeneration;
244221 }
245222
246- private List<Property> properties = new ArrayList<Property>();
223+ private final List<Property> properties = new ArrayList<Property>();
247224
248225 @Override
249226 public List<Property> getProperties() {
@@ -255,8 +232,8 @@
255232 * @param rs
256233 * @throws SQLException
257234 */
258- public DBObjectTable(ResultSet rs) throws SQLException {
259-
235+ public DBObjectTable(ResultSet rs, DatabaseMetaData dmd) throws SQLException {
236+
260237 int colCnt = rs.getMetaData().getColumnCount();
261238 int i = 0;
262239 if (colCnt > i) {
@@ -299,6 +276,14 @@
299276 refGeneration = rs.getString(++i);
300277 properties.add(new Property("REF_GENERATION", refGeneration));
301278 }
279+
280+ ResultSet exportedKeys = dmd.getExportedKeys(tableCatalog, tableSchema, tableName);
281+ List<ReferenceColumnResult> rcr = ReferenceColumnResult.convReferenceColumnResult(exportedKeys);
282+ if (rcr.size() != 0) {
283+ Jdbcacsess2.logger.fine(rcr.toString());
284+ }
285+ exportedKeys.close();
286+ exportedKey = rcr;
302287 }
303288
304289 /*
@@ -352,11 +337,11 @@
352337 */
353338 @Override
354339 public Icon getIconImage() {
355- if (dbObTableType.getTableTypeName().indexOf("TABLE") != -1
356- || dbObTableType.getTableTypeName().indexOf("table") != -1) {
340+ if (dbObTableType.tableTypeName.indexOf("TABLE") != -1
341+ || dbObTableType.tableTypeName.indexOf("table") != -1) {
357342 return DbObjectIconImage.TABLE.getValue();
358343 }
359- if (dbObTableType.getTableTypeName().equals("VIEW")) {
344+ if (dbObTableType.tableTypeName.equals("VIEW")) {
360345 return DbObjectIconImage.VIEW.getValue();
361346 }
362347 return DbObjectIconImage.TABLETYPE.getValue();
Show on old repository browser