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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181 | package Torello.JavaDoc.Annotations;
import Torello.JavaDoc.Messager.Messager;
import Torello.JavaDoc.Messager.MsgPrintTools;
import Torello.JavaDoc.Messager.MsgVerbose;
import Torello.JavaDoc.Annotations.CSSLinks;
import Torello.JDUInternal.Miscellaneous.Where.JDUAnnotations;
import Torello.Java.ReadOnly.ReadOnlyList;
import Torello.Java.ReadOnly.ReadOnlyArrayList;
import Torello.Java.StrCSV;
import Torello.Java.StrPrint;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.AssignmentTree;
import static com.sun.source.tree.Tree.Kind.ASSIGNMENT;
import java.util.List;
// EXPORTS:
// public String[] FileNames();
//
// package Torello.JDUInternal.Features.USER_SUPPLIED_CSS_FILES
// The classes in this package do the processing for inserting the '.css' Files which the user
// has requested be placed into his Java-Doc '.html' Web-Page. These '.css' Files must be
// located in the '../upgrade-files/stylesheets/' directory. These '.css' Files must either:
//
// 1) obey the standard naming convention and have the exact same file-name as the
// Java-Class which has been annotated by the @CSSLinks Annotation
//
// 2) have a name equal to one of the names provided to the Annotation-Element "FileNames"
/**
* An internally used data-record class used for storing all user-supplied annotation data
* associated with a single use / application of the {@link CSSLinks} annotation.
*
* @see Torello.JavaDoc.Annotations.CSSLinks
*/
@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="MIRROR_JDHBI")
public class CSSLMirror implements AnnotationMirror
{
// ********************************************************************************************
// ********************************************************************************************
// Public, Final, ReadOnly, Mirrored Fields
// ********************************************************************************************
// ********************************************************************************************
/** Holds data extracted from {@link CSSLinks#FileNames()} */
public final ReadOnlyList<String> fileNames;
// ********************************************************************************************
// ********************************************************************************************
// interface AnnotationMirror
// ********************************************************************************************
// ********************************************************************************************
// Stores the actual text of the @StaticFunctional annotation which was placed.
// This is nothing more than the exact line that was originally inserted into the class.
// The only reason this is even needed (in case you are wondering) is because the error
// checking & error printing code outputs this text when printing an error message.
private final String annotationAsStr;
/** {@inheritDoc} */ @Override
public String getAnnotationAsString() { return annotationAsStr; }
/** {@inheritDoc} */ @Override
public String getAnnotationName() { return "CSSLinks"; }
// ********************************************************************************************
// ********************************************************************************************
// Package-Private Constructor, Invoked by class "TypeAnnotationMirrors"
// ********************************************************************************************
// ********************************************************************************************
CSSLMirror(
final List<? extends ExpressionTree> arguments,
final String annotationAsStr
)
{
this.annotationAsStr = annotationAsStr;
ReadOnlyList<String> fileNames = null;
if (arguments.size() == 0)
{
this.fileNames = ReadOnlyArrayList.emptyROAL();
return;
}
for (ExpressionTree argument : arguments)
{
/*
System.out.println(
"argument: " + argument.toString() + '\n' +
"argument.getKind(): " + argument.getKind().toString() + '\n' +
"argument.getClass().getSimpleName(): " + argument.getClass().getSimpleName()
);
*/
// System.out.println(argument);
if (argument.getKind() != ASSIGNMENT) throw Messager.assertFail(
"The ExpressionTree returned by the @CSSLinks arguments list was not of " +
"type ASSIGNMENT, but rather " + argument.getKind() + '\n' +
"ExpressionTree.toString(): " + argument.toString() + '\n' +
"All Annotation Expressions: " + StrCSV.toCSV(arguments, true, true, null) + '\n' +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.CSSLMirror
);
String elemName = ((AssignmentTree) argument).getVariable().toString();
ExpressionTree elemValue = ((AssignmentTree) argument).getExpression();
/*
System.out.println(
" elemName: " + elemName + '\n' +
" elemValue.toString(): " + elemValue.toString() + '\n' +
" elemValue.getKind(): " + elemValue.getKind().toString() + '\n' +
" elemValue.getClass(): " + elemValue.getClass().getSimpleName() + '\n'
);
*/
if (elemName.equals("FileNames"))
{
if (fileNames != null) throw Messager.assertFail(
"There are apparently multiple instances of the Annotation-Element " +
"'FileNames' included with the @CSSLinks Annotation" + '\n' +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.CSSLMirror
);
fileNames =
HELPER.handleStringArray(elemValue, "FileNames", JDUAnnotations.CSSLMirror);
}
else throw Messager.assertFail(
"There was an Expression Variable-Name that was not 'FileNames' but rather: " +
elemName +
MsgPrintTools.annotationProcessingError(),
JDUAnnotations.CSSLMirror
);
}
this.fileNames = fileNames;
if (MsgVerbose.isVerbose()) MsgVerbose.println(
"@CSSFiles Annotation-Processing Mirror Class:" +
" fileNames: " + StrCSV.toCSV(this.fileNames, true, false, null)
);
}
// ********************************************************************************************
// ********************************************************************************************
// toString
// ********************************************************************************************
// ********************************************************************************************
/** {@inheritDoc} */ @Override
public String toString()
{
// public final ReadOnlyList<String> fileNames;
//
// " fileNames: ".length() => 15
return
annotationAsStr + '\n' +
"{\n" +
" fileNames: " + HELPER.TOSTR(this.fileNames, 15) + '\n' +
'}';
}
}
|