01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * Created Dec 27, 2006
14: * @author mdamour
15: */
16:
17: package org.pentaho.data.connection.hql;
18:
19: import java.util.List;
20:
21: import org.hibernate.type.Type;
22: import org.pentaho.commons.connection.AbstractPentahoMetaData;
23:
24: /**
25: * @author mdamour
26: *
27: * TODO To change the template for this generated type comment go to Window -
28: * Preferences - Java - Code Style - Code Templates
29: */
30: public class HQLMetaData extends AbstractPentahoMetaData {
31: private Object[][] columnHeaders;
32:
33: private HQLResultSet resultSet;
34:
35: private String columnNames[];
36:
37: // private Type columnTypes[];
38:
39: public HQLMetaData(List data, HQLResultSet resultSet,
40: String[] columnNames, Type colummTypes[]) {
41: this .resultSet = resultSet;
42: this .columnNames = columnNames;
43: // this.columnTypes = colummTypes;
44: getColumnHeaders();
45: }
46:
47: /*
48: * (non-Javadoc)
49: *
50: * @see org.pentaho.connection.IPentahoMetaData#getColumnHeaders()
51: *
52: * In the case of HQL data there is only 1 row
53: */
54: public Object[][] getColumnHeaders() {
55: if (columnHeaders == null) {
56: try {
57: int rowCount = 1;
58: int columnCount = resultSet.getColumnCount();
59: Object[][] result = new Object[rowCount][columnCount];
60: for (int column = 0; column < columnCount; column++) {
61: try {
62: result[0][column] = columnNames[column];
63: } catch (Exception e) {
64: }
65: }
66: this .columnHeaders = result;
67: } catch (Exception e) {
68: // TODO Auto-generated catch block
69: e.printStackTrace();
70: }
71: }
72: return columnHeaders;
73: }
74:
75: public int getColumnCount() {
76: try {
77: return resultSet.getColumnCount();
78: } catch (Exception ex) {
79: ex.printStackTrace();
80: }
81: // TODO: Ripple the exception out of this package
82: return -1;
83: }
84:
85: public Object[][] getRowHeaders() {
86: return null;
87: }
88: }
|