Package net.sf.jasperreports.engine

Examples of net.sf.jasperreports.engine.JRField


    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;
          }
          case JRExpressionChunk.TYPE_FIELD :
          {
            jrField = (JRField)fieldsMap.get(chunkText);
 
            sbuffer.append("((");
            sbuffer.append(jrField.getValueClassName());
            sbuffer.append(")super.field_");
            sbuffer.append(JRStringUtil.getJavaIdentifier(chunkText));
            sbuffer.append(".get");
            sbuffer.append((String)fieldPrefixMap.get(new Byte(evaluationType)));
            sbuffer.append("Value())");
View Full Code Here


        JRField[] fields = dataset.getFields();
        if (fields != null)
        {
            for (int i = 0; i < fields.length; i++)
            {
                JRField field = fields[i];
                String fieldMapping = getFieldMapping(field);

                MappingLexer lexer = new MappingLexer(new StringReader(fieldMapping));
                MappingParser parser = new MappingParser(lexer);
                parser.setMappingMetadata(this);
                Mapping mapping;
                try
                {
                    mapping = parser.mapping();
                }
                catch (ANTLRException e)
                {
                    log.error("Error parsing field mapping", e);
                    throw new JRRuntimeException(e);
                }

                if (mapping == null)
                {
                    throw new JRRuntimeException("Invalid field mapping \"" + fieldMapping + "\".");
                }

                processMappingMembers(mapping);

                FieldMatcher fieldMatcher = createFieldMatcher(mapping);
                fieldMatchers.put(field.getName(), fieldMatcher);
            }
        }

        if (!dataField)
        {
View Full Code Here

    {
      if (returnTypes[0].isEntityType() || returnTypes[0].isComponentType())
      {
        for (int i = 0; i < fields.length; i++)
        {
          JRField field = fields[i];
          readers.put(field.getName(), getFieldReaderSingleReturn(aliasesMap, field, useIndexOnSingleReturn));
        }
      }
      else
      {
        if (fields.length > 1)
        {
          throw new JRRuntimeException("The HQL query returns only one non-entity and non-component result but there are more than one fields.");
        }
       
        if (fields.length == 1)
        {
          JRField field = fields[0];
          if (useIndexOnSingleReturn)
          {
            readers.put(field.getName(), new IndexFieldReader(0));
          }
          else
          {
            readers.put(field.getName(), new IdentityFieldReader());
          }
        }
      }
    }
    else
    {
      for (int i = 0; i < fields.length; i++)
      {
        JRField field = fields[i];
        readers.put(field.getName(), getFieldReader(returnTypes, aliasesMap, field));       
      }
    }

    return readers;
  }
View Full Code Here

      sortOrders[i] = (SortOrderEnum.ASCENDING == sortField.getOrderValue() ? 1 : -1);

      collatorFlags[i] = false;
      for(int j = 0; j < fields.length; j++)
      {
        JRField field = fields[j];
        if (sortField.getName().equals(field.getName()))
        {
          //it is certain that a matching field will be found, due to verifySortFields();
          collatorFlags[i] = String.class.getName().equals(field.getValueClassName());
          break;
        }
      }
    }
