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
Constructors -
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).booleancontainsNamespacedFunction(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:ScriptHostFunctionResolverAttempts to find if this resolver has a function by its calling name and namespace.A
nullnamespace is valid, since it is a host call without declaring a namespace.Names must be resolved case-insensitively!
If this returns
truefor a function name,ScriptHostFunctionResolver.getNamespacedFunction(String, String)must NOT return null if called with that name!- Specified by:
containsNamespacedFunctionin 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:ScriptHostFunctionResolverAttempts to resolve a pertinent function by its calling name.A
nullnamespace 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 returnfalseif called with that name!The same function must be returned if this is called again with the same name!
- Specified by:
getNamespacedFunctionin 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:
-