Source Code Cross Referenced for MDXResultSet.java in  » Report » pentaho-report » org » pentaho » data » connection » mdx » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.pentaho.data.connection.mdx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved. 
003:         * This software was developed by Pentaho Corporation and is provided under the terms 
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
005:         * this file except in compliance with the license. If you need a copy of the license, 
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
011:         * the license for the specific language governing your rights and limitations.
012:         *
013:         * Created Sep 12, 2005 
014:         * @author wseyler
015:         */
016:
017:        package org.pentaho.data.connection.mdx;
018:
019:        import mondrian.olap.Axis;
020:        import mondrian.olap.Connection;
021:        import mondrian.olap.Result;
022:
023:        import org.pentaho.commons.connection.IPentahoMetaData;
024:        import org.pentaho.commons.connection.IPentahoResultSet;
025:        import org.pentaho.commons.connection.memory.MemoryMetaData;
026:        import org.pentaho.commons.connection.memory.MemoryResultSet;
027:
028:        /**
029:         * @author wseyler
030:         * 
031:         * TODO To change the template for this generated type comment go to Window -
032:         * Preferences - Java - Code Style - Code Templates
033:         */
034:        public class MDXResultSet implements  IPentahoResultSet {
035:            private static final int columnAxis = 0;
036:
037:            private static final int rowAxis = 1;
038:
039:            int columnCount = 0;
040:
041:            int rowCount = 0;
042:
043:            Result nativeResultSet;
044:
045:            Connection nativeConnection;
046:
047:            int rowIndex = 0;
048:
049:            MDXMetaData mdxMetaData = null;
050:
051:            /**
052:             * @param result
053:             */
054:            public MDXResultSet(Result nativeResultSet,
055:                    Connection nativeConnection) {
056:                super ();
057:
058:                this .nativeResultSet = nativeResultSet;
059:                this .nativeConnection = nativeConnection;
060:
061:                Axis[] axis = nativeResultSet.getAxes();
062:                if (axis == null || axis.length == 0) {
063:                    columnCount = 0;
064:                    rowCount = 0;
065:                } else if (axis.length == 1) {
066:                    columnCount = axis[columnAxis].getPositions().size();
067:                    rowCount = 0;
068:                } else {
069:                    columnCount = axis[columnAxis].getPositions().size();
070:                    rowCount = axis[rowAxis].getPositions().size();
071:                }
072:
073:                mdxMetaData = new MDXMetaData(this .nativeResultSet);
074:            }
075:
076:            /*
077:             * (non-Javadoc)
078:             * 
079:             * @see org.pentaho.connection.IPentahoResultSet#getMetaData()
080:             */
081:            public IPentahoMetaData getMetaData() {
082:                return mdxMetaData;
083:            }
084:
085:            /*
086:             * (non-Javadoc)
087:             * 
088:             * @see org.pentaho.connection.IPentahoResultSet#next()
089:             */
090:            public Object[] next() {
091:                Object[] result = null;
092:
093:                if (rowIndex < rowCount) {
094:                    result = new Object[columnCount];
095:                    for (int i = 0; i < columnCount; i++) {
096:                        result[i] = getValueAt(rowIndex, i);
097:                    }
098:                    rowIndex++;
099:                }
100:                return result;
101:            }
102:
103:            /*
104:             * (non-Javadoc)
105:             * 
106:             * @see org.pentaho.connection.IPentahoResultSet#close()
107:             */
108:            public void close() {
109:                nativeResultSet.close();
110:            }
111:
112:            /*
113:             * (non-Javadoc)
114:             * 
115:             * @see org.pentaho.connection.IPentahoResultSet#closeConnection()
116:             */
117:            public void closeConnection() {
118:                nativeResultSet.close();
119:                nativeConnection.close();
120:            }
121:
122:            /*
123:             * (non-Javadoc)
124:             * 
125:             * @see org.pentaho.core.runtime.IDisposable#dispose()
126:             */
127:            public void dispose() {
128:                closeConnection();
129:            }
130:
131:            /*
132:             * (non-Javadoc)
133:             * 
134:             * @see org.pentaho.connection.IPentahoResultSet#isScrollable()
135:             */
136:            public boolean isScrollable() {
137:                // TODO Auto-generated method stub
138:                return false;
139:            }
140:
141:            /*
142:             * (non-Javadoc)
143:             * 
144:             * @see org.pentaho.connection.IPentahoResultSet#getValueAt(int, int)
145:             */
146:            public Object getValueAt(int row, int column) {
147:                int[] key = new int[2];
148:                key[0] = column;
149:                key[1] = row;
150:                return nativeResultSet.getCell(key).getValue();
151:            }
152:
153:            /*
154:             * (non-Javadoc)
155:             * 
156:             * @see org.pentaho.connection.IPentahoResultSet#getRowCount()
157:             */
158:            public int getRowCount() {
159:                return mdxMetaData.getRowHeaders().length;
160:            }
161:
162:            /*
163:             * (non-Javadoc)
164:             * 
165:             * @see org.pentaho.connection.IPentahoResultSet#getColumnCount()
166:             */
167:            public int getColumnCount() {
168:                return mdxMetaData.getColumnCount();
169:            }
170:
171:            public IPentahoResultSet memoryCopy() {
172:                try {
173:                    IPentahoMetaData metadata = getMetaData();
174:                    Object columnHeaders[][] = metadata.getColumnHeaders();
175:                    Object rowHeaders[][] = metadata.getRowHeaders();
176:
177:                    MemoryMetaData cachedMetaData = new MemoryMetaData(
178:                            columnHeaders, rowHeaders);
179:                    MemoryResultSet cachedResultSet = new MemoryResultSet(
180:                            cachedMetaData);
181:
182:                    Object[] rowObjects = next();
183:                    while (rowObjects != null) {
184:                        cachedResultSet.addRow(rowObjects);
185:                        rowObjects = next();
186:                    }
187:                    return cachedResultSet;
188:                } finally {
189:                    close();
190:                }
191:            }
192:
193:            public void beforeFirst() {
194:                rowIndex = 0;
195:            }
196:
197:            public Object[] getDataColumn(int column) {
198:                int oldIndex = rowIndex; // save our current iteration location
199:
200:                beforeFirst();
201:                Object[] result = new Object[getRowCount()];
202:                int index = 0;
203:                Object[] rowData = next();
204:                while (rowData != null) {
205:                    result[index] = rowData[column];
206:                    index++;
207:                    rowData = next();
208:                }
209:
210:                rowIndex = oldIndex; // restore the old iteration location
211:
212:                return result;
213:            }
214:
215:            public Object[] getDataRow(int row) {
216:                int oldIndex = rowIndex; // save our current iteration location
217:
218:                rowIndex = row;
219:                Object[] rowData = next();
220:                rowIndex = oldIndex;
221:
222:                return rowData;
223:            }
224:
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.