Class TemplateVariableResolver
- Direct Known Subclasses:
SimpleTemplateVariableResolver
TemplateVariableResolver
resolves TemplateVariables
of a certain type inside a TemplateContext
.
Clients may instantiate and extend this class.
- Since:
- 3.0
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionCreates an empty instance.protected
TemplateVariableResolver
(String type, String description) Creates an instance ofTemplateVariableResolver
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the description for the resolver.getType()
Returns the type of this resolver.protected boolean
isUnambiguous
(TemplateContext context) Returns whether this resolver is able to resolve unambiguously.protected String
resolve
(TemplateContext context) Returns an instance of the type resolved by the receiver available incontext
.void
resolve
(TemplateVariable variable, TemplateContext context) Resolvesvariable
incontext
.protected String[]
resolveAll
(TemplateContext context) Returns all possible bindings available incontext
.final void
setDescription
(String description) Sets the description.final void
Sets the type name.
-
Constructor Details
-
TemplateVariableResolver
Creates an instance ofTemplateVariableResolver
.- Parameters:
type
- the name of the typedescription
- the description for the type
-
TemplateVariableResolver
public TemplateVariableResolver()Creates an empty instance.This is a framework-only constructor that exists only so that resolvers can be contributed via an extension point and that should not be called in client code except for subclass constructors; use
TemplateVariableResolver(String, String)
instead.
-
-
Method Details
-
getType
Returns the type of this resolver.- Returns:
- the type
-
getDescription
Returns the description for the resolver.- Returns:
- the description for the resolver
-
resolve
Returns an instance of the type resolved by the receiver available incontext
. To resolve means to provide a binding to a concrete text object (aString
) in the given context.The default implementation looks up the type in the context.
- Parameters:
context
- the context in which to resolve the type- Returns:
- the name of the text object of this type, or
null
if it cannot be determined
-
resolveAll
Returns all possible bindings available incontext
. The default implementation simply returns an array which contains the result ofresolve(TemplateContext)
, or an empty array if that call returnsnull
.- Parameters:
context
- the context in which to resolve the type- Returns:
- an array of possible bindings of this type in
context
-
resolve
Resolvesvariable
incontext
. To resolve means to find a valid binding of the receiver's type in the givenTemplateContext
. If the variable can be successfully resolved, its value is set usingTemplateVariable.setValues(String[])
.- Parameters:
context
- the context in which variable is resolvedvariable
- the variable to resolve
-
isUnambiguous
Returns whether this resolver is able to resolve unambiguously. When resolving aTemplateVariable
, itsisUmambiguous
state is set to the one of this resolver. By default, this method returnsfalse
. Clients can overwrite this method to give a hint about whether there should be e.g. prompting for input values for ambiguous variables.- Parameters:
context
- the context in which the resolved check should be evaluated- Returns:
true
if the receiver is unambiguously resolvable incontext
,false
otherwise
-
setDescription
Sets the description.This is a framework-only method that exists only so that resolvers can be contributed via an extension point and that should not be called in client code; use
TemplateVariableResolver(String, String)
instead.- Parameters:
description
- the description of this resolver
-
setType
Sets the type name.This is a framework-only method that exists only so that resolvers can be contributed via an extension point and that should not be called in client code; use
TemplateVariableResolver(String, String)
instead.- Parameters:
type
- the type name of this resolver
-