protected long getChangesInMode(int candidateMode) {
   SyncInfoSet participantSet = getParticipantSyncInfoSet();
   long numChanges;
   switch (candidateMode) {
     case ISynchronizePageConfiguration.OUTGOING_MODE:
       numChanges = participantSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
       break;
     case ISynchronizePageConfiguration.INCOMING_MODE:
       numChanges = participantSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
       break;
     case ISynchronizePageConfiguration.BOTH_MODE:
       numChanges =
           participantSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK)
               + participantSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
       break;
     default:
       numChanges = 0;
       break;
   }
   return numChanges;
 }
 /*
  * Return the candidate mode based on the presence of unfiltered changes
  * and the modes supported by the page.
  */
 protected int getCandidateMode() {
   SyncInfoSet participantSet = getParticipantSyncInfoSet();
   SynchronizePageConfiguration configuration = (SynchronizePageConfiguration) getConfiguration();
   long outgoingChanges = participantSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
   if (outgoingChanges > 0) {
     if (configuration.isModeSupported(ISynchronizePageConfiguration.OUTGOING_MODE)) {
       return ISynchronizePageConfiguration.OUTGOING_MODE;
     }
     if (configuration.isModeSupported(ISynchronizePageConfiguration.BOTH_MODE)) {
       return ISynchronizePageConfiguration.BOTH_MODE;
     }
   }
   long incomingChanges = participantSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
   if (incomingChanges > 0) {
     if (configuration.isModeSupported(ISynchronizePageConfiguration.INCOMING_MODE)) {
       return ISynchronizePageConfiguration.INCOMING_MODE;
     }
     if (configuration.isModeSupported(ISynchronizePageConfiguration.BOTH_MODE)) {
       return ISynchronizePageConfiguration.BOTH_MODE;
     }
   }
   return configuration.getMode();
 }