Eclipse Platform Release 3.7

## org.eclipse.jface.text.templates
Class TemplateVariableResolver

    java.lang.Object
      org.eclipse.jface.text.templates.TemplateVariableResolver

Direct Known Subclasses:
  SimpleTemplateVariableResolver

    public class TemplateVariableResolver

extends Object

A `TemplateVariableResolver` resolves `TemplateVariables` of a certain type inside a `TemplateContext`.

Clients may instantiate and extend this class.

Since:
  3.0
See Also:
  `TemplateVariable`

Constructor Summary
`` `TemplateVariableResolver()` Creates an empty instance.
`protected` `TemplateVariableResolver(String type, String description)` Creates an instance of `TemplateVariableResolver`.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TemplateVariableResolver

    protected TemplateVariableResolver(String type,
                                       String description)

  Creates an instance of `TemplateVariableResolver`.

  Parameters:
    `type` - the name of the type
    `description` - 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 Detail

### getType

    public String getType()

  Returns the type of this resolver.

  Returns:
    the type

### getDescription

    public String getDescription()

  Returns the description for the resolver.

  Returns:
    the description for the resolver

### resolve

    protected String resolve(TemplateContext context)

  Returns an instance of the type resolved by the receiver available in `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.

  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

    protected String[] resolveAll(TemplateContext context)

  Returns all possible bindings available in `context`. The default implementation simply returns an array which contains the result of `resolve(TemplateContext)`, or an empty array if that call returns `null`.

  Parameters:
    `context` - the context in which to resolve the type
  Returns:
    an array of possible bindings of this type in `context`

### resolve

    public void resolve(TemplateVariable variable,
                        TemplateContext context)

  Resolves `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[])`.

  Parameters:
    `context` - the context in which variable is resolved
    `variable` - the variable to resolve

### isUnambiguous

    protected boolean isUnambiguous(TemplateContext context)

  Returns whether this resolver is able to resolve unambiguously. When resolving a `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.

  Parameters:
    `context` - the context in which the resolved check should be evaluated
  Returns:
    `true` if the receiver is unambiguously resolvable in `context`, `false` otherwise

### setDescription

    public final void setDescription(String description)

  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

    public final void setType(String type)

  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

Eclipse Platform Release 3.7

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2011. All rights reserved.