class TrailFilePositionSetter {

  public synchronized FilePositionResult locateFilePosition(long scn, TransactionSCNFinderCallback callback)
      throws IOException
  {
    TrailFileNotifier notifier = new TrailFileNotifier(_dir, _filter, null, 0, null);
    List<File> orderedTrailFiles = notifier.getCandidateTrailFiles();

    _log.info("Initial set of Trail Files :" + orderedTrailFiles);

    if ( (null == orderedTrailFiles) || orderedTrailFiles.isEmpty())
    {
      return FilePositionResult.createNoTxnsFoundResult();
    }

    FilePositionResult res = null;

    if ( scn == USE_EARLIEST_SCN)
    {
      res = getFilePosition(scn, callback);
    } else {
      for (int i = orderedTrailFiles.size() - 1; i >= 0; i--)
      {
        callback.reset();

        File startFile = orderedTrailFiles.get(i);
        _log.info("Locating the SCN (" + scn + ") starting from the trail file :" + startFile);
        res = getFilePosition(scn, callback,startFile.getName());

        _log.info("Result of the location operation for SCN (" + scn + ") starting from trail file (" + startFile + ") is : " + res);

        // If this is the first txn scanned, we need to go to previous file
        if (((res.getStatus() == Status.EXACT_SCN_NOT_FOUND) || (res.getStatus() == Status.FOUND))
            && (res.getTxnPos().getTxnRank() > 0)) // TxnRank will be 0 if this is the
                                                   // first txn scanned
        {
          break;
        }

        if ((0 == i) && (res != null))
        {
          ScnTxnPos scnTxnPos = res.getTxnPos();
          if ( (scnTxnPos != null) && (scnTxnPos.getTxnRank() <= 0))
          {
            return FilePositionResult.createErrorResult(new DatabusException("A transaction with scn less than requested SCN was not found. "
              + "Without this txn, we cannot identify if all transactions for requested SCN "
              + "have been located. Requested SinceSCN is :" + scn));
          }
        }
      }
    }
    return res;
  }

  public  TrailFilePositionSetter(String dir, String filePrefix);
  public  TrailFilePositionSetter(String dir, String filePrefix, String phySourceName);

}