// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 10/2/2001 11:01:01
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/utils/GenReport

package com.macromedia.generator.utils;

import java.io.*;
import java.util.Locale;
import java.util.ResourceBundle;

// Referenced classes of package com.macromedia.generator.utils:
//            GenReportFrame

public class GenReport
{

    public GenReport()
    {
        _fld027F = null;
        _fld0280 = null;
        _fld0281 = null;
        results30 = null;
        results60 = null;
        results90 = null;
        resultsCurrent = null;
        _fld019D = 0x5265c00L;
        _fld026E = 0;
        _fld0282 = false;
        _fld0280 = null;
        _fld0281 = null;
        loadKeys();
    }

    private void _mth027F(String s)
    {
        if(!_fld0282)
            return;
        String s1 = System.getProperty("file.separator");
        String s2 = System.getProperty("com.macromedia.generator.installpath");
        String s3 = s2 + s1 + "logs" + s1 + "GenReportDebug.log";
        try
        {
            FileOutputStream fileoutputstream = new FileOutputStream(s3, true);
            PrintWriter printwriter = new PrintWriter(fileoutputstream);
            printwriter.println(s);
            printwriter.flush();
            printwriter.close();
        }
        catch(FileNotFoundException _ex) { }
    }

    private void _mth0280(GenReportFrame genreportframe, long l)
    {
        if(!_fld0282)
        {
            return;
        } else
        {
            long l1 = genreportframe.getMidTime();
            _mth027F("mid time: " + l1 + ", gifCnt: " + genreportframe.gifCnt + ", totSize: " + genreportframe.gifTotSize + ", totTime: " + genreportframe.gifTotTime);
            return;
        }
    }

    public boolean loadKeys()
    {
        ResourceBundle resourcebundle = ResourceBundle.getBundle("com.macromedia.generator.resources.ResourceData", Locale.getDefault());
        if(resourcebundle == null)
        {
            return false;
        } else
        {
            _fld027F = new String[31];
            _fld027F[0] = resourcebundle.getString("GenStats").trim();
            _fld027F[1] = resourcebundle.getString("GenStatsStartup").trim();
            _fld027F[2] = resourcebundle.getString("GenStatsCurTime").trim();
            _fld027F[3] = resourcebundle.getString("GenStatsStatTime").trim();
            _fld027F[4] = resourcebundle.getString("GenStatsMaxReq").trim();
            _fld027F[5] = resourcebundle.getString("GenStatsSwfCnt").trim();
            _fld027F[6] = resourcebundle.getString("GenStatsSwfAvgSz").trim();
            _fld027F[7] = resourcebundle.getString("GenStatsSwfAvgTime").trim();
            _fld027F[8] = resourcebundle.getString("GenStatsSwfMaxSz").trim();
            _fld027F[9] = resourcebundle.getString("GenStatsSwfMaxTime").trim();
            _fld027F[10] = resourcebundle.getString("GenStatsGifCnt").trim();
            _fld027F[11] = resourcebundle.getString("GenStatsGifAvgSz").trim();
            _fld027F[12] = resourcebundle.getString("GenStatsGifAvgTime").trim();
            _fld027F[13] = resourcebundle.getString("GenStatsGifMaxSz").trim();
            _fld027F[14] = resourcebundle.getString("GenStatsGifMaxTime").trim();
            _fld027F[15] = resourcebundle.getString("GenStatsJpgCnt").trim();
            _fld027F[16] = resourcebundle.getString("GenStatsJpgAvgSz").trim();
            _fld027F[17] = resourcebundle.getString("GenStatsJpgAvgTime").trim();
            _fld027F[18] = resourcebundle.getString("GenStatsJpgMaxSz").trim();
            _fld027F[19] = resourcebundle.getString("GenStatsJpgMaxTime").trim();
            _fld027F[20] = resourcebundle.getString("GenStatsPngCnt").trim();
            _fld027F[21] = resourcebundle.getString("GenStatsPngAvgSz").trim();
            _fld027F[22] = resourcebundle.getString("GenStatsPngAvgTime").trim();
            _fld027F[23] = resourcebundle.getString("GenStatsPngMaxSz").trim();
            _fld027F[24] = resourcebundle.getString("GenStatsPngMaxTime").trim();
            _fld027F[25] = resourcebundle.getString("GenStatsQTMCnt").trim();
            _fld027F[26] = resourcebundle.getString("GenStatsQTMAvgSz").trim();
            _fld027F[27] = resourcebundle.getString("GenStatsQTMAvgTime").trim();
            _fld027F[28] = resourcebundle.getString("GenStatsQTMMaxSz").trim();
            _fld027F[29] = resourcebundle.getString("GenStatsQTMMaxTime").trim();
            _fld027F[30] = resourcebundle.getString("EndGenStats").trim();
            return true;
        }
    }

