Package net.sf.jasperreports.engine

Examples of net.sf.jasperreports.engine.JRParameter


  private String generateExpression(
    JRExpression expression,
    byte evaluationType
    )
  {
    JRParameter jrParameter = null;
    JRField jrField = null;
    JRVariable jrVariable = null;

    StringBuffer sbuffer = new StringBuffer();

    JRExpressionChunk[] chunks = expression.getChunks();
    JRExpressionChunk chunk = null;
    String chunkText = null;
    if (chunks != null && chunks.length > 0)
    {
      for(int i = 0; i < chunks.length; i++)
      {
        chunk = chunks[i];

        chunkText = chunk.getText();
        if (chunkText == null)
        {
          chunkText = "";
        }
       
        switch (chunk.getType())
        {
          case JRExpressionChunk.TYPE_TEXT :
          {
            sbuffer.append(chunkText);
            break;
          }
          case JRExpressionChunk.TYPE_PARAMETER :
          {
            jrParameter = (JRParameter)parametersMap.get(chunkText);
 
            sbuffer.append("((");
            sbuffer.append(jrParameter.getValueClassName());
            sbuffer.append(")super.parameter_");
            sbuffer.append(JRStringUtil.getJavaIdentifier(chunkText));
            sbuffer.append(".getValue())");
 
            break;
View Full Code Here


          JRQueryChunk queryChunk = chunks[j];
          switch (queryChunk.getType())
          {
            case JRQueryChunk.TYPE_PARAMETER :
            {
              JRParameter parameter = (JRParameter)parametersMap.get(queryChunk.getText());
              if ( parameter == null )
              {
                addBrokenRule("Query parameter not found : " + queryChunk.getText(), query);
              }
              else if (queryExecuterFactory != null)
              {
                String parameterType = null;
                try
                {
                  parameterType = parameter.getValueClassName();
                }
                catch (JRRuntimeException e)
                {
                  // ignore, already added when the parameter got verified
                }
View Full Code Here

    JRParameter[] parameters = dataset.getParameters();
    if (parameters != null && parameters.length > 0)
    {
      for(int index = 0; index < parameters.length; index++)
      {
        JRParameter parameter = parameters[index];

        Object errorSource = parameter;
        if (parameter.isSystemDefined())
        {
          errorSource = jasperDesign;
        }

        if (parameter.getName() == null || parameter.getName().trim().length() == 0)
        {
          addBrokenRule("Parameter name missing.", errorSource);
        }

        if (parameter.getValueClassName() == null)
        {
          addBrokenRule("Class not set for parameter : " + parameter.getName(), errorSource);
        }
        else
        {
          try
          {
            Class parameterType = parameter.getValueClass();
            JRExpression expression = parameter.getDefaultValueExpression();
            if (expression != null)
            {
              try
              {
                if (expression.getValueClass() == null)
                {
                  addBrokenRule("No value class defined for the expression in parameter: " + parameter.getName(), expression);
                }
                else
                {
                  if (!parameterType.isAssignableFrom(expression.getValueClass()))
                  {
                    addBrokenRule("The parameter default value expression class is not compatible with the parameter's class : " + parameter.getName(), expression);
                  }
                }
              }
              catch (JRRuntimeException e)
              {
View Full Code Here

        if (paramName == null || paramName.trim().length() == 0)
        {
          addBrokenRule("Dataset " + datasetName + " parameter name missing.", parameter);
        }

        JRParameter datasetParam = null;
        if (dataset != null)
        {
          datasetParam = (JRParameter) dataset.getParametersMap().get(paramName);

          if (datasetParam == null)
          {
            addBrokenRule("Unknown parameter " + paramName + " in dataset " + datasetName + ".", parameter);
          }
        }

        JRExpression expression = parameter.getExpression();

        if (expression != null)
        {
          try
          {
            Class clazz = expression.getValueClass();
            if (clazz == null)
            {
              addBrokenRule("Class not set for dataset " + datasetName + " parameter expression : " + paramName + ".", expression);
            }
            else if (datasetParam != null && !datasetParam.getValueClass().isAssignableFrom(clazz))
            {
              addBrokenRule("Class " + clazz + " not supported for parameter " + paramName + " of dataset " + datasetName + ". Use " + datasetParam.getValueClass() + " instead.",
                  expression);
            }
          }
          catch (JRRuntimeException e)
          {
View Full Code Here

  {
    Collections.sort(parametersList, new Comparator()
        {
          public int compare(Object o1, Object o2)
          {
            JRParameter p1 = (JRParameter) o1;
            JRParameter p2 = (JRParameter) o2;
            boolean s1 = p1.isSystemDefined();
            boolean s2 = p2.isSystemDefined();
           
            return s1 ? (s2 ? 0 : -1) : (s2 ? 1 : 0);
          }
        });
  }
View Full Code Here

  private void removeBuiltinParameters(Object[] builtinParameters)
  {
    for (int i = 0; i < builtinParameters.length; i += 2)
    {
      String parameterName = (String) builtinParameters[i];
      JRParameter parameter = (JRParameter) parametersMap.get(parameterName);
      if (parameter.isSystemDefined())
      {
        removeParameter(parameter);
      }
    }
  }
View Full Code Here

    {
      clone.parametersList = new ArrayList(parametersList.size());
      clone.parametersMap = new HashMap(parametersList.size());
      for(int i = 0; i < parametersList.size(); i++)
      {
        JRParameter parameter =
          (JRParameter)((JRParameter)parametersList.get(i)).clone();
        clone.parametersList.add(parameter);
        clone.parametersMap.put(parameter.getName(), parameter);
      }
    }
   
    if (fieldsList != null)
    {
View Full Code Here

  private String generateExpression(
    JRExpression expression,
    byte evaluationType
    )
  {
    JRParameter jrParameter = null;
    JRField jrField = null;
    JRVariable jrVariable = null;

    StringBuffer sb = new StringBuffer();

    JRExpressionChunk[] chunks = expression.getChunks();
    JRExpressionChunk chunk = null;
    String chunkText = null;
    if (chunks != null && chunks.length > 0)
    {
      for(int i = 0; i < chunks.length; i++)
      {
        chunk = chunks[i];

        chunkText = chunk.getText();
        if (chunkText == null)
        {
          chunkText = "";
        }
       
        switch (chunk.getType())
        {
          case JRExpressionChunk.TYPE_TEXT :
          {
            appendExpressionText(expression, sb, chunkText);
            break;
          }
          case JRExpressionChunk.TYPE_PARAMETER :
          {
            jrParameter = (JRParameter)parametersMap.get(chunkText);
 
            sb.append("((");
            sb.append(jrParameter.getValueClassName());
            sb.append(")parameter_");
            sb.append(JRStringUtil.getJavaIdentifier(chunkText));
            sb.append(".getValue())");
 
            break;
View Full Code Here

      xmlLoader.addError(new JRValidationException("Unknown sub dataset " + datasetRun.getDatasetName(), datasetRun));
    }
    else
    {
      JRDatasetParameter runParameter = (JRDatasetParameter) digester.peek();
      JRParameter param = (JRParameter) dataset.getParametersMap().get(runParameter.getName());
     
      if (param == null)
      {
        xmlLoader.addError(new JRValidationException("Unknown parameter " + runParameter.getName() + " in sub dataset " + datasetRun.getDatasetName(), runParameter));
      }
      else
      {
        valueClassName = param.getValueClassName();
      }
    }

    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClassName(valueClassName);
View Full Code Here

            sb.append(chunkText);
            break;
          }
          case JRExpressionChunk.TYPE_PARAMETER :
          {
            JRParameter jrParameter = (JRParameter)parametersMap.get(chunkText);
           
            appendReferenceChunk(
              sb,
              jrParameter.getValueClassName(),
              "parameter",
              JRStringUtil.getJavaIdentifier(chunkText),
              null,
              chunks.length > 1
              );
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.JRParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.