Package ru.petrsu.akolosov.flowbrook.utils

Source Code of ru.petrsu.akolosov.flowbrook.utils.FlowGaps

/*
* Copyright (C) 2010 Alexander Kolosov
*
* This file is part of FlowBrook.
*
* FlowBrook is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* FlowBrook 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
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FlowBrook. If not, see <http://www.gnu.org/licenses/>
*/

package ru.petrsu.akolosov.flowbrook.utils;

import java.io.File;
import java.util.Calendar;
import java.util.List;
import ru.petrsu.akolosov.flowbrook.FlowSource;
import ru.petrsu.akolosov.flowbrook.FlowSourceSet;
import ru.petrsu.akolosov.flowbrook.flowtools.FlowTools;

/**
*
* @author Alexander Kolosov
*/
public class FlowGaps {

    public static void main(String args[]) {

        Calendar cal = Calendar.getInstance();
        FlowSource firstSource = null;
        FlowSource lastSource = null;

        for (String path : args) {
            FlowSourceSet sourceSet = FlowTools.getSourceFromDir(new File(path), true);
            if (lastSource != null)
                sourceSet.addFlowSource(lastSource);

            List<FlowSource> sources = sourceSet.getEffectiveSources();

            for (int i = 0; i < sources.size() - 1; i++) {
                FlowSource s1 = sources.get(i);
                FlowSource s2 = lastSource = sources.get(i + 1);

                if (firstSource == null)
                    firstSource = s1;

                cal.setTime(s2.getFirstFlowTime());
                long s2Start = cal.getTimeInMillis();

                cal.setTime(s1.getLastFlowTime());
                long s1End = cal.getTimeInMillis();

                long diff = s2Start - s1End;

                long hourMillis = 60 * 60 * 1000;

                if (diff >= hourMillis) {
                    System.out.println("Gap: " + s1.getLastFlowTime() + " -> " + s2.getFirstFlowTime() + ": more than hour");
                }
            }
        }

        System.out.println("Overall: " + firstSource.getFirstFlowTime() + " -> " + lastSource.getLastFlowTime());
    }
}
TOP

Related Classes of ru.petrsu.akolosov.flowbrook.utils.FlowGaps

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.