Package delight.nashornsandbox.internal
Class LinkedHashMapSecuredJsCache
java.lang.Object
delight.nashornsandbox.internal.LinkedHashMapSecuredJsCache
- All Implemented Interfaces:
SecuredJsCache
Default implementation of
SecuredJsCache
, uses a LinkedHashMap
as its cache and is not thread-safe. Also, mixing scripts with missing braces
allowed and not allowed is forbidden.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final LinkedHashMap
<String, String> -
Constructor Summary
ConstructorsConstructorDescriptionLinkedHashMapSecuredJsCache
(LinkedHashMap<String, String> linkedHashMap, boolean allowNoBraces) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
assertConfiguration
(boolean allowNoBraces) getOrCreate
(String js, boolean allowNoBraces, Supplier<String> producer) Gets a value from the cache and tries to create it if it couldn't be found.
-
Field Details
-
map
-
allowNoBraces
private final boolean allowNoBraces
-
-
Constructor Details
-
LinkedHashMapSecuredJsCache
public LinkedHashMapSecuredJsCache(LinkedHashMap<String, String> linkedHashMap, boolean allowNoBraces)
-
-
Method Details
-
getOrCreate
Description copied from interface:SecuredJsCache
Gets a value from the cache and tries to create it if it couldn't be found.- Specified by:
getOrCreate
in interfaceSecuredJsCache
- Parameters:
js
- the raw javascript codeallowNoBraces
- whether missing braces are allowed.producer
- if no cached value could be found, this is used to create the value- Returns:
- the cached or created value, or null if it could be neither found in the cache nor created.
-
assertConfiguration
private void assertConfiguration(boolean allowNoBraces)
-