Source Code Cross Referenced for JDBCHighLowDataset.java in  » Portal » stringbeans-3.5 » com » nabhinc » portlet » chart » 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 » Portal » stringbeans 3.5 » com.nabhinc.portlet.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2003 Nabh Information Systems, Inc. 
003:         * 
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:
020:        package com.nabhinc.portlet.chart;
021:
022:        import org.jfree.data.HighLowDataset;
023:
024:        import com.nabhinc.util.db.DBUtil;
025:
026:        import java.sql.Connection;
027:        import java.sql.PreparedStatement;
028:        import java.sql.ResultSet;
029:        import java.util.Vector;
030:
031:        import javax.portlet.PortletException;
032:
033:        /**
034:         * 
035:         *
036:         * @author Padmanabh Dabke
037:         * (c) 2002, 2003 Nabh Information Systems, Inc. All Rights Reserved.
038:         */
039:        public class JDBCHighLowDataset extends BaseJDBCDataset implements 
040:                HighLowDataset {
041:
042:            private static final long serialVersionUID = -6654476935158347558L;
043:
044:            public boolean jhldsDrawVolume = false;
045:            private Vector jhldsDates = null;
046:            private Vector jhldsHigh = null;
047:            private Vector jhldsLow = null;
048:            private Vector jhldsOpen = null;
049:            private Vector jhldsClose = null;
050:            private Vector jhldsVol = null;
051:            private String jhldsSeriesName = null;
052:
053:            /**
054:             * @see com.nabhinc.portal.charting.BaseJDBCDataSet#executeQuery()
055:             */
056:            public void executeQuery() throws PortletException {
057:                Object xObject = null;
058:                int column = 0;
059:                int numberOfColumns = 0;
060:                int numberOfValidColumns = 0;
061:                int columnTypes[] = null;
062:
063:                Connection connection = null;
064:                ResultSet resultSet = null;
065:                PreparedStatement statement = null;
066:                jhldsDates = new Vector();
067:                jhldsHigh = new Vector();
068:                jhldsLow = new Vector();
069:                jhldsOpen = new Vector();
070:                jhldsClose = new Vector();
071:                try {
072:                    connection = DBUtil.getConnection(bjdsDataSource);
073:                    statement = connection.prepareStatement(bjdsSQL);
074:                    resultSet = statement.executeQuery();
075:                    /// might need to add, to free memory from any previous result sets
076:                    Vector points = new Vector();
077:                    while (resultSet.next()) {
078:                        jhldsDates.addElement(resultSet.getDate(1));
079:                        jhldsHigh.addElement(resultSet.getObject(2));
080:                        jhldsLow.addElement(resultSet.getObject(3));
081:                        jhldsOpen.addElement(resultSet.getObject(4));
082:                        jhldsClose.addElement(resultSet.getObject(5));
083:                        if (jhldsDrawVolume) {
084:                            jhldsVol.addElement(resultSet.getObject(6));
085:                        }
086:
087:                    }
088:
089:                    fireDatasetChanged();
090:
091:                } catch (Exception ex) {
092:                    throw new PortletException(
093:                            "Encountered database exception.", ex);
094:                } finally {
095:                    DBUtil.close(resultSet);
096:                    DBUtil.close(statement);
097:                    DBUtil.close(connection);
098:
099:                }
100:            }
101:
102:            /**
103:             * @see com.nabhinc.portal.charting.BaseJDBCDataSet#createDummyData()
104:             */
105:            public void createDummyData() {
106:                jhldsDates = new Vector();
107:                jhldsHigh = new Vector();
108:                jhldsLow = new Vector();
109:                jhldsOpen = new Vector();
110:                jhldsClose = new Vector();
111:            }
112:
113:            /**
114:             * @see org.jfree.data.HighLowDataset#getHighValue(int, int)
115:             */
116:            public Number getHighValue(int series, int item) {
117:                if (jhldsHigh == null) {
118:                    return null;
119:                } else {
120:                    return (Number) jhldsHigh.elementAt(item);
121:                }
122:            }
123:
124:            /**
125:             * @see org.jfree.data.HighLowDataset#getLowValue(int, int)
126:             */
127:            public Number getLowValue(int series, int item) {
128:                if (jhldsLow == null) {
129:                    return null;
130:                } else {
131:                    return (Number) jhldsLow.elementAt(item);
132:                }
133:            }
134:
135:            /**
136:             * @see org.jfree.data.HighLowDataset#getOpenValue(int, int)
137:             */
138:            public Number getOpenValue(int series, int item) {
139:                if (jhldsOpen == null) {
140:                    return null;
141:                } else {
142:                    return (Number) jhldsOpen.elementAt(item);
143:                }
144:            }
145:
146:            /**
147:             * @see org.jfree.data.HighLowDataset#getCloseValue(int, int)
148:             */
149:            public Number getCloseValue(int series, int item) {
150:                if (jhldsClose == null) {
151:                    return null;
152:                } else {
153:                    return (Number) jhldsClose.elementAt(item);
154:                }
155:            }
156:
157:            /**
158:             * @see org.jfree.data.HighLowDataset#getVolumeValue(int, int)
159:             */
160:            public Number getVolumeValue(int series, int item) {
161:                if (jhldsVol == null) {
162:                    return null;
163:                } else {
164:                    return (Number) jhldsVol.elementAt(item);
165:                }
166:            }
167:
168:            /**
169:             * @see org.jfree.data.XYDataset#getItemCount(int)
170:             */
171:            public int getItemCount(int series) {
172:                return jhldsDates.size();
173:            }
174:
175:            /**
176:             * Returns the x-value for one item in a series.
177:             * <p>
178:             * The value returned is a Long object generated from the underlying Date object.
179:             *
180:             * @param series  the series (zero-based index).
181:             * @param item  the item (zero-based index).
182:             *
183:             * @return the x-value.
184:             */
185:            public Number getXValue(int series, int item) {
186:                return new Long(((java.sql.Date) jhldsDates.elementAt(item))
187:                        .getTime());
188:            }
189:
190:            /**
191:             * Returns the y-value for one item in a series.
192:             * <p>
193:             * This method (from the XYDataset interface) is mapped to the getCloseValue(...) method.
194:             *
195:             * @param series  the series (zero-based index).
196:             * @param item  the item (zero-based index).
197:             *
198:             * @return the y-value.
199:             */
200:            public Number getYValue(int series, int item) {
201:                return getCloseValue(series, item);
202:            }
203:
204:            /**
205:             * @see org.jfree.data.SeriesDataset#getSeriesCount()
206:             */
207:            public int getSeriesCount() {
208:                return 1;
209:            }
210:
211:            /**
212:             * @see org.jfree.data.SeriesDataset#getSeriesName(int)
213:             */
214:            public String getSeriesName(int series) {
215:                return jhldsSeriesName;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.