class DateRater {

    public ValueWithConfidence<DateColumnResults> rateAndPick(Map<Integer, PotentialColumn> mappedPotentials,
            List<? extends List<? extends String>> sampleData)
    {
        List<PotentialColumn> potentials = New.list(mappedPotentials.values());

        Collections.sort(potentials, new PotentialColumnComparator());

        List<Decider> deciders = DeciderFactory.getInstance().buildDeciders();

        DateColumn firstDate = null;
        int firstDateScore = 0;

        DateColumn secondDate = null;
        int secondDateScore = 0;

        for (Decider decider : deciders)
        {
            boolean stillDeciding = true;

            if (myIsJustDetectFormats)
            {
                decider.setConfidence(1);
            }

            while (!potentials.isEmpty() && stillDeciding)
            {
                if (firstDate != null)
                {
                    decider.setConfidence(ourEndTimeScore);
                }

                List<Pair<PotentialColumn, Integer>> scores = decider.calculateConfidence(potentials, sampleData);

                if (!scores.isEmpty())
                {
                    List<Pair<DateColumn, Integer>> results = decider.compileResults(scores);

                    for (Pair<DateColumn, Integer> result : results)
                    {
                        DateColumn dateColumn = result.getFirstObject();
                        int secondObject = result.getSecondObject().intValue();

                        removePotentials(potentials, dateColumn);

                        if (firstDate == null)
                        {
                            firstDate = dateColumn;
                            firstDateScore = secondObject;
                        }
                        else if (secondDate == null)
                        {
                            secondDate = dateColumn;
                            secondDateScore = secondObject;
                        }
                        else if (firstDateScore <= result.getSecondObject().intValue()
                                && firstDate.getPrimaryColumnIndex() > dateColumn.getPrimaryColumnIndex()
                                && firstDate.getDateColumnType() == dateColumn.getDateColumnType())
                        {
                            firstDate = dateColumn;
                            firstDateScore = secondObject;
                        }
                        else if (secondDateScore <= result.getSecondObject().intValue()
                                && secondDate.getPrimaryColumnIndex() > dateColumn.getPrimaryColumnIndex()
                                && secondDate.getDateColumnType() == dateColumn.getDateColumnType())
                        {
                            secondDate = dateColumn;
                            secondDateScore = secondObject;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    stillDeciding = false;
                }
            }

            if (potentials.isEmpty() || firstDate != null && secondDate != null)
            {
                break;
            }
        }

        return compileResults(firstDate, firstDateScore, secondDate, secondDateScore, sampleData);
    }

}