01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.text.templates;
11:
12: /**
13: * A simple template variable resolver, which always evaluates to a defined string.
14: * <p>
15: * Clients may instantiate and extend this class.
16: * </p>
17: *
18: * @since 3.0
19: */
20: public class SimpleTemplateVariableResolver extends
21: TemplateVariableResolver {
22:
23: /** The string to which this variable evaluates. */
24: private String fEvaluationString;
25:
26: /*
27: * @see TemplateVariableResolver#TemplateVariableResolver(String, String)
28: */
29: protected SimpleTemplateVariableResolver(String type,
30: String 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 evaluationString) {
40: fEvaluationString = evaluationString;
41: }
42:
43: /*
44: * @see TemplateVariableResolver#evaluate(TemplateContext)
45: */
46: protected String 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: }
|