1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package Torello.HTML.Tools.Images;

import Torello.Java.StrPrint;

class ResultsToString 
{
    // Used in the above toString() method
    private static final String COMMA = ", ";

    static String run(final Results r)
    {
        final StringBuilder sb = new StringBuilder();


        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        // NOTE: These arrays, themselves can never be null - BUT THEIR CONTENTS ARE OFTEN NULL
        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

        for (int i=0; i < r.urls.length; i++)
        {
            if (r.b64EncodedImg[i]) sb.append("Base 64 Encoded Image\n");

            else sb.append(
                "URL: " + ((r.urls[i] == null)
                    ? "null"
                    : StrPrint.abbrev(r.urls[i].toString(), 50, true, " ... ", 100)) +
                '\n'
            );

            boolean comma = false;

            if (r.skipped[i] == true)
            {
                sb.append("    SKIPPED");
                comma = true;
            }

            if (r.imageFormats[i] != null)
            {
                sb.append(comma ? COMMA : "    ");
                sb.append("Format: " + r.imageFormats[i]);
                comma = true;
            }

            if (r.sizes[i] > 0)
            {
                sb.append(comma ? COMMA : "    ");
                sb.append("Size: " + StrPrint.commas(r.sizes[i]));
                comma = true;
            }

            if (r.widths[i] > 0)
            {
                sb.append(comma ? COMMA : "    ");
                sb.append("W: " + StrPrint.commas(r.widths[i]));
                comma = true;
            }

            if (r.heights[i] > 0)
            {
                sb.append(comma ? COMMA : "    ");
                sb.append("H: " + StrPrint.commas(r.heights[i]));
                comma = true;
            }

            if (comma) sb.append('\n');

            comma = false;

            if (r.fileNames[i] != null)
            {
                sb.append("    FileName: [" + r.fileNames[i] + ']');
                comma = true;
            }

            if (r.saveDirectories[i] != null)
            {
                sb.append(comma ? COMMA : "    ");
                sb.append("Dir: [" + StrPrint.abbrev(r.saveDirectories[i], 30, true, null, 60) + ']');
                comma = true;
            }

            if (comma) sb.append('\n');

            if (r.exceptions[i] != null)
                sb.append("    Thrown: " + r.exceptions[i].getClass().getName() + '\n');

            if (i < (r.urls.length - 1)) sb.append('\n');
        }

        return sb.toString();
    }

}