129
|
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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.templates.SimpleTemplateVariableResolver;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17
|
|
18 /**
|
|
19 * A simple template variable resolver, which always evaluates to a defined string.
|
|
20 * <p>
|
|
21 * Clients may instantiate and extend this class.
|
|
22 * </p>
|
|
23 *
|
|
24 * @since 3.0
|
|
25 */
|
|
26 public class SimpleTemplateVariableResolver : TemplateVariableResolver {
|
|
27
|
|
28 /** The string to which this variable evaluates. */
|
|
29 private String fEvaluationString;
|
|
30
|
|
31 /*
|
|
32 * @see TemplateVariableResolver#TemplateVariableResolver(String, String)
|
|
33 */
|
|
34 protected SimpleTemplateVariableResolver(String type, String description) {
|
|
35 super(type, description);
|
|
36 }
|
|
37
|
|
38 /**
|
|
39 * Sets the string to which this variable evaluates.
|
|
40 *
|
|
41 * @param evaluationString the evaluation string, may be <code>null</code>.
|
|
42 */
|
|
43 public final void setEvaluationString(String evaluationString) {
|
|
44 fEvaluationString= evaluationString;
|
|
45 }
|
|
46
|
|
47 /*
|
|
48 * @see TemplateVariableResolver#evaluate(TemplateContext)
|
|
49 */
|
|
50 protected String resolve(TemplateContext context) {
|
|
51 return fEvaluationString;
|
|
52 }
|
|
53
|
|
54 /**
|
|
55 * Returns always <code>true</code>, since simple variables are normally
|
|
56 * unambiguous.
|
|
57 *
|
|
58 * @param context {@inheritDoc}
|
|
59 * @return <code>true</code>
|
|
60 */
|
|
61 protected bool isUnambiguous(TemplateContext context) {
|
|
62 return true;
|
|
63 }
|
|
64 }
|