public class TemplateVariableResolver extends Object
TemplateVariableResolver
resolves TemplateVariables
of a certain type inside a TemplateContext
.
Clients may instantiate and extend this class.
TemplateVariable
Modifier | Constructor and Description |
---|---|
|
TemplateVariableResolver()
Creates an empty instance.
|
protected |
TemplateVariableResolver(String type,
String description)
Creates an instance of
TemplateVariableResolver . |
Modifier and Type | Method and Description |
---|---|
String |
getDescription()
Returns the description for the resolver.
|
String |
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 in
context . |
void |
resolve(TemplateVariable variable,
TemplateContext context)
Resolves
variable in context . |
protected String[] |
resolveAll(TemplateContext context)
Returns all possible bindings available in
context . |
void |
setDescription(String description)
Sets the description.
|
void |
setType(String type)
Sets the type name.
|
protected TemplateVariableResolver(String type, String description)
TemplateVariableResolver
.type
- the name of the typedescription
- the description for the typepublic TemplateVariableResolver()
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.
public String getType()
public String getDescription()
protected String resolve(TemplateContext context)
context
.
To resolve means to provide a binding to a concrete text object (a
String
) in the given context.
The default implementation looks up the type in the context.
context
- the context in which to resolve the typenull
if it cannot be determinedprotected String[] resolveAll(TemplateContext context)
context
. The default
implementation simply returns an array which contains the result of
resolve(TemplateContext)
, or an empty array if that call returns
null
.context
- the context in which to resolve the typecontext
public void resolve(TemplateVariable variable, TemplateContext context)
variable
in context
. To resolve
means to find a valid binding of the receiver's type in the given TemplateContext
.
If the variable can be successfully resolved, its value is set using
TemplateVariable.setValues(String[])
.context
- the context in which variable is resolvedvariable
- the variable to resolveprotected boolean isUnambiguous(TemplateContext context)
TemplateVariable
, its isUmambiguous
state is set to the one of this resolver. By default, this method
returns false
. Clients can overwrite this method to give
a hint about whether there should be e.g. prompting for input values for
ambiguous variables.context
- the context in which the resolved check should be
evaluatedtrue
if the receiver is unambiguously resolvable
in context
, false
otherwisepublic final void setDescription(String 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.
description
- the description of this resolverpublic final void setType(String type)
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.
type
- the type name of this resolver
Copyright (c) 2000, 2013 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.