2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template.java;
7 import java.text.DateFormat;
10 import net.sourceforge.phpdt.internal.corext.template.SimpleTemplateVariable;
11 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
13 import net.sourceforge.phpdt.internal.corext.template.TemplateVariable;
16 * Global variables which are available in any context.
18 public class GlobalVariables {
21 * The cursor variable determines the cursor placement after template edition.
23 static class Cursor extends SimpleTemplateVariable {
25 super(JavaTemplateMessages.getString("GlobalVariables.variable.name.cursor"), JavaTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ //$NON-NLS-2$
26 setEvaluationString(""); //$NON-NLS-1$
32 * The dollar variable inserts an escaped dollar symbol.
34 static class Dollar extends SimpleTemplateVariable {
36 super(JavaTemplateMessages.getString("GlobalVariables.variable.name.dollar"), JavaTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
37 setEvaluationString("$"); //$NON-NLS-1$
43 * The date variable evaluates to the current date.
45 static class Date extends SimpleTemplateVariable {
47 super(JavaTemplateMessages.getString("GlobalVariables.variable.name.date"), JavaTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
50 public String evaluate(TemplateContext context) {
51 return DateFormat.getDateInstance().format(new java.util.Date());
56 * The time variable evaluates to the current time.
58 static class Time extends SimpleTemplateVariable {
60 super(JavaTemplateMessages.getString("GlobalVariables.variable.name.time"), JavaTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
63 public String evaluate(TemplateContext context) {
64 return DateFormat.getTimeInstance().format(new java.util.Date());
69 * The user variable evaluates to the current user.
71 static class User extends SimpleTemplateVariable {
73 super(JavaTemplateMessages.getString("GlobalVariables.variable.name.user"), JavaTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
76 public String evaluate(TemplateContext context) {
77 return System.getProperty("user.name"); //$NON-NLS-1$