1 47 48 package org.jfree.chart.urls; 49 50 import java.io.Serializable ; 51 52 import org.jfree.data.xy.XYDataset; 53 import org.jfree.util.ObjectUtilities; 54 55 60 public class StandardXYURLGenerator implements XYURLGenerator, Serializable { 61 62 63 private static final long serialVersionUID = -1771624523496595382L; 64 65 66 public static final String DEFAULT_PREFIX = "index.html"; 67 68 69 public static final String DEFAULT_SERIES_PARAMETER = "series"; 70 71 72 public static final String DEFAULT_ITEM_PARAMETER = "item"; 73 74 75 private String prefix; 76 77 78 private String seriesParameterName; 79 80 81 private String itemParameterName; 82 83 88 public StandardXYURLGenerator() { 89 this(DEFAULT_PREFIX, DEFAULT_SERIES_PARAMETER, DEFAULT_ITEM_PARAMETER); 90 } 91 92 99 public StandardXYURLGenerator(String prefix) { 100 this(prefix, DEFAULT_SERIES_PARAMETER, DEFAULT_ITEM_PARAMETER); 101 } 102 103 112 public StandardXYURLGenerator(String prefix, 113 String seriesParameterName, 114 String itemParameterName) { 115 if (prefix == null) { 116 throw new IllegalArgumentException ("Null 'prefix' argument."); 117 } 118 if (seriesParameterName == null) { 119 throw new IllegalArgumentException ( 120 "Null 'seriesParameterName' argument." 121 ); 122 } 123 if (itemParameterName == null) { 124 throw new IllegalArgumentException ( 125 "Null 'itemParameterName' argument." 126 ); 127 } 128 this.prefix = prefix; 129 this.seriesParameterName = seriesParameterName; 130 this.itemParameterName = itemParameterName; 131 } 132 133 142 public String generateURL(XYDataset dataset, int series, int item) { 143 String url = this.prefix; 144 boolean firstParameter = url.indexOf("?") == -1; 145 url += firstParameter ? "?" : "&"; 146 url += this.seriesParameterName + "=" + series 147 + "&" + this.itemParameterName + "=" + item; 148 return url; 149 } 150 151 158 public boolean equals(Object obj) { 159 if (obj == this) { 160 return true; 161 } 162 if (!(obj instanceof StandardXYURLGenerator)) { 163 return false; 164 } 165 StandardXYURLGenerator that = (StandardXYURLGenerator) obj; 166 if (!ObjectUtilities.equal(that.prefix, this.prefix)) { 167 return false; 168 } 169 if (!ObjectUtilities.equal(that.seriesParameterName, 170 this.seriesParameterName)) { 171 return false; 172 } 173 if (!ObjectUtilities.equal(that.itemParameterName, 174 this.itemParameterName)) { 175 return false; 176 } 177 return true; 178 } 179 180 } 181 | Popular Tags |