    public boolean loadStats(String s)
    {
        BufferedReader bufferedreader = null;
        try
        {
            bufferedreader = new BufferedReader(new FileReader(s));
        }
        catch(Exception _ex) { }
        if(bufferedreader == null)
            return false;
        long l = 0L;
        for(GenReportFrame genreportframe = readFrame(bufferedreader); genreportframe != null; genreportframe = readFrame(bufferedreader))
        {
            genreportframe._fld0284 = _fld0281;
            if(_fld0281 != null)
                _fld0281._fld0283 = genreportframe;
            if(_fld0280 == null)
                _fld0280 = genreportframe;
            _fld0281 = genreportframe;
            long l1 = genreportframe.getMidTime();
            if(l1 < l)
                _mth027F("something goofy about the times here. " + l + " > " + l1);
            l = l1;
        }

        _mth0281();
        return true;
    }

    protected GenReportFrame readFrame(BufferedReader bufferedreader)
    {
        GenReportFrame genreportframe = null;
        try
        {
            String s = bufferedreader.readLine();
            if(s == null)
                return null;
            genreportframe = new GenReportFrame();
            if(!genreportframe.parseReadString(s))
                genreportframe = null;
        }
        catch(IOException _ex)
        {
            return null;
        }
        if(genreportframe != null)
            _mth027F("readFrame: " + genreportframe.getMidTime() + " delta time: " + genreportframe.statTime);
        return genreportframe;
    }

    public boolean setDaysBack(int i)
    {
        if(i < 0)
        {
            return false;
        } else
        {
            _fld026E = i;
            return true;
        }
    }

    public void setReportLog(boolean flag)
    {
        _fld0282 = flag;
    }

    public boolean setTimeFrame(String s)
    {
        if(s.equalsIgnoreCase("sec"))
            _fld019D = 1000L;
        else
        if(s.equalsIgnoreCase("min"))
            _fld019D = 60000L;
        else
        if(s.equalsIgnoreCase("hour"))
            _fld019D = 0x36ee80L;
        else
        if(s.equalsIgnoreCase("day"))
            _fld019D = 0x5265c00L;
        else
            return false;
        _mth027F("Time frame set to: " + s);
        return true;
    }

