Source Code Cross Referenced for StandardCategoryURLGenerator.java in  » Chart » jfreechart » org » jfree » chart » urls » 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 » Chart » jfreechart » org.jfree.chart.urls 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * ---------------------------------
028:         * StandardCategoryURLGenerator.java
029:         * ---------------------------------
030:         * (C) Copyright 2002-2007, by Richard Atkinson and Contributors.
031:         *
032:         * Original Author:  Richard Atkinson;
033:         * Contributors:     David Gilbert (for Object Refinery Limited);
034:         *                   Cleland Early;
035:         *
036:         * $Id: StandardCategoryURLGenerator.java,v 1.6.2.3 2007/04/17 16:05:27 mungady Exp $
037:         *
038:         * Changes:
039:         * --------
040:         * 05-Aug-2002 : Version 1, contributed by Richard Atkinson;
041:         * 29-Aug-2002 : Reversed seriesParameterName and itemParameterName in 
042:         *               constructor.  Never should have been the other way round.  
043:         *               Also updated JavaDoc (RA);
044:         * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG);
045:         * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG);
046:         * 23-Mar-2003 : Implemented Serializable (DG);
047:         * 13-Aug-2003 : Implemented Cloneable (DG);
048:         * 23-Dec-2003 : Added fix for bug 861282 (DG);
049:         * 21-May-2004 : Added URL encoding - see patch 947854 (DG);
050:         * 13-Jan-2004 : Fixed for compliance with XHTML 1.0 (DG);
051:         * ------------- JFREECHART 1.0.x ---------------------------------------------
052:         * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG);
053:         * 17-Apr-2007 : Use new URLUtilities class to encode URLs (DG);
054:         *
055:         */
056:
057:        package org.jfree.chart.urls;
058:
059:        import java.io.Serializable;
060:
061:        import org.jfree.data.category.CategoryDataset;
062:        import org.jfree.util.ObjectUtilities;
063:
064:        /**
065:         * A URL generator that can be assigned to a 
066:         * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}.
067:         */
068:        public class StandardCategoryURLGenerator implements 
069:                CategoryURLGenerator, Cloneable, Serializable {
070:
071:            /** For serialization. */
072:            private static final long serialVersionUID = 2276668053074881909L;
073:
074:            /** Prefix to the URL */
075:            private String prefix = "index.html";
076:
077:            /** Series parameter name to go in each URL */
078:            private String seriesParameterName = "series";
079:
080:            /** Category parameter name to go in each URL */
081:            private String categoryParameterName = "category";
082:
083:            /**
084:             * Creates a new generator with default settings.
085:             */
086:            public StandardCategoryURLGenerator() {
087:                super ();
088:            }
089:
090:            /**
091:             * Constructor that overrides default prefix to the URL.
092:             *
093:             * @param prefix  the prefix to the URL (<code>null</code> not permitted).
094:             */
095:            public StandardCategoryURLGenerator(String prefix) {
096:                if (prefix == null) {
097:                    throw new IllegalArgumentException(
098:                            "Null 'prefix' argument.");
099:                }
100:                this .prefix = prefix;
101:            }
102:
103:            /**
104:             * Constructor that overrides all the defaults.
105:             *
106:             * @param prefix  the prefix to the URL (<code>null</code> not permitted).
107:             * @param seriesParameterName  the name of the series parameter to go in 
108:             *                             each URL (<code>null</code> not permitted).
109:             * @param categoryParameterName  the name of the category parameter to go in
110:             *                               each URL (<code>null</code> not permitted).
111:             */
112:            public StandardCategoryURLGenerator(String prefix,
113:                    String seriesParameterName, String categoryParameterName) {
114:
115:                if (prefix == null) {
116:                    throw new IllegalArgumentException(
117:                            "Null 'prefix' argument.");
118:                }
119:                if (seriesParameterName == null) {
120:                    throw new IllegalArgumentException(
121:                            "Null 'seriesParameterName' argument.");
122:                }
123:                if (categoryParameterName == null) {
124:                    throw new IllegalArgumentException(
125:                            "Null 'categoryParameterName' argument.");
126:                }
127:                this .prefix = prefix;
128:                this .seriesParameterName = seriesParameterName;
129:                this .categoryParameterName = categoryParameterName;
130:
131:            }
132:
133:            /**
134:             * Generates a URL for a particular item within a series.
135:             *
136:             * @param dataset  the dataset.
137:             * @param series  the series index (zero-based).
138:             * @param category  the category index (zero-based).
139:             *
140:             * @return The generated URL.
141:             */
142:            public String generateURL(CategoryDataset dataset, int series,
143:                    int category) {
144:                String url = this .prefix;
145:                Comparable seriesKey = dataset.getRowKey(series);
146:                Comparable categoryKey = dataset.getColumnKey(category);
147:                boolean firstParameter = url.indexOf("?") == -1;
148:                url += firstParameter ? "?" : "&amp;";
149:                url += this .seriesParameterName + "="
150:                        + URLUtilities.encode(seriesKey.toString(), "UTF-8");
151:                url += "&amp;" + this .categoryParameterName + "="
152:                        + URLUtilities.encode(categoryKey.toString(), "UTF-8");
153:                return url;
154:            }
155:
156:            /**
157:             * Returns an independent copy of the URL generator.
158:             * 
159:             * @return A clone.
160:             * 
161:             * @throws CloneNotSupportedException not thrown by this class, but 
162:             *         subclasses (if any) might.
163:             */
164:            public Object clone() throws CloneNotSupportedException {
165:
166:                // all attributes are immutable, so we can just return the super.clone()
167:                return super .clone();
168:
169:            }
170:
171:            /**
172:             * Tests the generator for equality with an arbitrary object.
173:             *
174:             * @param obj  the object (<code>null</code> permitted).
175:             *
176:             * @return A boolean.
177:             */
178:            public boolean equals(Object obj) {
179:                if (obj == this ) {
180:                    return true;
181:                }
182:                if (!(obj instanceof  StandardCategoryURLGenerator)) {
183:                    return false;
184:                }
185:                StandardCategoryURLGenerator that = (StandardCategoryURLGenerator) obj;
186:                if (!ObjectUtilities.equal(this .prefix, that.prefix)) {
187:                    return false;
188:                }
189:
190:                if (!ObjectUtilities.equal(this .seriesParameterName,
191:                        that.seriesParameterName)) {
192:                    return false;
193:                }
194:                if (!ObjectUtilities.equal(this .categoryParameterName,
195:                        that.categoryParameterName)) {
196:                    return false;
197:                }
198:                return true;
199:            }
200:
201:            /**
202:             * Returns a hash code.
203:             * 
204:             * @return A hash code.
205:             */
206:            public int hashCode() {
207:                int result;
208:                result = (this .prefix != null ? this .prefix.hashCode() : 0);
209:                result = 29
210:                        * result
211:                        + (this .seriesParameterName != null ? this .seriesParameterName
212:                                .hashCode()
213:                                : 0);
214:                result = 29
215:                        * result
216:                        + (this .categoryParameterName != null ? this .categoryParameterName
217:                                .hashCode()
218:                                : 0);
219:                return result;
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.