Package org.elasticsearch.painless.spi
Class WhitelistLoader
java.lang.Object
org.elasticsearch.painless.spi.WhitelistLoader
Loads and creates a
Whitelist from one to many text files.-
Method Summary
Modifier and TypeMethodDescriptionstatic WhitelistloadFromResourceFiles(Class<?> resource, String... filepaths) Loads and creates aWhitelistfrom one to many text files using only the base annotation parsers.static WhitelistloadFromResourceFiles(Class<?> resource, Map<String, WhitelistAnnotationParser> parsers, String... filepaths) Loads and creates aWhitelistfrom one to many text files.
-
Method Details
-
loadFromResourceFiles
Loads and creates aWhitelistfrom one to many text files using only the base annotation parsers. SeeloadFromResourceFiles(Class, Map, String...)for information on how to structure a whitelist text file. -
loadFromResourceFiles
public static Whitelist loadFromResourceFiles(Class<?> resource, Map<String, WhitelistAnnotationParser> parsers, String... filepaths) Loads and creates aWhitelistfrom one to many text files. The file paths are passed in as an array ofStrings with a singleClassto be be used to load the resources where eachStringis the path of a single text file. TheClass'sClassLoaderwill be used to lookup the Java reflection objects for each individualClass,Constructor,Method, andFieldspecified as part of the whitelist in the text file. A single pass is made through each file to collect all the information about each class, constructor, method, and field. Most validation will be done at a later point after all whitelists have been gathered and their merging takes place. A painless type name is one of the following:- def - The Painless dynamic type which is automatically included without a need to be whitelisted.
- fully-qualified Java type name - Any whitelisted Java class will have the equivalent name as a Painless type name with the exception that any dollar symbols used as part of inner classes will be replaced with dot symbols.
- short Java type name - The text after the final dot symbol of any specified Java class. A short type Java name may be excluded by using the 'no_import' attribute during Painless class parsing as described later.
- Blank lines will be ignored by the parser.
- Comments may be created starting with a pound '#' symbol and end with a newline. These will be ignored by the parser.
- Primitive types may be specified starting with 'class' and followed by the Java type name, an opening bracket, a newline, a closing bracket, and a final newline.
- Complex types may be specified starting with 'class' and followed by the fully-qualified Java
class name, optionally followed by a 'no_import' attribute, an opening bracket, a newline,
constructor/method/field specifications, a closing bracket, and a final newline. Within a complex
type the following may be parsed:
- A constructor may be specified starting with an opening parenthesis, followed by a comma-delimited list of Painless type names corresponding to the type/class names for the equivalent Java parameter types (these must be whitelisted as well), a closing parenthesis, and a newline.
- A method may be specified starting with a Painless type name for the return type, followed by the Java name of the method (which will also be the Painless name for the method), an opening parenthesis, a comma-delimited list of Painless type names corresponding to the type/class names for the equivalent Java parameter types (these must be whitelisted as well), a closing parenthesis, and a newline.
- An augmented method may be specified starting with a Painless type name for the return type, followed by the fully qualified Java name of the class the augmented method is part of (this class does not need to be whitelisted), the Java name of the method (which will also be the Painless name for the method), an opening parenthesis, a comma-delimited list of Painless type names corresponding to the type/class names for the equivalent Java parameter types (these must be whitelisted as well), a closing parenthesis, and a newline.
- A field may be specified starting with a Painless type name for the equivalent Java type of the field, followed by the Java name of the field (which all be the Painless name for the field), and a newline.
- Annotations may be added starting with an at, followed by a name, optionally an opening brace, a parameter name, an equals, an opening quote, an argument value, a closing quote, (possibly repeated for multiple arguments,) and a closing brace. Multiple annotations may be added after a class (before the opening bracket), after a method, or after field.
# primitive types class int -> int { } # complex types class my.package.Example @no_import { # constructors () (int) (def, def) (Example, def) # method Example add(int, def) int add(Example, Example) void example() @deprecated[use example 2 instead] void example2() # augmented Example some.other.Class sub(Example, int, def) # fields int value0 int value1 def value2 }
-