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
package Torello.JavaDoc.Annotations;

import Torello.JavaDoc.Messager.Where_Am_I;
import Torello.JavaDoc.Messager.Messager;
import Torello.JDUInternal.Miscellaneous.Where.JDUAnnotations;

import Torello.Java.ReadOnly.ReadOnlyList;

import Torello.Java.StrPrint;
import Torello.Java.StrCh;

import static Torello.Java.C.*;


class IHTErrorCheck
{
    private static final Where_Am_I WHERE_AM_I = JDUAnnotations.IHTErrorCheck;

    // IHTMirror Fields:
    // 
    // public final Background             background;
    // public final String                 title;
    // public final ReadOnlyList<String>   divCSSClass;
    // public final ReadOnlyList<String>   tableCSSClass;

    static void check(
            final IHTMirror ihtMirror,


            // This is the Annotation, as a simple Java-String.  This is very useful for
            // Error-Printing with the Messager.  That's the only purpose of it

            final String annotationAsStr,


            // The Signature of the Detail-Entity onto which this "@LinkJavaSource" Annotation
            // was placed.  Very important for error messages

            final String signature
        )
    {
        if ((ihtMirror.divCSSClass != null) && (ihtMirror.divCSSClass.size() > 0))
            checkCSSClasses(ihtMirror.divCSSClass, "divCSSClass", annotationAsStr, signature);

        if ((ihtMirror.tableCSSClass != null) && (ihtMirror.tableCSSClass.size() > 0))
            checkCSSClasses(ihtMirror.tableCSSClass, "tableCSSClass", annotationAsStr, signature);


        // THIS TEST IS BLOCK-COPIED IDENTICAL TO THE TEST THAT IS LOCATED INSIDE
        // THE ERROR-MESSAGE TEXT WAS ALSO BLOCK-COPIED
        // 
        // "Torello.JDUInternal.Annotations.EntityAnnotations.Processor.IntoHTMLTableProcessor"

        final boolean test =
                (! StrCh.containsOR(ihtMirror.title, '\t', '\n', '\r'))
            &&  (ihtMirror.title.length() <= 300);


        if (! test) Messager.userErrorContinue(
            "Annotation Placed:\n" +
            "    " + BCYAN + annotationAsStr + RESET + '\n' +
            "String Annotation-Parameter 'title()' was passed " +
                "[" + ihtMirror.title + "]\n" +
            "However, this String may not contain the characters: '\\t', '\\n' or '\\r'\n" +
            "Nor may it be more than 300 Characters long.\n",
            JDUAnnotations.IHTErrorCheck
        );
    }

    static void checkCSSClasses(
            final ReadOnlyList<String>  cssClasses,
            final String                elemName,
            final String                annotationAsStr,
            final String                signature
        )
    {
        final int SIZE = cssClasses.size();

        for (int i=0; i < SIZE; i++)
        {
            final String cssClass = cssClasses.get(i);

            if (cssClass == null) Messager.userErrorContinue(
                "Annotation Placed:\n" +
                "    " + BCYAN + annotationAsStr + RESET + '\n' +
                "null has been passed to the " + (i+1) + StrPrint.ordinalIndicator(i+1) +
                "of the String-Array for the Annotation-Element Named: " +
                '[' + elemName + "]\n",
                JDUAnnotations.IHTErrorCheck
            );
        }
    }
}