View Full Code Here

    JRField[] fields = dataset.getFields();
    if (fields != null && fields.length > 0)
    {
      for(int index = 0; index < fields.length; index++)
      {
        JRField field = fields[index];

        if (field.getName() == null || field.getName().trim().length() == 0)
        {
          addBrokenRule("Field name missing.", field);
        }

        try
        {
          Class fieldType = field.getValueClass();
          if (fieldType == null)
          {
            addBrokenRule("Class not set for field : " + field.getName(), field);
          }
        }
        catch (JRRuntimeException e)
        {
          addBrokenRule(e, field);
View Full Code Here

    {
      clone.fieldsList = new ArrayList(fieldsList.size());
      clone.fieldsMap = new HashMap(fieldsList.size());
      for(int i = 0; i < fieldsList.size(); i++)
      {
        JRField field =
          (JRField)((JRField)fieldsList.get(i)).clone();
        clone.fieldsList.add(field);
        clone.fieldsMap.put(field.getName(), field);
      }
    }
   
    if (sortFieldsList != null)
    {
View Full Code Here

    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;
          }
          case JRExpressionChunk.TYPE_FIELD :
          {
            jrField = (JRField)fieldsMap.get(chunkText);
 
            sb.append("((");
            sb.append(jrField.getValueClassName());
            sb.append(")field_");
            sb.append(JRStringUtil.getJavaIdentifier(chunkText));
            sb.append(".get");
            sb.append((String)fieldPrefixMap.get(new Byte(evaluationType)));
            sb.append("Value())");
View Full Code Here

    JRField[] fields = dataset.getFields();
    if (fields != null)
    {
      for(int i = 0; i < fields.length; i++)
      {
        JRField field = fields[i];
        fieldsMap.put(field.getName(), field);
        fieldIndexMap.put(field.getName(), Integer.valueOf(i));
        sortInfo.fieldNames.add(field.getName());
      }
    }

    Map variablesMap = new HashMap();
    JRVariable[] variables = dataset.getVariables();
    if (variables != null)
    {
      for(int i = 0; i < variables.length; i++)
      {
        variablesMap.put(variables[i].getName(), variables[i]);
      }
    }

    JRSortField[] sortFields = getAllSortFields(dataset);
    if (sortFields != null)
    {
      sortInfo.sortFieldInfo = new SortFieldInfo[sortFields.length];

      for(int i = 0; i < sortFields.length; i++)
      {
        JRSortField sortField = sortFields[i];

        String sortFieldName = sortField.getName();
       
        SortFieldInfo info = new SortFieldInfo();
       
        info.name = sortFieldName;
        info.isVariable = sortField.getType() == SortFieldTypeEnum.VARIABLE;
        info.order = (SortOrderEnum.ASCENDING == sortField.getOrderValue() ? 1 : -1);

        Integer index;
        if (info.isVariable)
        {
          JRVariable variable = (JRVariable)variablesMap.get(sortFieldName);
          if (variable == null)
          {
            throw new JRRuntimeException("Sort variable \"" + sortFieldName + "\" not found in dataset.");
          }
         
          index = new Integer(sortInfo.fieldNames.size());
          info.collatorFlag = String.class.getName().equals(variable.getValueClassName());
         
          sortInfo.fieldNames.add(variable.getName());
        }
        else
        {
          JRField field = (JRField)fieldsMap.get(sortFieldName);
          if (field == null)
          {
            throw new JRRuntimeException("Sort field \"" + sortFieldName + "\" not found in dataset.");
          }
         
          index = (Integer)fieldIndexMap.get(sortField.getName());

          info.collatorFlag = String.class.getName().equals(field.getValueClassName());
        }
        info.index = index.intValue();

        sortInfo.sortFieldInfo[i] = info;
      }
View Full Code Here

 
            break;
          }
          case JRExpressionChunk.TYPE_FIELD :
          {
            JRField jrField = (JRField)fieldsMap.get(chunkText);

            appendReferenceChunk(
              sb,
              jrField.getValueClassName(),
              "field",
              JRStringUtil.getJavaIdentifier(chunkText),
              (String)fieldPrefixMap.get(new Byte(evaluationType)),
              chunks.length > 1
              );
View Full Code Here

    for (int i = 0; i < fields.length; i++)
    {
      try
      {
        JRField field = fields[i];

        JRDesignExpression exp = new JRDesignExpression();
        exp.addFieldChunk(field.getName());
       
        if (field.getValueClassName().equals("java.sql.Date"))
        {
          // JasperReports does not support java.sql.Date in text field expression
          exp.setValueClass(java.util.Date.class);
        }
        else
        {
          exp.setValueClass(field.getValueClass());
        }

        JRDesignTextField txt = new JRDesignTextField();
        txt.setExpression(exp);
        txt.setX(i * fieldWidth);
        txt.setY(0);
        txt.setHeight(20);
        txt.setWidth(fieldWidth);

        if (field.getValueClass().equals(Double.class))
        {
          txt.setPattern("0.00");
        }

        bandDetail.addElement(txt);

        JRDesignStaticText sText = new JRDesignStaticText();
        sText.setX(i * fieldWidth);
        sText.setY(0);
        sText.setHeight(20);
        sText.setWidth(fieldWidth);
        sText.setText(field.getName());
        sText.setUnderline(true);

        bandHeader.addElement(sText);
      }
      catch (Exception e)
View Full Code Here

TOP

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

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.