1 58 package org.krysalis.barcode; 59 60 import java.util.Map ; 61 62 67 public class DefaultBarcodeClassResolver implements BarcodeClassResolver { 68 69 private Map classes; 70 71 76 public DefaultBarcodeClassResolver() { 77 registerBarcodeClass("codabar", "org.krysalis.barcode.impl.Codabar"); 78 registerBarcodeClass("code39", "org.krysalis.barcode.impl.Code39"); 79 registerBarcodeClass("code128", "org.krysalis.barcode.impl.Code128"); 80 registerBarcodeClass("2of5", "org.krysalis.barcode.impl.Interleaved2Of5"); 81 registerBarcodeClass("intl2of5", "org.krysalis.barcode.impl.Interleaved2Of5"); 82 registerBarcodeClass("interleaved2of5", "org.krysalis.barcode.impl.Interleaved2Of5"); 83 registerBarcodeClass("ean-13", "org.krysalis.barcode.impl.EAN13"); 84 registerBarcodeClass("ean13", "org.krysalis.barcode.impl.EAN13"); 85 registerBarcodeClass("ean-8", "org.krysalis.barcode.impl.EAN8"); 86 registerBarcodeClass("ean8", "org.krysalis.barcode.impl.EAN8"); 87 registerBarcodeClass("upc-a", "org.krysalis.barcode.impl.UPCA"); 88 registerBarcodeClass("upca", "org.krysalis.barcode.impl.UPCA"); 89 registerBarcodeClass("upc-e", "org.krysalis.barcode.impl.UPCE"); 90 registerBarcodeClass("upce", "org.krysalis.barcode.impl.UPCE"); 91 registerBarcodeClass("postnet", "org.krysalis.barcode.impl.POSTNET"); 92 } 93 94 99 public void registerBarcodeClass(String name, String classname) { 100 if (this.classes == null) { 101 this.classes = new java.util.HashMap (); 102 } 103 this.classes.put(name.toLowerCase(), classname); 104 } 105 106 109 public Class resolve(String name) throws ClassNotFoundException { 110 String clazz = null; 111 if (this.classes != null) { 112 clazz = (String )this.classes.get(name.toLowerCase()); 113 } 114 if (clazz == null) { 115 clazz = name; 116 } 117 Class cl = Class.forName(clazz); 118 return cl; 119 } 120 121 } 122 | Popular Tags |