Source Code Cross Referenced for XMLCategoryDataset.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 java.util.List;
023:
024:        import java.io.IOException;
025:        import java.io.InputStream;
026:        import java.net.MalformedURLException;
027:        import java.net.URL;
028:        import java.util.ArrayList;
029:        import java.util.Vector;
030:
031:        import javax.portlet.PortletException;
032:        import javax.xml.parsers.DocumentBuilder;
033:        import javax.xml.parsers.DocumentBuilderFactory;
034:        import javax.xml.parsers.ParserConfigurationException;
035:
036:        import com.nabhinc.util.StringUtil;
037:        import com.nabhinc.util.XMLUtil;
038:
039:        import org.w3c.dom.Document;
040:        import org.w3c.dom.Element;
041:        import org.xml.sax.InputSource;
042:        import org.xml.sax.SAXException;
043:
044:        import org.jfree.data.CategoryDataset;
045:        import org.jfree.data.DefaultKeyedValues2D;
046:
047:        /**
048:         * 
049:         *
050:         * @author Padmanabh Dabke
051:         * (c) 2002, 2003 Nabh Information Systems, Inc. All Rights Reserved.
052:         */
053:        public class XMLCategoryDataset extends BaseXMLDataset implements 
054:                CategoryDataset {
055:
056:            private static final long serialVersionUID = 2285053009607685916L;
057:
058:            private String[] xcdsCategoryArray = null;
059:            private DefaultKeyedValues2D xcds2DData = new DefaultKeyedValues2D();
060:
061:            /**
062:             * @see com.nabhinc.portal.charting.BaseJDBCDataSet#executeQuery()
063:             */
064:            public void executeQuery() throws PortletException {
065:                Object xObject = null;
066:                int column = 0;
067:                int currentColumn = 0;
068:                int numberOfColumns = 0;
069:                int numberOfValidColumns = 0;
070:                int columnTypes[] = null;
071:                List categoryNames = new ArrayList();
072:                Vector rows = new Vector();
073:                Number[] newRow;
074:
075:                xcds2DData = new DefaultKeyedValues2D();
076:
077:                try {
078:                    InputStream fis = new URL(bxdsXMLURL).openStream();
079:                    InputSource source = new InputSource(fis);
080:                    DocumentBuilder parser = DocumentBuilderFactory
081:                            .newInstance().newDocumentBuilder();
082:
083:                    Document d = parser.parse(source);
084:                    Element root = d.getDocumentElement();
085:
086:                    String cats = XMLUtil.getSubElementText(root, "categories");
087:                    if (cats != null) {
088:                        xcdsCategoryArray = StringUtil.split(cats, ",");
089:                    }
090:
091:                    Element[] seriesElems = XMLUtil.getSubElements(root,
092:                            "series");
093:
094:                    for (int i = 0; i < seriesElems.length; i++) {
095:                        String seriesName = seriesElems[i].getAttribute("name");
096:                        Element[] valueElems = XMLUtil.getSubElements(
097:                                seriesElems[i], "value");
098:                        for (int j = 0; j < valueElems.length; j++) {
099:                            xcds2DData.setValue(Double.valueOf(XMLUtil
100:                                    .getChildCharacterData(valueElems[j])),
101:                                    seriesName, xcdsCategoryArray[j]);
102:                        }
103:                    }
104:                } catch (MalformedURLException mue) {
105:                    throw new PortletException("Invalid XML document URL: "
106:                            + bxdsXMLURL + ".", mue);
107:                } catch (ParserConfigurationException pce) {
108:                    throw new PortletException("Bad XML parser configuration.",
109:                            pce);
110:                } catch (IOException ioe) {
111:                    throw new PortletException("IO exception.", ioe);
112:                } catch (SAXException se) {
113:                    throw new PortletException("SAX exception.", se);
114:                }
115:
116:            }
117:
118:            /**
119:             * @see com.nabhinc.portal.charting.BaseJDBCDataSet#createDummyData()
120:             */
121:            public void createDummyData() {
122:
123:                if (xcds2DData == null) {
124:                    xcds2DData = new DefaultKeyedValues2D();
125:
126:                    xcdsCategoryArray = new String[] { "mon", "tue", "wed",
127:                            "thu", "fri", "sat", "sun" };
128:                    String[] xcdsSeriesArray = new String[] { "test1.jsp",
129:                            "test2.jsp", "test3.jsp", "test4.jsp" };
130:
131:                    for (int i = 0; i < xcdsCategoryArray.length; i++) {
132:                        int lastY = (int) (Math.random() * 1000 + 1000);
133:                        for (int j = 0; j < xcdsSeriesArray.length; j++) {
134:                            final int y = lastY
135:                                    + (int) (Math.random() * 200 - 100);
136:                            lastY = y;
137:                            xcds2DData.setValue(new Integer(y),
138:                                    xcdsSeriesArray[j], xcdsCategoryArray[i]);
139:                        }
140:                    }
141:                }
142:
143:            }
144:
145:            /* (non-Javadoc)
146:             * @see org.jfree.data.KeyedValues2D#getRowKey(int)
147:             */
148:            public Comparable getRowKey(int arg0) {
149:                return xcds2DData.getRowKey(arg0);
150:            }
151:
152:            /* (non-Javadoc)
153:             * @see org.jfree.data.KeyedValues2D#getRowIndex(java.lang.Comparable)
154:             */
155:            public int getRowIndex(Comparable arg0) {
156:                return xcds2DData.getRowIndex(arg0);
157:            }
158:
159:            /* (non-Javadoc)
160:             * @see org.jfree.data.KeyedValues2D#getRowKeys()
161:             */
162:            public List getRowKeys() {
163:                return xcds2DData.getRowKeys();
164:            }
165:
166:            /* (non-Javadoc)
167:             * @see org.jfree.data.KeyedValues2D#getColumnKey(int)
168:             */
169:            public Comparable getColumnKey(int arg0) {
170:                return xcds2DData.getColumnKey(arg0);
171:            }
172:
173:            /* (non-Javadoc)
174:             * @see org.jfree.data.KeyedValues2D#getColumnIndex(java.lang.Comparable)
175:             */
176:            public int getColumnIndex(Comparable arg0) {
177:                return xcds2DData.getColumnIndex(arg0);
178:            }
179:
180:            /* (non-Javadoc)
181:             * @see org.jfree.data.KeyedValues2D#getColumnKeys()
182:             */
183:            public List getColumnKeys() {
184:                return xcds2DData.getColumnKeys();
185:            }
186:
187:            /* (non-Javadoc)
188:             * @see org.jfree.data.KeyedValues2D#getValue(java.lang.Comparable, java.lang.Comparable)
189:             */
190:            public Number getValue(Comparable arg0, Comparable arg1) {
191:                return xcds2DData.getValue(arg0, arg1);
192:            }
193:
194:            /* (non-Javadoc)
195:             * @see org.jfree.data.Values2D#getRowCount()
196:             */
197:            public int getRowCount() {
198:                return xcds2DData.getRowCount();
199:            }
200:
201:            /* (non-Javadoc)
202:             * @see org.jfree.data.Values2D#getColumnCount()
203:             */
204:            public int getColumnCount() {
205:                return xcds2DData.getColumnCount();
206:            }
207:
208:            /* (non-Javadoc)
209:             * @see org.jfree.data.Values2D#getValue(int, int)
210:             */
211:            public Number getValue(int arg0, int arg1) {
212:                return xcds2DData.getValue(arg0, arg1);
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.