Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
// Example how to add constant variables
// Caution: This class has to be provided as a service!
public class DateReplacementProvider implements IReplacementProvider {
 
	// We 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;
	}
 
	// Each time, "currentDate" 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 "";
	}
}