Package delight.nashornsandbox.internal
Class LinkedHashMapSecuredJsCache
- java.lang.Object
-
- delight.nashornsandbox.internal.LinkedHashMapSecuredJsCache
-
- All Implemented Interfaces:
SecuredJsCache
class LinkedHashMapSecuredJsCache extends java.lang.Object implements SecuredJsCache
Default implementation ofSecuredJsCache, uses aLinkedHashMapas its cache and is not thread-safe. Also, mixing scripts with missing braces allowed and not allowed is forbidden.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanallowNoBracesprivate java.util.LinkedHashMap<java.lang.String,java.lang.String>map
-
Constructor Summary
Constructors Constructor Description LinkedHashMapSecuredJsCache(java.util.LinkedHashMap<java.lang.String,java.lang.String> linkedHashMap, boolean allowNoBraces)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidassertConfiguration(boolean allowNoBraces)java.lang.StringgetOrCreate(java.lang.String js, boolean allowNoBraces, java.util.function.Supplier<java.lang.String> producer)Gets a value from the cache and tries to create it if it couldn't be found.
-
-
-
Method Detail
-
getOrCreate
public java.lang.String getOrCreate(java.lang.String js, boolean allowNoBraces, java.util.function.Supplier<java.lang.String> producer)Description copied from interface:SecuredJsCacheGets a value from the cache and tries to create it if it couldn't be found.- Specified by:
getOrCreatein 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)
-
-