Package net.sf.jasperreports.engine

Examples of net.sf.jasperreports.engine.JRSortField


    int[] sortIndexes = new int[sortFields.length];
    int[] sortOrders = new int[sortFields.length];
    boolean[] collatorFlags = new boolean[sortFields.length];
    for(int i = 0; i < sortFields.length; i++)
    {
      JRSortField sortField = sortFields[i];
      sortIndexes[i] = ((Integer)fieldIndexMap.get(sortField.getName())).intValue();
      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


    JRSortField[] sortFields = dataset.getSortFields();
    if (sortFields != null && sortFields.length > 0)
    {
      for(int index = 0; index < sortFields.length; index++)
      {
        JRSortField sortField = sortFields[index];
        String sortFieldName = sortField.getName();

        if (sortFieldName == null || sortFieldName.trim().length() == 0)
        {
          addBrokenRule("Sort field name missing.", sortField);
        }
        else
        {
          boolean isFound = false;

          if (sortField.getType() == SortFieldTypeEnum.VARIABLE)
          {
            if (variables != null)
            {
              int j = 0;
              while (!isFound && j < variables.length)
              {
                isFound = sortFieldName.equals(variables[j].getName());
                j++;
              }
            }
          }
          else
          {
            if (fields != null)
            {
              int j = 0;
              while (!isFound && j < fields.length)
              {
                isFound = sortFieldName.equals(fields[j].getName());
                j++;
              }
            }
          }

          if (!isFound)
          {
            addBrokenRule("Sort " + sortField.getType().getName().toLowerCase() + " \'" + sortFieldName + "\' not found in dataset.", sortField);
          }
        }
      }
    }
  }
View Full Code Here

    {
      clone.sortFieldsList = new ArrayList(sortFieldsList.size());
      clone.sortFieldsMap = new HashMap(sortFieldsList.size());
      for(int i = 0; i < sortFieldsList.size(); i++)
      {
        JRSortField sortField =
          (JRSortField)((JRSortField)sortFieldsList.get(i)).clone();
        clone.sortFieldsList.add(sortField);
        clone.sortFieldsMap.put(sortField.getName(), sortField);
      }
    }
   
    if (variablesList != null)
    {
View Full Code Here

    {
      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();
View Full Code Here

    {
      record[i] = dataset.getFieldValue(fields[i].getName());
    }
    for(int i = 0; i < allSortFields.length; i++)
    {
      JRSortField sortField = allSortFields[i];
      if (sortField.getType() == SortFieldTypeEnum.VARIABLE)
      {
        record[sortInfo.sortFieldInfo[i].index] = dataset.getVariableValue(sortField.getName());
      }
    }
    records.add(record);
  }
View Full Code Here

TOP

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

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.