Class CompoundHostFunctionResolver
java.lang.Object
com.blackrook.rookscript.resolvers.hostfunction.CompoundHostFunctionResolver
- All Implemented Interfaces:
ScriptHostFunctionResolver
A host function resolver that is a combination of multiple resolvers.
Functions are resolved in the order that they are added to this resolver.
- Author:
- Matthew Tropiano
-
Field Summary
Fields inherited from interface com.blackrook.rookscript.resolvers.ScriptHostFunctionResolver
EMPTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddNamedResolver
(String namespace, ScriptFunctionResolver resolver) Adds a resolver in a namespace.addResolver
(ScriptFunctionResolver resolver) Adds a global resolver.clear()
Removes all resolvers (and all namespaced ones).boolean
containsNamespacedFunction
(String namespace, String name) Attempts to find if this resolver has a function by its calling name and namespace.getNamespacedFunction
(String namespace, String name) Attempts to resolve a pertinent function by its calling name.
-
Constructor Details
-
CompoundHostFunctionResolver
public CompoundHostFunctionResolver()Creates a new CompoundHostFunctionResolver.
-
-
Method Details
-
addResolver
Adds a global resolver.- Parameters:
resolver
- the resolver to add.- Returns:
- itself.
- See Also:
-
addNamedResolver
public CompoundHostFunctionResolver addNamedResolver(String namespace, ScriptFunctionResolver resolver) Adds a resolver in a namespace. This will replace a namespace if it already had a resolver assigned.- Parameters:
namespace
- the function namespace.resolver
- the resolver to add.- Returns:
- itself.
-
clear
Removes all resolvers (and all namespaced ones).- Returns:
- itself.
-
containsNamespacedFunction
Description copied from interface:ScriptHostFunctionResolver
Attempts to find if this resolver has a function by its calling name and namespace.A
null
namespace is valid, since it is a host call without declaring a namespace.Names must be resolved case-insensitively!
If this returns
true
for a function name,ScriptHostFunctionResolver.getNamespacedFunction(String, String)
must NOT return null if called with that name!- Specified by:
containsNamespacedFunction
in interfaceScriptHostFunctionResolver
- Parameters:
namespace
- the function namespace (null is valid!).name
- the name to find.- Returns:
- a corresponding function or null for no such function.
- See Also:
-
getNamespacedFunction
Description copied from interface:ScriptHostFunctionResolver
Attempts to resolve a pertinent function by its calling name.A
null
namespace is valid, since it is a host call without declaring a namespace.Names must be resolved case-insensitively!
If this returns a non-null for a function name,
ScriptHostFunctionResolver.containsNamespacedFunction(String, String)
must NOT returnfalse
if called with that name!The same function must be returned if this is called again with the same name!
- Specified by:
getNamespacedFunction
in interfaceScriptHostFunctionResolver
- Parameters:
namespace
- the function namespace (null is valid!).name
- the name to resolve.- Returns:
- a corresponding function or null for no such function.
- See Also:
-