/*
 * (c) Copyright: Artenum SARL, 101-103 Boulevard Mac Donald,
 *                75019, Paris, France 2005.
 *                http://www.artenum.com
 *
 * License:
 *
 *  This program is free software; you can redistribute it
 *  and/or modify it under the terms of the Q Public License;
 *  either version 1 of the License.
 *
 *  This program is distributed in the hope that it will be
 *  useful, but WITHOUT ANY WARRANTY; without even the implied
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE. See the Q Public License for more details.
 *
 *  You should have received a copy of the Q Public License
 *  License along with this program;
 *  if not, write to:
 *    Artenum SARL, 101-103 Boulevard Mac Donald,
 *    75019, PARIS, FRANCE, e-mail: contact@artenum.com
 */
package com.artenum.cassandra.plugin.dynamic.dataset;

import java.io.File;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author Sebastien
 */
public class FileToolBox {
    public static void sortFileList(File[] fileListToSort) {
        Arrays.sort(fileListToSort, new FileComparator());
    }

    public static File findNextFile(File previousFile, int maxNumber) {
        return null;
    }

    public static ArrayList splitNumbers(String fileNameToSplit) {
        ArrayList result = new ArrayList();
        StringBuffer number = null;
        StringBuffer text = null;
        int numberID = 1;
        int stringID = 2;
        int currentID = -1;
        for (int i = 0; i < fileNameToSplit.length(); i++) {
            if ((fileNameToSplit.charAt(i) >= '0') && (fileNameToSplit.charAt(i) <= '9')) {
                if ((currentID == stringID) || (currentID == -1)) {
                    currentID = numberID;
                    number = new StringBuffer();
                    result.add(number);
                }

                number.append(fileNameToSplit.charAt(i));
            } else {
                if ((currentID == numberID) || (currentID == -1)) {
                    currentID = stringID;
                    text = new StringBuffer();
                    result.add(text);
                }

                text.append(fileNameToSplit.charAt(i));
            }
        }

        return result;
    }
}
