2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template.php;
7 import java.text.DateFormat;
9 import net.sourceforge.phpdt.internal.corext.template.SimpleTemplateVariable;
10 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
13 * Global variables which are available in any context.
15 public class GlobalVariables {
18 * The cursor variable determines the cursor placement after template edition.
20 static class Cursor extends SimpleTemplateVariable {
22 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.cursor"), PHPTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ //$NON-NLS-2$
23 setEvaluationString(""); //$NON-NLS-1$
29 * The dollar variable inserts an escaped dollar symbol.
31 static class Dollar extends SimpleTemplateVariable {
33 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.dollar"), PHPTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
34 setEvaluationString("$"); //$NON-NLS-1$
40 * The date variable evaluates to the current date.
42 static class Date extends SimpleTemplateVariable {
44 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.date"), PHPTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
47 public String evaluate(TemplateContext context) {
48 return DateFormat.getDateInstance().format(new java.util.Date());
53 * The time variable evaluates to the current time.
55 static class Time extends SimpleTemplateVariable {
57 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.time"), PHPTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
60 public String evaluate(TemplateContext context) {
61 return DateFormat.getTimeInstance().format(new java.util.Date());
66 * The user variable evaluates to the current user.
68 static class User extends SimpleTemplateVariable {
70 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.user"), PHPTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
73 public String evaluate(TemplateContext context) {
74 return System.getProperty("user.name"); //$NON-NLS-1$