锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久亚洲精品蜜桃臀,亚洲无人区一区二区三区,国产精品高清视亚洲一区二区http://www.tkk7.com/super/category/6714.htmlzh-cnTue, 27 Feb 2007 21:04:30 GMTTue, 27 Feb 2007 21:04:30 GMT60鍏充簬jasperReport涓槑緇嗚琛ョ┖琛岀殑澶勭悊鏂規硶銆?/title><link>http://www.tkk7.com/super/archive/2006/01/13/27851.html</link><dc:creator>鐜嬪崼鍗?/dc:creator><author>鐜嬪崼鍗?/author><pubDate>Fri, 13 Jan 2006 01:28:00 GMT</pubDate><guid>http://www.tkk7.com/super/archive/2006/01/13/27851.html</guid><wfw:comment>http://www.tkk7.com/super/comments/27851.html</wfw:comment><comments>http://www.tkk7.com/super/archive/2006/01/13/27851.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/super/comments/commentRss/27851.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/super/services/trackbacks/27851.html</trackback:ping><description><![CDATA[<P>1.鐢ㄨ儗鏅浘鐨勬柟娉?緗戜笂鏈夊緢澶氫粙緇嶈繖縐嶆柟寮忕殑錛岃繖閲屽氨涓嶈浜?BR>2.鐢ㄨ嚜瀹氫簬鏁版嵁婧愮殑鏂瑰紡(JRBeanCollectionDataSource),榪欎釜鍔炴硶涓嶉敊錛屼絾鏄瘡涓姤琛ㄩ兘瑕佸畾涔変竴涓暟鎹簮綾伙紝鎴戝珜楹葷儲銆?BR>3.鍙ソ淇敼jasper鐨勬簮浠g爜浜?鎴戜慨鏀逛簡net.sf.jasperreports.engine.fill.JRFillDataset.java,(1.1.1 鐗堢殑),鏀瑰姩鐨勫緢灝戯紝濡備笅鎵紺恒?BR>   瑕嗙洊婧愪唬鐮佸悗錛岄噸鏂扮紪璇戯紝鎵撳寘銆傚湪鎶ヨ〃涓彧瑕佸姞鍏ュ弬鏁癙AGE_MIN_LINE(Integer)=浣犺鐨勮鏁板氨鍙互浜?BR><BR>/*<BR> * ============================================================================<BR> * GNU Lesser General Public License<BR> * ============================================================================<BR> *<BR> * JasperReports - Free Java report-generating library.<BR> * Copyright (C) 2001-2005 JasperSoft Corporation <A >http://www.jaspersoft.com</A><BR> * <BR> * This library is free software; you can redistribute it and/or<BR> * modify it under the terms of the GNU Lesser General Public<BR> * License as published by the Free Software Foundation; either<BR> * version 2.1 of the License, or (at your option) any later version.<BR> * <BR> * This library is distributed in the hope that it will be useful,<BR> * but WITHOUT ANY WARRANTY; without even the implied warranty of<BR> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<BR> * Lesser General Public License for more details.<BR> * <BR> * You should have received a copy of the GNU Lesser General Public<BR> * License along with this library; if not, write to the Free Software<BR> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.<BR> * <BR> * JasperSoft Corporation<BR> * 303 Second Street, Suite 450 North<BR> * San Francisco, CA 94107<BR> * <A >http://www.jaspersoft.com</A><BR> */<BR>package net.sf.jasperreports.engine.fill;</P> <P>import java.sql.Connection;<BR>import java.sql.PreparedStatement;<BR>import java.sql.ResultSet;<BR>import java.sql.SQLException;<BR>import java.util.ArrayList;<BR>import java.util.HashMap;<BR>import java.util.HashSet;<BR>import java.util.List;<BR>import java.util.Locale;<BR>import java.util.Map;<BR>import java.util.MissingResourceException;<BR>import java.util.ResourceBundle;<BR>import java.util.Set;</P> <P>import net.sf.jasperreports.engine.JRAbstractScriptlet;<BR>import net.sf.jasperreports.engine.JRDataSource;<BR>import net.sf.jasperreports.engine.JRDataset;<BR>import net.sf.jasperreports.engine.JRDefaultScriptlet;<BR>import net.sf.jasperreports.engine.JRException;<BR>import net.sf.jasperreports.engine.JRExpression;<BR>import net.sf.jasperreports.engine.JRField;<BR>import net.sf.jasperreports.engine.JRGroup;<BR>import net.sf.jasperreports.engine.JRParameter;<BR>import net.sf.jasperreports.engine.JRQuery;<BR>import net.sf.jasperreports.engine.JRResultSetDataSource;<BR>import net.sf.jasperreports.engine.JRRuntimeException;<BR>import net.sf.jasperreports.engine.JRVariable;<BR>import net.sf.jasperreports.engine.JasperReport;<BR>import net.sf.jasperreports.engine.design.JRDefaultCompiler;<BR>import net.sf.jasperreports.engine.design.JRDesignVariable;<BR>import net.sf.jasperreports.engine.util.JRClassLoader;<BR>import net.sf.jasperreports.engine.util.JRQueryExecuter;</P> <P>import org.apache.commons.logging.Log;<BR>import org.apache.commons.logging.LogFactory;</P> <P>/**<BR> * @author Lucian Chirita (<A href="mailto:lucianc@users.sourceforge.net">lucianc@users.sourceforge.net</A>)<BR> * @version $Id: JRFillDataset.java,v 1.8 2005/11/28 10:23:24 teodord Exp $<BR> */<BR>public class JRFillDataset implements JRDataset<BR>{<BR> private static final Log log = LogFactory.getLog(JRBaseFiller.class);<BR> <BR> /**<BR>  * The filler that created this object.<BR>  */<BR> private final JRBaseFiller filler;<BR> <BR> /**<BR>  * The template dataset.<BR>  */<BR> private final JRDataset parent;<BR> <BR> /**<BR>  * Whether this is the main dataset of the report.<BR>  */<BR> private final boolean isMain;<BR> <BR> /**<BR>  * The dataset query.<BR>  */<BR> protected JRQuery query = null;<BR> <BR> /**<BR>  * The dataset parameter.<BR>  */<BR> protected JRFillParameter[] parameters = null;</P> <P> /**<BR>  * The dataset parameters indexed by name.<BR>  */<BR> protected Map parametersMap = null;</P> <P> /**<BR>  * The dataset fields.<BR>  */<BR> protected JRFillField[] fields = null;<BR> <BR> /**<BR>  * The dataset fields indexed by name.<BR>  */<BR> protected Map fieldsMap = null;<BR> <BR> /**<BR>  * The dataset variables.<BR>  */<BR> protected JRFillVariable[] variables = null;<BR> <BR> /**<BR>  * The dataset variables indexed by name.<BR>  */<BR> protected Map variablesMap = null;<BR> <BR> /**<BR>  * Set of <A href="mailto:{@link">{@link</A> VariableCalculationReq VariableCalculationReq} objects.<BR>  */<BR> protected Set variableCalculationReqs;</P> <P> /**<BR>  * The element datasets.<BR>  */<BR> protected JRFillElementDataset[] elementDatasets;<BR> <BR> /**<BR>  * Used to save the original element datasets when<BR>  * <A href="mailto:{@link">{@link</A> #filterElementDatasets(JRFillElementDataset) filterElementDatasets} is called.<BR>  */<BR> protected JRFillElementDataset[] origElementDatasets;</P> <P> /**<BR>  * The dataset groups.<BR>  */<BR> protected JRFillGroup[] groups = null;</P> <P> /**<BR>  * The resource bundle base name.<BR>  */<BR> protected String resourceBundleBaseName = null;<BR> <BR> /**<BR>  * The resource missing handle type.<BR>  */<BR> protected byte whenResourceMissingType;<BR> <BR> /**<BR>  * The scriptlet class name.<BR>  */<BR> protected String scriptletClassName = null;<BR> <BR> /**<BR>  * The scriptlet class.<BR>  */<BR> protected Class scriptletClass = null;</P> <P> /**<BR>  * The value of the <A href="mailto:{@link">{@link</A> JRParameter#REPORT_MAX_COUNT max count} parameter.<BR>  */<BR> protected Integer reportMaxCount = null;</P> <P> /**<BR>  * The data source. <BR>  */<BR> protected JRDataSource dataSource = null;<BR> <BR> /**<BR>  * The <A href="mailto:{@link">{@link</A> Locale Locale} to be used by the dataset.<BR>  */<BR> protected Locale locale = null;<BR> <BR> /**<BR>  * The loaded resource bundle.<BR>  */<BR> protected ResourceBundle resourceBundle = null;</P> <P> /**<BR>  * The cursor used when iterating the data source.<BR>  */<BR> protected int reportCount = 0;</P> <P> /**<BR>  * The calculator used by the dataset.<BR>  */<BR> protected JRCalculator calculator = null;</P> <P> /**<BR>  * The scriptlet used by the dataset.<BR>  */<BR> protected JRAbstractScriptlet scriptlet = null;</P> <P> /**<BR>  * The statement used to fire the query.<BR>  */<BR> protected PreparedStatement dataSourceStatement;</P> <P> private ResultSet dataSourceResultSet;</P> <P> //////////////////////////////////////////add by super.wang<BR> protected int vitalCount = 0;<BR> protected Integer pageMinLine=null; <BR> //////////////////////////////////////////add by super.end </P> <P> /**<BR>  * Creates a fill dataset object.<BR>  * @param filler the filelr<BR>  * @param dataset the template dataset<BR>  * @param factory the fill object factory<BR>  */<BR> protected JRFillDataset(JRBaseFiller filler, JRDataset dataset, JRFillObjectFactory factory)<BR> {<BR>  factory.put(dataset, this);<BR>  <BR>  this.filler = filler;<BR>  this.parent = dataset;<BR>  this.isMain = dataset.isMainDataset();<BR>  <BR>  scriptletClassName = dataset.getScriptletClass();<BR>  resourceBundleBaseName = dataset.getResourceBundle();<BR>  whenResourceMissingType = dataset.getWhenResourceMissingType();<BR>  <BR>  query = dataset.getQuery();<BR>  <BR>  setParameters(dataset, factory);</P> <P>  setFields(dataset, factory);</P> <P>  setVariables(dataset, factory);<BR>  <BR>  setGroups(dataset, factory);<BR> }</P> <P> <BR> private void setParameters(JRDataset dataset, JRFillObjectFactory factory)<BR> {<BR>  JRParameter[] jrParameters = dataset.getParameters();<BR>  if (jrParameters != null && jrParameters.length > 0)<BR>  {<BR>   parameters = new JRFillParameter[jrParameters.length];<BR>   parametersMap = new HashMap();<BR>   for (int i = 0; i < parameters.length; i++)<BR>   {<BR>    parameters[i] = factory.getParameter(jrParameters[i]);<BR>    parametersMap.put(parameters[i].getName(), parameters[i]);<BR>   }<BR>  }<BR> }</P> <P><BR> private void setGroups(JRDataset dataset, JRFillObjectFactory factory)<BR> {<BR>  JRGroup[] jrGroups = dataset.getGroups();<BR>  if (jrGroups != null && jrGroups.length > 0)<BR>  {<BR>   groups = new JRFillGroup[jrGroups.length];<BR>   for (int i = 0; i < groups.length; i++)<BR>   {<BR>    groups[i] = factory.getGroup(jrGroups[i]);<BR>   }<BR>  }<BR> }</P> <P><BR> private void setVariables(JRDataset dataset, JRFillObjectFactory factory)<BR> {<BR>  JRVariable[] jrVariables = dataset.getVariables();<BR>  if (jrVariables != null && jrVariables.length > 0)<BR>  {<BR>   List variableList = new ArrayList(jrVariables.length * 3);</P> <P>   variablesMap = new HashMap();<BR>   for (int i = 0; i < jrVariables.length; i++)<BR>   {<BR>    addVariable(jrVariables[i], variableList, factory);<BR>   }</P> <P>   setVariables(variableList);<BR>  }<BR> }<BR> <BR> <BR> private JRFillVariable addVariable(JRVariable parentVariable, List variableList, JRFillObjectFactory factory)<BR> {<BR>  JRFillVariable variable = factory.getVariable(parentVariable);</P> <P>  byte calculation = variable.getCalculation();<BR>  switch (calculation)<BR>  {<BR>   case JRVariable.CALCULATION_AVERAGE:<BR>   case JRVariable.CALCULATION_VARIANCE:<BR>   {<BR>    JRVariable countVar = createHelperVariable(parentVariable, "_COUNT", JRVariable.CALCULATION_COUNT);<BR>    JRFillVariable fillCountVar = addVariable(countVar, variableList, factory);<BR>    variable.setHelperVariable(fillCountVar, JRCalculable.HELPER_COUNT);</P> <P>    JRVariable sumVar = createHelperVariable(parentVariable, "_SUM", JRVariable.CALCULATION_SUM);<BR>    JRFillVariable fillSumVar = addVariable(sumVar, variableList, factory);<BR>    variable.setHelperVariable(fillSumVar, JRCalculable.HELPER_SUM);</P> <P>    break;<BR>   }<BR>   case JRVariable.CALCULATION_STANDARD_DEVIATION:<BR>   {<BR>    JRVariable varianceVar = createHelperVariable(parentVariable, "_VARIANCE", JRVariable.CALCULATION_VARIANCE);<BR>    JRFillVariable fillVarianceVar = addVariable(varianceVar, variableList, factory);<BR>    variable.setHelperVariable(fillVarianceVar, JRCalculable.HELPER_VARIANCE);</P> <P>    break;<BR>   }<BR>  }</P> <P>  variableList.add(variable);<BR>  return variable;<BR> }</P> <P> private JRVariable createHelperVariable(JRVariable variable, String nameSuffix, byte calculation)<BR> {<BR>  JRDesignVariable helper = new JRDesignVariable();<BR>  helper.setName(variable.getName() + nameSuffix);<BR>  helper.setValueClassName(variable.getValueClassName());<BR>  helper.setIncrementerFactoryClassName(variable.getIncrementerFactoryClassName());<BR>  helper.setResetType(variable.getResetType());<BR>  helper.setResetGroup(variable.getResetGroup());<BR>  helper.setIncrementType(variable.getIncrementType());<BR>  helper.setIncrementGroup(variable.getIncrementGroup());<BR>  helper.setCalculation(calculation);<BR>  helper.setSystemDefined(true);<BR>  helper.setExpression(variable.getExpression());</P> <P>  return helper;<BR> }</P> <P><BR> private void setVariables(List variableList)<BR> {<BR>  variables = new JRFillVariable[variableList.size()];<BR>  variables = (JRFillVariable[]) variableList.toArray(variables);</P> <P>  for (int i = 0; i < variables.length; i++)<BR>  {<BR>   variablesMap.put(variables[i].getName(), variables[i]);<BR>  }<BR> }</P> <P><BR> private void setFields(JRDataset dataset, JRFillObjectFactory factory)<BR> {<BR>  JRField[] jrFields = dataset.getFields();<BR>  if (jrFields != null && jrFields.length > 0)<BR>  {<BR>   fields = new JRFillField[jrFields.length];<BR>   fieldsMap = new HashMap();<BR>   for (int i = 0; i < fields.length; i++)<BR>   {<BR>    fields[i] = factory.getField(jrFields[i]);<BR>    fieldsMap.put(fields[i].getName(), fields[i]);<BR>   }<BR>  }<BR> }</P> <P><BR> /**<BR>  * Creates the calculator<BR>  * @param jasperReport the report<BR>  * @throws JRException<BR>  */<BR> protected void createCalculator(JasperReport jasperReport) throws JRException<BR> {<BR>  setCalculator(createCalculator(jasperReport, this));<BR> }</P> <P> protected void setCalculator(JRCalculator calculator)<BR> {<BR>  this.calculator = calculator;<BR> }</P> <P> protected static JRCalculator createCalculator(JasperReport jasperReport, JRDataset dataset) throws JRException<BR> {<BR>  JREvaluator evaluator = JRDefaultCompiler.getInstance().loadEvaluator(jasperReport, dataset);<BR>  return new JRCalculator(evaluator);<BR> }</P> <P><BR> /**<BR>  * Initializes the calculator.<BR>  * <BR>  * @throws JRException<BR>  */<BR> protected void initCalculator() throws JRException<BR> {<BR>  calculator.init(this);<BR> }</P> <P><BR> /**<BR>  * Inherits properties from the report.<BR>  */<BR> protected void inheritFromMain()<BR> {<BR>  if (resourceBundleBaseName == null && !isMain)<BR>  {<BR>   resourceBundleBaseName = filler.mainDataset.resourceBundleBaseName;<BR>   whenResourceMissingType = filler.mainDataset.whenResourceMissingType;<BR>  }<BR> }<BR> <BR> <BR> /**<BR>  * Creates and initializes the scriptlet.<BR>  * <BR>  * @return the scriptlet<BR>  * @throws JRException<BR>  */<BR> protected JRAbstractScriptlet initScriptlet() throws JRException<BR> {<BR>  scriptlet = createScriptlet();</P> <P>  scriptlet.setData(parametersMap, fieldsMap, variablesMap, groups);<BR>  <BR>  return scriptlet;<BR> }<BR> <BR> <BR> /**<BR>  * Creates the scriptlet.<BR>  * <BR>  * @return the scriptlet<BR>  * @throws JRException<BR>  */<BR> protected JRAbstractScriptlet createScriptlet() throws JRException<BR> {<BR>  JRAbstractScriptlet tmpScriptlet = null;</P> <P>  if (scriptletClassName != null)<BR>  {<BR>   if (scriptletClass == null)<BR>   {<BR>    try<BR>    {<BR>     scriptletClass = JRClassLoader.loadClassForName(scriptletClassName);<BR>    }<BR>    catch (ClassNotFoundException e)<BR>    {<BR>     throw new JRException("Error loading scriptlet class : " + scriptletClassName, e);<BR>    }<BR>   }</P> <P>   try<BR>   {<BR>    tmpScriptlet = (JRAbstractScriptlet) scriptletClass.newInstance();<BR>   }<BR>   catch (Exception e)<BR>   {<BR>    throw new JRException("Error creating scriptlet class instance : " + scriptletClassName, e);<BR>   }<BR>  }</P> <P>  if (tmpScriptlet == null)<BR>  {<BR>   tmpScriptlet = new JRDefaultScriptlet();<BR>  }</P> <P>  return tmpScriptlet;<BR> }</P> <P><BR> /**<BR>  * Initializes the element datasets.<BR>  * <BR>  * @param factory the fill object factory used by the filler<BR>  */<BR> protected void initElementDatasets(JRFillObjectFactory factory)<BR> {<BR>  elementDatasets = factory.getElementDatasets(this);<BR> }</P> <P><BR> /**<BR>  * Filters the element datasets, leaving only one.<BR>  * <p><BR>  * This method is used when a dataset is instantiated by a chart or crosstab.<BR>  * <BR>  * @param elementDataset the element dataset that should remain<BR>  */<BR> protected void filterElementDatasets(JRFillElementDataset elementDataset)<BR> {<BR>  origElementDatasets = elementDatasets;<BR>  elementDatasets = new JRFillElementDataset[]{elementDataset};<BR> }<BR> <BR> <BR> /**<BR>  * Restores the original element datasets.<BR>  * <p><BR>  * This method should be called after <A href="mailto:{@link">{@link</A> #filterElementDatasets(JRFillElementDataset) filterElementDatasets}.<BR>  */<BR> protected void restoreElementDatasets()<BR> {<BR>  if (origElementDatasets != null)<BR>  {<BR>   elementDatasets = origElementDatasets;<BR>   origElementDatasets = null;<BR>  }<BR> }<BR> </P> <P> /**<BR>  * Loads the resource bundle corresponding to the resource bundle base name and locale.<BR>  */<BR> protected ResourceBundle loadResourceBundle()<BR> {<BR>  ResourceBundle tmpResourceBundle = null;</P> <P>  if (resourceBundleBaseName != null)<BR>  {<BR>   ClassLoader classLoader = Thread.currentThread().getContextClassLoader();<BR>   if (classLoader != null)<BR>   {<BR>    try<BR>    {<BR>     tmpResourceBundle = ResourceBundle.getBundle(resourceBundleBaseName, locale, classLoader);<BR>    }<BR>    catch (MissingResourceException e)<BR>    {<BR>     // if (log.isWarnEnabled())<BR>     // log.warn("Failure using<BR>     // Thread.currentThread().getContextClassLoader() in<BR>     // JRClassLoader class. Using<BR>     // JRClassLoader.class.getClassLoader() instead.");<BR>    }<BR>   }</P> <P>   if (tmpResourceBundle == null)<BR>   {<BR>    classLoader = JRClassLoader.class.getClassLoader();</P> <P>    if (classLoader == null)<BR>    {<BR>     tmpResourceBundle = ResourceBundle.getBundle(resourceBundleBaseName, locale);<BR>    }<BR>    else<BR>    {<BR>     tmpResourceBundle = ResourceBundle.getBundle(resourceBundleBaseName, locale, classLoader);<BR>    }<BR>   }<BR>  }</P> <P>  return tmpResourceBundle;<BR> }</P> <P><BR> /**<BR>  * Reads built-in parameter values from the value map.<BR>  * <BR>  * @param parameterValues the parameter values<BR>  * @throws JRException<BR>  */<BR> protected void setParameters(Map parameterValues) throws JRException<BR> {<BR>  reportMaxCount = (Integer) parameterValues.get(JRParameter.REPORT_MAX_COUNT);</P> <P>  locale = (Locale) parameterValues.get(JRParameter.REPORT_LOCALE);<BR>  if (locale == null)<BR>  {<BR>   locale = Locale.getDefault();<BR>  }<BR>  if (locale == null)<BR>  {<BR>   parameterValues.remove(JRParameter.REPORT_LOCALE);//FIXME NOW why remove? check all<BR>  }<BR>  else<BR>  {<BR>   parameterValues.put(JRParameter.REPORT_LOCALE, locale);<BR>  }<BR>  setParameter(JRParameter.REPORT_LOCALE, locale);  <BR>  <BR>  resourceBundle = (ResourceBundle) parameterValues.get(JRParameter.REPORT_RESOURCE_BUNDLE);<BR>  if (resourceBundle == null)<BR>  {<BR>   resourceBundle = loadResourceBundle();<BR>  }<BR>  if (resourceBundle == null)<BR>  {<BR>   parameterValues.remove(JRParameter.REPORT_RESOURCE_BUNDLE);<BR>  }<BR>  else<BR>  {<BR>   parameterValues.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle);<BR>  }<BR>  setParameter(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle);<BR>  </P> <P>  try<BR>  {<BR>   pageMinLine = (Integer)getParameterValue("PAGE_MIN_LINE");<BR>  }<BR>  catch (Exception e) {}  <BR> }<BR> <BR> <BR> /**<BR>  * Sets the parameter values from the values map.<BR>  * <BR>  * @param parameterValues the values map<BR>  * @throws JRException<BR>  */<BR> protected void setParameterValues(Map parameterValues) throws JRException<BR> {<BR>  if (parameters != null && parameters.length > 0)<BR>  {<BR>   for (int i = 0; i < parameters.length; i++)<BR>   {<BR>    if (parameterValues.containsKey(parameters[i].getName()))<BR>    {<BR>     setParameter(parameters[i], parameterValues.get(parameters[i].getName()));<BR>    }<BR>    else if (!parameters[i].isSystemDefined())<BR>    {<BR>     Object value = calculator.evaluate(parameters[i].getDefaultValueExpression(), JRExpression.EVALUATION_DEFAULT);<BR>     if (value != null)<BR>     {<BR>      parameterValues.put(parameters[i].getName(), value);<BR>     }<BR>     setParameter(parameters[i], value);<BR>    }<BR>   }<BR>  }<BR> }</P> <P> <BR> /**<BR>  * Creates the data source from a connection.<BR>  * <BR>  * @param parameterValues the parameterValues<BR>  * @param conn the connection<BR>  * @return the data source to be used<BR>  * @throws JRException<BR>  */<BR> protected JRDataSource createDataSource(Map parameterValues, Connection conn) throws JRException<BR> {<BR>  if (conn == null)<BR>  {<BR>   conn = (Connection) parameterValues.get(JRParameter.REPORT_CONNECTION);<BR>  }<BR>  if (conn == null)<BR>  {<BR>   parameterValues.remove(JRParameter.REPORT_CONNECTION);<BR>  }<BR>  else<BR>  {<BR>   parameterValues.put(JRParameter.REPORT_CONNECTION, conn);<BR>  }<BR>  setParameter(JRParameter.REPORT_CONNECTION, conn);</P> <P>  if (conn == null)<BR>  {<BR>   if (log.isWarnEnabled())<BR>    log.warn("The supplied java.sql.Connection object is null.");<BR>  }</P> <P>  PreparedStatement pstmt = null;</P> <P>  try<BR>  {<BR>   JRDataSource ds = null;</P> <P>   pstmt = JRQueryExecuter.getStatement(query, parametersMap, parameterValues, conn);</P> <P>   if (pstmt != null)<BR>   {<BR>    if (reportMaxCount != null)<BR>    {<BR>     pstmt.setMaxRows(reportMaxCount.intValue());<BR>    }</P> <P>    dataSourceStatement = pstmt;<BR>    filler.fillContext.setRunningStatement(dataSourceStatement);</P> <P>    dataSourceResultSet = pstmt.executeQuery();<BR>    ds = new JRResultSetDataSource(dataSourceResultSet);<BR>   }<BR>   <BR>   return ds;<BR>  }<BR>  catch (SQLException e)<BR>  {<BR>   throw new JRException("Error executing SQL statement for report : " + filler.name, e);<BR>  }<BR>  finally<BR>  {<BR>   filler.fillContext.clearRunningStatement();<BR>  }<BR> }</P> <P><BR> /**<BR>  * Sets the data source to be used.<BR>  * <BR>  * @param parameterValues the parameter values<BR>  * @param ds the data source<BR>  * @throws JRException<BR>  */<BR> protected void setDatasource(Map parameterValues, JRDataSource ds) throws JRException<BR> {<BR>  dataSource = ds;<BR>  <BR>  if (dataSource == null)<BR>  {<BR>   dataSource = (JRDataSource) parameterValues.get(JRParameter.REPORT_DATA_SOURCE);<BR>  }<BR>  if (dataSource == null)<BR>  {<BR>   parameterValues.remove(JRParameter.REPORT_DATA_SOURCE);<BR>  }<BR>  else<BR>  {<BR>   parameterValues.put(JRParameter.REPORT_DATA_SOURCE, dataSource);<BR>  }<BR>  setParameter(JRParameter.REPORT_DATA_SOURCE, dataSource);</P> <P>  /*   */<BR>  parameterValues.put(JRParameter.REPORT_SCRIPTLET, scriptlet);<BR>  setParameter(JRParameter.REPORT_SCRIPTLET, scriptlet);</P> <P>  /*   */<BR>  parameterValues.put(JRParameter.REPORT_PARAMETERS_MAP, parameterValues);<BR>  setParameter(JRParameter.REPORT_PARAMETERS_MAP, parameterValues);<BR> }<BR> <BR> <BR> /**<BR>  * Closes the statement used to fire the query.<BR>  */<BR> protected void closeStatement()<BR> {<BR>  if (dataSourceResultSet != null)<BR>  {<BR>   try<BR>   {<BR>    dataSourceResultSet.close();<BR>   }<BR>   catch (SQLException e)<BR>   {<BR>    log.error("Error while closing result set.", e);<BR>   }<BR>   finally<BR>   {<BR>    dataSourceResultSet = null;<BR>   }<BR>  }<BR>  <BR>  if (dataSourceStatement != null)<BR>  {<BR>   try<BR>   {<BR>    dataSourceStatement.close();<BR>   }<BR>   catch (SQLException e)<BR>   {<BR>    log.error("Error while closing statement.", e);<BR>   }<BR>   finally<BR>   {<BR>    dataSourceStatement = null;<BR>   }<BR>  }<BR> }</P> <P> <BR> /**<BR>  * Starts the iteration on the data source.<BR>  */<BR> protected void start()<BR> {<BR>  reportCount = 0;<BR>  vitalCount=0;<BR> }</P> <P> <BR> /**<BR>  * Moves to the next record in the data source.<BR>  * <BR>  * @return <code>true</code> if the data source was not exhausted<BR>  * @throws JRException<BR>  */<BR> protected boolean next() throws JRException<BR> {<BR>  boolean hasNext = false;</P> <P>  if (dataSource != null)<BR>  {<BR>   if (vitalCount==0)<BR>    hasNext = (reportMaxCount == null || reportMaxCount.intValue() > reportCount) && dataSource.next();<BR>   if (hasNext)<BR>   {<BR>    reportCount++;    <BR>    /*   */<BR>    if (fields != null && fields.length > 0)<BR>    {<BR>     JRFillField field = null;<BR>     for (int i = 0; i < fields.length; i++)<BR>     {<BR>      field = fields[i];<BR>      field.setOldValue(field.getValue());<BR>      field.setValue(dataSource.getFieldValue(field));<BR>     }<BR>    }</P> <P>    /*   */<BR>    if (variables != null && variables.length > 0)<BR>    {<BR>     JRFillVariable variable = null;<BR>     for (int i = 0; i < variables.length; i++)<BR>     {<BR>      variable = variables[i];<BR>      variable.setOldValue(variable.getValue());<BR>     }<BR>    }<BR>   }<BR>   else<BR>   {<BR>    log.error("reportCount:"+reportCount);</P> <P>    if (pageMinLine!=null && pageMinLine.intValue()>0)<BR>    {<BR>     if (vitalCount==0)<BR>     {<BR>      int modNum = reportCount%pageMinLine.intValue();<BR>      if (modNum!=0)<BR>      {<BR>       vitalCount=pageMinLine.intValue()-modNum;<BR>      }<BR>      else<BR>       vitalCount=-1;<BR>     }<BR>     else<BR>     {<BR>      vitalCount--;<BR>     }<BR>     if (vitalCount!=0)<BR>     {<BR>      if (fields != null && fields.length > 0)<BR>      {<BR>       JRFillField field = null;<BR>       for (int i = 0; i < fields.length; i++)<BR>       {<BR>        field = fields[i];<BR>        field.setOldValue(field.getValue());<BR>        field.setValue(null);<BR>       }<BR>      }<BR>     }<BR>     <BR>     //<BR>    }<BR>    <BR>   }<BR>  }</P> <P>  if (vitalCount>0)<BR>  {<BR>   log.error("---blank line--");<BR>   return true;<BR>  }<BR>  return hasNext;<BR> }<BR> <BR> <BR> /**<BR>  * Sets the value of a parameter.<BR>  * <BR>  * @param parameterName the parameter name<BR>  * @param value the value<BR>  * @throws JRException<BR>  */<BR> protected void setParameter(String parameterName, Object value) throws JRException<BR> {<BR>  JRFillParameter parameter = (JRFillParameter) parametersMap.get(parameterName);<BR>  if (parameter != null)<BR>  {<BR>   setParameter(parameter, value);<BR>  }<BR> }<BR> <BR> <BR> /**<BR>  * Sets the value of the parameter.<BR>  * <BR>  * @param parameter the parameter<BR>  * @param value the value<BR>  * @throws JRException<BR>  */<BR> protected void setParameter(JRFillParameter parameter, Object value) throws JRException<BR> {<BR>  if (value != null)<BR>  {<BR>   if (parameter.getValueClass().isInstance(value))<BR>   {<BR>    parameter.setValue(value);<BR>   }<BR>   else<BR>   {<BR>    throw new JRException(<BR>     "Incompatible " <BR>     + value.getClass().getName() <BR>     + " value assigned to parameter " <BR>     + parameter.getName() <BR>     + " in the " + getName() + " dataset."<BR>     );<BR>   }<BR>  }<BR>  else<BR>  {<BR>   parameter.setValue(value);<BR>  }<BR> }</P> <P> <BR> /**<BR>  * Returns the value of a variable.<BR>  * <BR>  * @param variableName the variable name<BR>  * @return the variable value<BR>  */<BR> public Object getVariableValue(String variableName)<BR> {<BR>  JRFillVariable var = (JRFillVariable) variablesMap.get(variableName);<BR>  if (var == null)<BR>  {<BR>   throw new JRRuntimeException("No such variable " + variableName);<BR>  }<BR>  return var.getValue();<BR> }</P> <P> <BR> /**<BR>  * Returns the value of a parameter.<BR>  * <BR>  * @param parameterName the parameter name<BR>  * @return the parameter value<BR>  */<BR> public Object getParameterValue(String parameterName)<BR> {<BR>  JRFillParameter param = (JRFillParameter) parametersMap.get(parameterName);<BR>  if (param == null)<BR>  {<BR>   throw new JRRuntimeException("No such parameter " + parameterName);<BR>  }<BR>  return param.getValue();<BR> }</P> <P> <BR> /**<BR>  * Returns the value of a field.<BR>  * <BR>  * @param fieldName the field name<BR>  * @return the field value<BR>  */<BR> public Object getFieldValue(String fieldName)<BR> {<BR>  JRFillField var = (JRFillField) fieldsMap.get(fieldName);<BR>  if (var == null)<BR>  {<BR>   throw new JRRuntimeException("No such field " + fieldName);<BR>  }<BR>  return var.getValue();<BR> }<BR> <BR> <BR> /**<BR>  * Class used to hold expression calculation  requirements.<BR>  */<BR> protected static class VariableCalculationReq<BR> {<BR>  String variableName;</P> <P>  byte calculation;</P> <P>  VariableCalculationReq(String variableName, byte calculation)<BR>  {<BR>   this.variableName = variableName;<BR>   this.calculation = calculation;<BR>  }</P> <P>  public boolean equals(Object o)<BR>  {<BR>   if (o == null || !(o instanceof VariableCalculationReq))<BR>   {<BR>    return false;<BR>   }</P> <P>   VariableCalculationReq r = (VariableCalculationReq) o;</P> <P>   return variableName.equals(r.variableName) && calculation == r.calculation;<BR>  }</P> <P>  public int hashCode()<BR>  {<BR>   return 31 * calculation + variableName.hashCode();<BR>  }<BR> }<BR> <BR> <BR> /**<BR>  * Adds a variable calculation requirement.<BR>  * <BR>  * @param variableName the variable name<BR>  * @param calculation the required calculation<BR>  */<BR> protected void addVariableCalculationReq(String variableName, byte calculation)<BR> {<BR>  if (variableCalculationReqs == null)<BR>  {<BR>   variableCalculationReqs = new HashSet();<BR>  }</P> <P>  variableCalculationReqs.add(new VariableCalculationReq(variableName, calculation));<BR> }</P> <P> <BR> /**<BR>  * Checks if there are variable calculation requirements and creates the required variables.<BR>  * <BR>  * @param factory the fill object factory<BR>  */<BR> protected void checkVariableCalculationReqs(JRFillObjectFactory factory)<BR> {<BR>  if (variableCalculationReqs != null && !variableCalculationReqs.isEmpty())<BR>  {<BR>   List variableList = new ArrayList(variables.length * 2);</P> <P>   for (int i = 0; i < variables.length; i++)<BR>   {<BR>    JRFillVariable variable = variables[i];<BR>    checkVariableCalculationReq(variable, variableList, factory);<BR>   }</P> <P>   setVariables(variableList);<BR>  }<BR> }</P> <P> <BR> private void checkVariableCalculationReq(JRFillVariable variable, List variableList, JRFillObjectFactory factory)<BR> {<BR>  if (hasVariableCalculationReq(variable, JRVariable.CALCULATION_AVERAGE) || hasVariableCalculationReq(variable, JRVariable.CALCULATION_VARIANCE))<BR>  {<BR>   if (variable.getHelperVariable(JRCalculable.HELPER_COUNT) == null)<BR>   {<BR>    JRVariable countVar = createHelperVariable(variable, "_COUNT", JRVariable.CALCULATION_COUNT);<BR>    JRFillVariable fillCountVar = factory.getVariable(countVar);<BR>    checkVariableCalculationReq(fillCountVar, variableList, factory);<BR>    variable.setHelperVariable(fillCountVar, JRCalculable.HELPER_COUNT);<BR>   }</P> <P>   if (variable.getHelperVariable(JRCalculable.HELPER_SUM) == null)<BR>   {<BR>    JRVariable sumVar = createHelperVariable(variable, "_SUM", JRVariable.CALCULATION_SUM);<BR>    JRFillVariable fillSumVar = factory.getVariable(sumVar);<BR>    checkVariableCalculationReq(fillSumVar, variableList, factory);<BR>    variable.setHelperVariable(fillSumVar, JRCalculable.HELPER_SUM);<BR>   }<BR>  }</P> <P>  if (hasVariableCalculationReq(variable, JRVariable.CALCULATION_STANDARD_DEVIATION))<BR>  {<BR>   if (variable.getHelperVariable(JRCalculable.HELPER_VARIANCE) == null)<BR>   {<BR>    JRVariable varianceVar = createHelperVariable(variable, "_VARIANCE", JRVariable.CALCULATION_VARIANCE);<BR>    JRFillVariable fillVarianceVar = factory.getVariable(varianceVar);<BR>    checkVariableCalculationReq(fillVarianceVar, variableList, factory);<BR>    variable.setHelperVariable(fillVarianceVar, JRCalculable.HELPER_VARIANCE);<BR>   }<BR>  }</P> <P>  variableList.add(variable);<BR> }</P> <P> <BR> private boolean hasVariableCalculationReq(JRVariable var, byte calculation)<BR> {<BR>  return variableCalculationReqs.contains(new VariableCalculationReq(var.getName(), calculation));<BR> }</P> <P><BR> public String getName()<BR> {<BR>  return parent.getName();<BR> }</P> <P> public String getScriptletClass()<BR> {<BR>  return parent.getScriptletClass();<BR> }</P> <P> public JRParameter[] getParameters()<BR> {<BR>  return parameters;<BR> }</P> <P> public JRQuery getQuery()<BR> {<BR>  return query;<BR> }</P> <P> public JRField[] getFields()<BR> {<BR>  return fields;<BR> }</P> <P> public JRVariable[] getVariables()<BR> {<BR>  return variables;<BR> }</P> <P> public JRGroup[] getGroups()<BR> {<BR>  return groups;<BR> }</P> <P> public boolean isMainDataset()<BR> {<BR>  return isMain;<BR> }</P> <P> public String getResourceBundle()<BR> {<BR>  return resourceBundleBaseName;<BR> }</P> <P><BR> public byte getWhenResourceMissingType()<BR> {<BR>  return whenResourceMissingType;<BR> }</P> <P><BR> public void setWhenResourceMissingType(byte whenResourceMissingType)<BR> {<BR>  this.whenResourceMissingType = whenResourceMissingType;<BR> }<BR>}<BR><BR><BR><BR>   </P><img src ="http://www.tkk7.com/super/aggbug/27851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/super/" target="_blank">鐜嬪崼鍗?/a> 2006-01-13 09:28 <a href="http://www.tkk7.com/super/archive/2006/01/13/27851.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variablehttp://www.tkk7.com/super/archive/2006/01/05/26648.html鐜嬪崼鍗?/dc:creator>鐜嬪崼鍗?/author>Thu, 05 Jan 2006 01:28:00 GMThttp://www.tkk7.com/super/archive/2006/01/05/26648.htmlhttp://www.tkk7.com/super/comments/26648.htmlhttp://www.tkk7.com/super/archive/2006/01/05/26648.html#Feedback0http://www.tkk7.com/super/comments/commentRss/26648.htmlhttp://www.tkk7.com/super/services/trackbacks/26648.html瑙e喅鏂瑰紡:
鍦↗VM涓姞鍏?Djava.awt.headless=true
瀵逛簬tomcat ,鍙互淇敼catalina.sh,鍔犲叆:CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true "

]]>
主站蜘蛛池模板: 国产vA免费精品高清在线观看| 亚洲伊人久久大香线焦| 精品久久久久久久久亚洲偷窥女厕| 永久免费在线观看视频| 亚洲国产成人精品不卡青青草原| a毛片视频免费观看影院| 亚洲av日韩av激情亚洲| 最近2022中文字幕免费视频| 亚洲经典在线中文字幕| 91免费播放人人爽人人快乐| 亚洲人成网站色在线观看| 好男人看视频免费2019中文 | 无码国产精品一区二区免费| 亚洲手机中文字幕| 天天摸天天碰成人免费视频| 狠狠入ady亚洲精品| 国产成人精品日本亚洲专区61| 国产在线观看无码免费视频| 亚洲一级二级三级不卡| 久久久久久国产精品免费免费| 学生妹亚洲一区二区| 亚洲AⅤ无码一区二区三区在线 | 国产精品四虎在线观看免费| 日韩一级片免费观看| 亚洲AV永久无码精品成人| 亚欧色视频在线观看免费| 亚洲AV无码一区二区三区网址| 爱情岛论坛网亚洲品质自拍| 最近免费最新高清中文字幕韩国| 久久亚洲精品国产亚洲老地址| 亚洲?v无码国产在丝袜线观看 | 18gay台湾男同亚洲男同| 免费无码又爽又高潮视频| 久久久精品国产亚洲成人满18免费网站| 亚洲国产精品无码久久SM| 毛片网站免费在线观看| 久久毛片免费看一区二区三区| 亚洲国产中文在线二区三区免| 无码不卡亚洲成?人片| 91精品导航在线网址免费| 免费无遮挡无码视频在线观看|