    private void _mth0281()
    {
        if(_fld0280 == null)
            return;
        long l = System.currentTimeMillis();
        l -= _fld019D * (long)_fld026E;
        long l1 = l - 30L * _fld019D;
        long l2 = l - 60L * _fld019D;
        long l3 = l - 90L * _fld019D;
        results30 = new GenReportFrame();
        results60 = new GenReportFrame();
        results90 = new GenReportFrame();
        resultsCurrent = new GenReportFrame();
        _mth027F("Tally current set");
        GenReportFrame genreportframe = _fld0281;
        String s = genreportframe.startupTime;
        for(resultsCurrent.startupTime = s; genreportframe != null && s != null && genreportframe.startupTime != null && s.equals(genreportframe.startupTime); genreportframe = genreportframe._fld0284)
        {
            _mth0280(genreportframe, l);
            resultsCurrent.mergeFrame(genreportframe);
        }

        _mth027F(" ");
        _mth027F("Purge for daysback: " + l);
        genreportframe = _fld0281;
        long l4 = 0L;
        GenReportFrame genreportframe1;
        for(; genreportframe != null; genreportframe = genreportframe1)
        {
            long l5 = genreportframe.currentTime + (genreportframe.statTime >> 1);
            if(l5 <= l)
                break;
            _mth0280(genreportframe, l);
            genreportframe1 = genreportframe._fld0284;
            if(genreportframe1 != null)
            {
                genreportframe._fld0284 = null;
                genreportframe1._fld0283 = null;
            }
            _fld0281 = genreportframe1;
            if(_fld0281 == null)
                _fld0280 = null;
        }

        _mth027F(" ");
        _mth027F("Tally 30 Days, " + l1);
        for(genreportframe = _fld0281; genreportframe != null; genreportframe = genreportframe._fld0284)
        {
            long l6 = genreportframe.currentTime + (genreportframe.statTime >> 1);
            if(l6 < l1)
                break;
            _mth0280(genreportframe, l);
            results30.mergeFrame(genreportframe);
        }

        _mth027F(" ");
        _mth027F("Tally 60 Days: " + l2);
        for(; genreportframe != null; genreportframe = genreportframe._fld0284)
        {
            long l7 = genreportframe.currentTime + (genreportframe.statTime >> 1);
            if(l7 < l2)
                break;
            _mth0280(genreportframe, l);
            results60.mergeFrame(genreportframe);
        }

        _mth027F(" ");
        _mth027F("Tally 90 Days: " + l3);
        for(; genreportframe != null; genreportframe = genreportframe._fld0284)
        {
            long l8 = genreportframe.currentTime + (genreportframe.statTime >> 1);
            if(l8 < l3)
                break;
            _mth0280(genreportframe, l);
            results90.mergeFrame(genreportframe);
        }

    }

    private String _fld027F[];
    public static final int KEY_COUNT = 31;
    public static final int BEGIN = 0;
    public static final int START_TIME = 1;
    public static final int CUR_TIME = 2;
    public static final int STAT_TIME = 3;
    public static final int MAX_REQUESTS = 4;
    public static final int SWF_CNT = 5;
    public static final int SWF_AVG_SIZE = 6;
    public static final int SWF_AVG_TIME = 7;
    public static final int SWF_MAX_SIZE = 8;
    public static final int SWF_MAX_TIME = 9;
    public static final int GIF_CNT = 10;
    public static final int GIF_AVG_SIZE = 11;
    public static final int GIF_AVG_TIME = 12;
    public static final int GIF_MAX_SIZE = 13;
    public static final int GIF_MAX_TIME = 14;
    public static final int JPG_CNT = 15;
    public static final int JPG_AVG_SIZE = 16;
    public static final int JPG_AVG_TIME = 17;
    public static final int JPG_MAX_SIZE = 18;
    public static final int JPG_MAX_TIME = 19;
    public static final int PNG_CNT = 20;
    public static final int PNG_AVG_SIZE = 21;
    public static final int PNG_AVG_TIME = 22;
    public static final int PNG_MAX_SIZE = 23;
    public static final int PNG_MAX_TIME = 24;
    public static final int QTM_CNT = 25;
    public static final int QTM_AVG_SIZE = 26;
    public static final int QTM_AVG_TIME = 27;
    public static final int QTM_MAX_SIZE = 28;
    public static final int QTM_MAX_TIME = 29;
    public static final int END = 30;
    GenReportFrame _fld0280;
    GenReportFrame _fld0281;
    public GenReportFrame results30;
    public GenReportFrame results60;
    public GenReportFrame results90;
    public GenReportFrame resultsCurrent;
    private long _fld019D;
    private int _fld026E;
    private boolean _fld0282;
}