...
The developer wants to add the current date as a constant variable. The class could be implemented as follows:
Code Block | ||
---|---|---|
| ||
// Example how to add constant variables // Caution: This class has to be provided as a service! public class DateReplacementProvider { // weWe provide one key here to get the currentDate in OdysseusScript @Override public Collection<String> getReplacementKeys() { List<String> keys = new ArrayList<String>(); keys.add("currentDate"); return keys; } // eachEach time, "currentKeycurrentDate" is used in one OdysseusScript-File, this // method is called @Override public String getReplacementValue( String replacementKey ) { // obsolete since we provide only one key if( replacementKey.equalsIgnoreCase("currentDate") ) { return new Date().toString(); } return ""; } } |