2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template.php;
7 import java.text.DateFormat;
8 import java.util.Calendar;
10 import net.sourceforge.phpdt.internal.corext.template.SimpleTemplateVariable;
11 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
14 * Global variables which are available in any context.
16 public class GlobalVariables {
19 * The cursor variable determines the cursor placement after template edition.
21 static class Cursor extends SimpleTemplateVariable {
23 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.cursor"), PHPTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ //$NON-NLS-2$
24 setEvaluationString(""); //$NON-NLS-1$
30 * The dollar variable inserts an escaped dollar symbol.
32 static class Dollar extends SimpleTemplateVariable {
34 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.dollar"), PHPTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
35 setEvaluationString("$"); //$NON-NLS-1$
41 * The date variable evaluates to the current date.
43 static class Date extends SimpleTemplateVariable {
45 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.date"), PHPTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
48 public String evaluate(TemplateContext context) {
49 return DateFormat.getDateInstance().format(new java.util.Date());
54 * The year variable evaluates to the current year.
56 static class Year extends SimpleTemplateVariable {
58 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.year"), PHPTemplateMessages.getString("GlobalVariables.variable.description.year")); //$NON-NLS-1$ //$NON-NLS-2$
61 public String evaluate(TemplateContext context) {
62 return Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
66 * The time variable evaluates to the current time.
68 static class Time extends SimpleTemplateVariable {
70 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.time"), PHPTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
73 public String evaluate(TemplateContext context) {
74 return DateFormat.getTimeInstance().format(new java.util.Date());
79 * The user variable evaluates to the current user.
81 static class User extends SimpleTemplateVariable {
83 super(PHPTemplateMessages.getString("GlobalVariables.variable.name.user"), PHPTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
86 public String evaluate(TemplateContext context) {
87 return System.getProperty("user.name"); //$NON-NLS-1$