private TreeMap<Integer, Integer> createTaskMap(FieldMap fieldMap, FixedMeta taskFixedMeta, FixedData taskFixedData, Var2Data taskVarData)
   {
      TreeMap<Integer, Integer> taskMap = new TreeMap<Integer, Integer>();
      int uniqueIdOffset = fieldMap.getFixedDataOffset(TaskField.UNIQUE_ID);
      Integer taskNameKey = fieldMap.getVarDataKey(TaskField.NAME);
      int itemCount = taskFixedMeta.getAdjustedItemCount();
      int uniqueID;
      Integer key;

      //
      // First three items are not tasks, so let's skip them
      //
      for (int loop = 3; loop < itemCount; loop++)
      {
         byte[] data = taskFixedData.getByteArrayValue(loop);
         if (data != null)
         {
            byte[] metaData = taskFixedMeta.getByteArrayValue(loop);

            //
            // Check for the deleted task flag
            //
            int flags = MPPUtility.getInt(metaData, 0);
            if ((flags & 0x02) != 0)
            {
               // Project stores the deleted tasks unique id's into the fixed data as well
               // and at least in one case the deleted task was listed twice in the list
               // the second time with data with it causing a phantom task to be shown.
               // See CalendarErrorPhantomTasks.mpp
               //
               // So let's add the unique id for the deleted task into the map so we don't
               // accidentally include the task later.
               //
               uniqueID = MPPUtility.getShort(data, TASK_UNIQUE_ID_FIXED_OFFSET); // Only a short stored for deleted tasks?
               key = Integer.valueOf(uniqueID);
               if (taskMap.containsKey(key) == false)
               {
                  taskMap.put(key, null); // use null so we can easily ignore this later
               }
            }
            else
            {
               //
               // Do we have a null task?
               //
               if (data.length == NULL_TASK_BLOCK_SIZE)
               {
                  uniqueID = MPPUtility.getInt(data, TASK_UNIQUE_ID_FIXED_OFFSET);
                  key = Integer.valueOf(uniqueID);
                  if (taskMap.containsKey(key) == false)
                  {
                     taskMap.put(key, Integer.valueOf(loop));
                  }
               }
               else
               {
                  //
                  // We apply a heuristic here - if we have more than 75% of the data, we assume
                  // the task is valid.
                  //
                  int maxSize = fieldMap.getMaxFixedDataSize(0);
                  if (maxSize == 0 || ((data.length * 100) / maxSize) > 75)
                  {
                     uniqueID = MPPUtility.getInt(data, uniqueIdOffset);
                     key = Integer.valueOf(uniqueID);

                     // Accept this task if it does not have a deleted unique ID or it has a deleted unique ID but the name is not null
                     if (!taskMap.containsKey(key) || taskVarData.getUnicodeString(key, taskNameKey) != null)
                     {
                        taskMap.put(key, Integer.valueOf(loop));
                     }
                  }
               }
            }
         }
      }

      return (taskMap);
   }
private TreeMap < Integer , Integer > createTaskMap ( FieldMap fieldMap , FixedMeta taskFixedMeta , FixedData taskFixedData , Var2Data taskVarData ) { TreeMap < Integer , Integer > taskMap = new TreeMap < Integer , Integer > ( ) ; int uniqueIdOffset = fieldMap . getFixedDataOffset ( TaskField . UNIQUE_ID ) ; Integer taskNameKey = fieldMap . getVarDataKey ( TaskField . NAME ) ; int itemCount = taskFixedMeta . getAdjustedItemCount ( ) ; int uniqueID ; Integer key ; for ( int loop = 3 ; loop < itemCount ; loop ++ ) { byte [ ] data = taskFixedData . getByteArrayValue ( loop ) ; if ( data != null ) { byte [ ] metaData = taskFixedMeta . getByteArrayValue ( loop ) ; int flags = MPPUtility . getInt ( metaData , 0 ) ; if ( ( flags & 0x02 ) != 0 ) { uniqueID = MPPUtility . getShort ( data , TASK_UNIQUE_ID_FIXED_OFFSET ) ; key = Integer . valueOf ( uniqueID ) ; if ( taskMap . containsKey ( key ) == false ) { taskMap . put ( key , null ) ; } } else { if ( data . length == NULL_TASK_BLOCK_SIZE ) { uniqueID = MPPUtility . getInt ( data , TASK_UNIQUE_ID_FIXED_OFFSET ) ; key = Integer . valueOf ( uniqueID ) ; if ( taskMap . containsKey ( key ) == false ) { taskMap . put ( key , Integer . valueOf ( loop ) ) ; } } else { int maxSize = fieldMap . getMaxFixedDataSize ( 0 ) ; if ( maxSize == 0 || ( ( data . length * 100 ) / maxSize ) > 75 ) { uniqueID = MPPUtility . getInt ( data , uniqueIdOffset ) ; key = Integer . valueOf ( uniqueID ) ; if ( ! taskMap . containsKey ( key ) || taskVarData . getUnicodeString ( key , taskNameKey ) != null ) { taskMap . put ( key , Integer . valueOf ( loop ) ) ; } } } } } } return ( taskMap ) ; }
This method maps the task unique identifiers to their index number
within the FixedData block.

@param fieldMap field map
@param taskFixedMeta Fixed meta data for this task
@param taskFixedData Fixed data for this task
@param taskVarData Variable task data
@return Mapping between task identifiers and block position