1 28 package net.sf.jasperreports.engine.fill; 29 30 import net.sf.jasperreports.engine.JRRuntimeException; 31 import net.sf.jasperreports.engine.JRSubreportReturnValue; 32 import net.sf.jasperreports.engine.JRVariable; 33 import net.sf.jasperreports.engine.util.JRClassLoader; 34 35 36 43 public class JRFillSubreportReturnValue implements JRSubreportReturnValue 44 { 45 protected final JRSubreportReturnValue parent; 46 47 protected JRIncrementer incrementer = null; 48 49 protected final JRBaseFiller filler; 50 51 52 protected JRFillSubreportReturnValue( 53 JRSubreportReturnValue returnValue, 54 JRFillObjectFactory factory, JRBaseFiller filler 55 ) 56 { 57 factory.put(returnValue, this); 58 59 parent = returnValue; 60 61 this.filler = filler; 62 } 63 64 public String getSubreportVariable() 65 { 66 return parent.getSubreportVariable(); 67 } 68 69 public String getToVariable() 70 { 71 return parent.getToVariable(); 72 } 73 74 public String getIncrementerFactoryClassName() 75 { 76 return parent.getIncrementerFactoryClassName(); 77 } 78 79 public byte getCalculation() 80 { 81 return parent.getCalculation(); 82 } 83 84 85 88 public JRIncrementer getIncrementer() 89 { 90 if (incrementer == null) 91 { 92 String incrementerFactoryClassName = getIncrementerFactoryClassName(); 93 94 JRIncrementerFactory incrementerFactory; 95 if (incrementerFactoryClassName == null) 96 { 97 JRVariable toVariable = filler.getVariable(getToVariable()); 98 incrementerFactory = JRDefaultIncrementerFactory.getFactory(toVariable.getValueClass()); 99 } 100 else 101 { 102 try 103 { 104 Class incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName); 105 incrementerFactory = JRIncrementerFactoryCache.getInstance(incrementerFactoryClass); 106 } 107 catch (ClassNotFoundException e) 108 { 109 throw new JRRuntimeException("Increment class " + incrementerFactoryClassName + " not found.", e); 110 } 111 } 112 113 incrementer = incrementerFactory.getIncrementer(getCalculation()); 114 } 115 116 return incrementer; 117 } 118 } 119 | Popular Tags |