1 48 49 package org.jfree.chart.urls; 50 51 import java.io.Serializable ; 52 53 import org.jfree.data.general.PieDataset; 54 55 60 public class StandardPieURLGenerator implements PieURLGenerator, Serializable { 61 62 63 private static final long serialVersionUID = 1626966402065883419L; 64 65 66 private String prefix = "index.html"; 67 68 69 private String categoryParameterName = "category"; 70 71 72 private String indexParameterName = "pieIndex"; 73 74 77 public StandardPieURLGenerator() { 78 super(); 79 } 80 81 86 public StandardPieURLGenerator(String prefix) { 87 this.prefix = prefix; 88 } 89 90 96 public StandardPieURLGenerator(String prefix, 97 String categoryParameterName) { 98 this.prefix = prefix; 99 this.categoryParameterName = categoryParameterName; 100 } 101 102 110 public StandardPieURLGenerator(String prefix, 111 String categoryParameterName, 112 String indexParameterName) { 113 this.prefix = prefix; 114 this.categoryParameterName = categoryParameterName; 115 this.indexParameterName = indexParameterName; 116 } 117 118 127 public String generateURL(PieDataset data, Comparable key, int pieIndex) { 128 129 String url = this.prefix; 130 if (url.indexOf("?") > -1) { 131 url += "&" + this.categoryParameterName + "=" + key.toString(); 132 } 133 else { 134 url += "?" + this.categoryParameterName + "=" + key.toString(); 135 } 136 if (this.indexParameterName != null) { 137 url += "&" + this.indexParameterName + "=" 138 + String.valueOf(pieIndex); 139 } 140 return url; 141 142 } 143 144 151 public boolean equals(Object obj) { 152 153 if (obj == null) { 154 return false; 155 } 156 if (obj == this) { 157 return true; 158 } 159 160 if ((obj instanceof StandardPieURLGenerator) == false) { 161 return false; 162 } 163 164 StandardPieURLGenerator generator = (StandardPieURLGenerator) obj; 165 return ( 166 this.categoryParameterName.equals(generator.categoryParameterName)) 167 && (this.prefix.equals(generator.prefix) 168 ); 169 170 } 171 } 172 | Popular Tags |