KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > templates > SimpleTemplateVariableResolver


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.text.templates;
12
13
14 /**
15  * A simple template variable resolver, which always evaluates to a defined string.
16  * <p>
17  * Clients may instantiate and extend this class.
18  * </p>
19  *
20  * @since 3.0
21  */

22 public class SimpleTemplateVariableResolver extends TemplateVariableResolver {
23
24     /** The string to which this variable evaluates. */
25     private String JavaDoc fEvaluationString;
26
27     /*
28      * @see TemplateVariableResolver#TemplateVariableResolver(String, String)
29      */

30     protected SimpleTemplateVariableResolver(String JavaDoc type, String JavaDoc description) {
31         super(type, description);
32     }
33
34     /**
35      * Sets the string to which this variable evaluates.
36      *
37      * @param evaluationString the evaluation string, may be <code>null</code>.
38      */

39     public final void setEvaluationString(String JavaDoc evaluationString) {
40         fEvaluationString= evaluationString;
41     }
42
43     /*
44      * @see TemplateVariableResolver#evaluate(TemplateContext)
45      */

46     protected String JavaDoc resolve(TemplateContext context) {
47         return fEvaluationString;
48     }
49
50     /**
51      * Returns always <code>true</code>, since simple variables are normally
52      * unambiguous.
53      *
54      * @param context {@inheritDoc}
55      * @return <code>true</code>
56      */

57     protected boolean isUnambiguous(TemplateContext context) {
58         return true;
59     }
60 }
61
Popular Tags