1 58 package org.krysalis.barcode.webapp; 59 60 import org.krysalis.barcode.servlet.BarcodeServlet; 61 import org.krysalis.barcode.tools.MimeTypes; 62 63 68 public class BarcodeRequestBean { 69 70 private String type; 71 private String msg; 72 private String height; 73 private String moduleWidth; 74 private String wideFactor; 75 private String quietZone; 76 private String humanReadable; 77 private String format; 78 private String resolution; 79 private boolean gray; 80 81 public String getType() { 82 return type; 83 } 84 85 public void setType(String string) { 86 type = string; 87 } 88 89 public String getHeight() { 90 return height; 91 } 92 93 public void setHeight(String string) { 94 height = string; 95 } 96 97 public String getMsg() { 98 return msg; 99 } 100 101 public void setMsg(String string) { 102 msg = string; 103 } 104 105 public String getModuleWidth() { 106 return moduleWidth; 107 } 108 109 public void setModuleWidth(String string) { 110 moduleWidth = string; 111 } 112 113 public String getWideFactor() { 114 return wideFactor; 115 } 116 117 public void setWideFactor(String string) { 118 wideFactor = string; 119 } 120 121 public String getQuietZone() { 122 return quietZone; 123 } 124 125 public void setQuietZone(String string) { 126 quietZone = string; 127 } 128 129 public String getHumanReadable() { 130 if ("[default]".equals(humanReadable)) { 131 return null; 132 } else { 133 return humanReadable; 134 } 135 } 136 137 public void setHumanReadable(String string) { 138 humanReadable = string; 139 } 140 141 public String getFormat() { 142 return this.format; 143 } 144 145 public boolean isSVG() { 146 return MimeTypes.MIME_SVG.equals(MimeTypes.expandFormat(getFormat())) 147 || (getFormat() == null) 148 || (getFormat().length() == 0); 149 } 150 151 public boolean isBitmap() { 152 return MimeTypes.isBitmapFormat(getFormat()); 153 } 154 155 public void setFormat(String string) { 156 this.format = string; 157 } 158 159 public String getResolution() { 160 return this.resolution; 161 } 162 163 public void setResolution(String string) { 164 this.resolution = string; 165 } 166 167 public boolean isGray() { 168 return this.gray; 169 } 170 171 public void setGray(boolean value) { 172 this.gray = value; 173 } 174 175 public String toURL() { 176 StringBuffer sb = new StringBuffer (64); 177 sb.append("genbc?"); 178 179 String type = getType(); 181 if (type == null) { 182 type = "code128"; 183 } 184 sb.append(BarcodeServlet.BARCODE_TYPE); 185 sb.append("="); 186 sb.append(type); 187 188 String msg = getMsg(); 190 if (msg == null) { 191 msg = "123456"; 192 } 193 sb.append("&"); 194 sb.append(BarcodeServlet.BARCODE_MSG); 195 sb.append("="); 196 sb.append(java.net.URLEncoder.encode(msg)); 197 199 String height = getHeight(); 201 if (height != null) { 202 sb.append("&"); 203 sb.append(BarcodeServlet.BARCODE_HEIGHT); 204 sb.append("="); 205 sb.append(height); 206 } 207 208 String moduleWidth = getModuleWidth(); 210 if (moduleWidth != null) { 211 sb.append("&"); 212 sb.append(BarcodeServlet.BARCODE_MODULE_WIDTH); 213 sb.append("="); 214 sb.append(moduleWidth); 215 } 216 217 String wideFactor = getWideFactor(); 219 if (wideFactor != null) { 220 sb.append("&"); 221 sb.append(BarcodeServlet.BARCODE_WIDE_FACTOR); 222 sb.append("="); 223 sb.append(wideFactor); 224 } 225 226 String quietZone = getQuietZone(); 228 if (quietZone != null) { 229 sb.append("&"); 230 sb.append(BarcodeServlet.BARCODE_QUIET_ZONE); 231 sb.append("="); 232 sb.append(quietZone); 233 } 234 235 String humanReadable = getHumanReadable(); 237 if (humanReadable != null) { 238 sb.append("&"); 239 sb.append(BarcodeServlet.BARCODE_HUMAN_READABLE_POS); 240 sb.append("="); 241 sb.append(humanReadable); 242 } 243 244 String fmt = getFormat(); 246 if (fmt != null && !isSVG()) { 247 sb.append("&"); 248 sb.append(BarcodeServlet.BARCODE_FORMAT); 249 sb.append("="); 250 sb.append(fmt); 251 } 252 253 String res = getResolution(); 255 if (res != null && isBitmap()) { 256 sb.append("&"); 257 sb.append(BarcodeServlet.BARCODE_IMAGE_RESOLUTION); 258 sb.append("="); 259 sb.append(res); 260 } 261 262 boolean gray = isGray(); 264 if (gray && isBitmap()) { 265 sb.append("&"); 266 sb.append(BarcodeServlet.BARCODE_IMAGE_GRAYSCALE); 267 sb.append("="); 268 sb.append((isGray() ? "true" : "false")); 269 } 270 271 return sb.toString(); 272 } 273 274 } 275 | Popular Tags |