35
35
public final class WhitelistLoader {
36
36
37
37
/**
38
- * Loads and creates a {@link Whitelist} from one to many text files. The file paths are passed in as an array of
38
+ * Loads and creates a {@link Whitelist} from one to many text files. The file paths are passed in as an array of
39
39
* {@link String}s with a single {@link Class} to be be used to load the resources where each {@link String}
40
- * is the path of a single text file. The {@link Class}'s {@link ClassLoader} will be used to lookup the Java
40
+ * is the path of a single text file. The {@link Class}'s {@link ClassLoader} will be used to lookup the Java
41
41
* reflection objects for each individual {@link Class}, {@link Constructor}, {@link Method}, and {@link Field}
42
42
* specified as part of the whitelist in the text file.
43
43
*
44
44
* A single pass is made through each file to collect all the information about each class, constructor, method,
45
- * and field. Most validation will be done at a later point after all whitelists have been gathered and their
45
+ * and field. Most validation will be done at a later point after all whitelists have been gathered and their
46
46
* merging takes place.
47
47
*
48
48
* A painless type name is one of the following:
@@ -52,15 +52,15 @@ public final class WhitelistLoader {
52
52
* <li> fully-qualified Java type name - Any whitelisted Java class will have the equivalent name as
53
53
* a Painless type name with the exception that any dollar symbols used as part of inner classes will
54
54
* be replaced with dot symbols. </li>
55
- * <li> short Java type name - The text after the final dot symbol of any specified Java class. A
55
+ * <li> short Java type name - The text after the final dot symbol of any specified Java class. A
56
56
* short type Java name may be excluded by using the 'only_fqn' token during Painless class parsing
57
57
* as described later. </li>
58
58
* </ul>
59
59
*
60
60
* The following can be parsed from each whitelist text file:
61
61
* <ul>
62
62
* <li> Blank lines will be ignored by the parser. </li>
63
- * <li> Comments may be created starting with a pound '#' symbol and end with a newline. These will
63
+ * <li> Comments may be created starting with a pound '#' symbol and end with a newline. These will
64
64
* be ignored by the parser. </li>
65
65
* <li> Primitive types may be specified starting with 'class' and followed by the Java type name,
66
66
* an opening bracket, a newline, a closing bracket, and a final newline. </li>
@@ -93,10 +93,10 @@ public final class WhitelistLoader {
93
93
*
94
94
* Note there must be a one-to-one correspondence of Painless type names to Java type/class names.
95
95
* If the same Painless type is defined across multiple files and the Java class is the same, all
96
- * specified constructors, methods, and fields will be merged into a single Painless type. The
96
+ * specified constructors, methods, and fields will be merged into a single Painless type. The
97
97
* Painless dynamic type, 'def', used as part of constructor, method, and field definitions will
98
- * be appropriately parsed and handled. Painless complex types must be specified with the
99
- * fully-qualified Java class name. Method argument types, method return types, and field types
98
+ * be appropriately parsed and handled. Painless complex types must be specified with the
99
+ * fully-qualified Java class name. Method argument types, method return types, and field types
100
100
* must be specified with Painless type names (def, fully-qualified, or short) as described earlier.
101
101
*
102
102
* The following example is used to create a single whitelist text file:
@@ -132,7 +132,7 @@ public final class WhitelistLoader {
132
132
* }
133
133
*/
134
134
public static Whitelist loadFromResourceFiles (Class <?> resource , String ... filepaths ) {
135
- List <WhitelistClass > whitelistStructs = new ArrayList <>();
135
+ List <WhitelistClass > whitelistClasses = new ArrayList <>();
136
136
137
137
// Execute a single pass through the whitelist text files. This will gather all the
138
138
// constructors, methods, augmented methods, and fields for each whitelisted class.
@@ -143,7 +143,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
143
143
try (LineNumberReader reader = new LineNumberReader (
144
144
new InputStreamReader (resource .getResourceAsStream (filepath ), StandardCharsets .UTF_8 ))) {
145
145
146
- String whitelistStructOrigin = null ;
146
+ String whitelistClassOrigin = null ;
147
147
String javaClassName = null ;
148
148
boolean onlyFQNJavaClassName = false ;
149
149
List <WhitelistConstructor > whitelistConstructors = null ;
@@ -178,7 +178,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
178
178
throw new IllegalArgumentException ("invalid class definition: failed to parse class name [" + line + "]" );
179
179
}
180
180
181
- whitelistStructOrigin = "[" + filepath + "]:[" + number + "]" ;
181
+ whitelistClassOrigin = "[" + filepath + "]:[" + number + "]" ;
182
182
javaClassName = tokens [0 ];
183
183
184
184
// Reset all the constructors, methods, and fields to support a new class.
@@ -194,11 +194,11 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
194
194
throw new IllegalArgumentException ("invalid class definition: extraneous closing bracket" );
195
195
}
196
196
197
- whitelistStructs .add (new WhitelistClass (whitelistStructOrigin , javaClassName , onlyFQNJavaClassName ,
197
+ whitelistClasses .add (new WhitelistClass (whitelistClassOrigin , javaClassName , onlyFQNJavaClassName ,
198
198
whitelistConstructors , whitelistMethods , whitelistFields ));
199
199
200
200
// Set all the variables to null to ensure a new class definition is found before other parsable values.
201
- whitelistStructOrigin = null ;
201
+ whitelistClassOrigin = null ;
202
202
javaClassName = null ;
203
203
onlyFQNJavaClassName = false ;
204
204
whitelistConstructors = null ;
@@ -300,7 +300,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
300
300
}
301
301
ClassLoader loader = AccessController .doPrivileged ((PrivilegedAction <ClassLoader >)resource ::getClassLoader );
302
302
303
- return new Whitelist (loader , whitelistStructs );
303
+ return new Whitelist (loader , whitelistClasses );
304
304
}
305
305
306
306
private WhitelistLoader () {}
0 commit comments