1 28 package net.sf.jasperreports.engine.fill; 29 30 import java.util.HashMap ; 31 import java.util.Map ; 32 33 import net.sf.jasperreports.engine.JRRuntimeException; 34 35 36 40 public class JRIncrementerFactoryCache 41 { 42 43 44 47 private static Map factoriesMap = null; 48 49 50 53 public static synchronized JRIncrementerFactory getInstance(Class factoryClass) 54 { 55 if (factoriesMap == null) 56 { 57 factoriesMap = new HashMap (); 58 } 59 60 JRIncrementerFactory incrementerFactory = (JRIncrementerFactory)factoriesMap.get(factoryClass.getName()); 61 62 if (incrementerFactory == null) 63 { 64 try 65 { 66 incrementerFactory = (JRIncrementerFactory)factoryClass.newInstance(); 67 } 68 catch (InstantiationException e) 69 { 70 throw new JRRuntimeException(e); 71 } 72 catch (IllegalAccessException e) 73 { 74 throw new JRRuntimeException(e); 75 } 76 77 factoriesMap.put(factoryClass.getName(), incrementerFactory); 78 } 79 80 return incrementerFactory; 81 } 82 83 84 } 85 | Popular Tags |