org.rythmengine.extension.IDurationParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rythm-engine Show documentation
Show all versions of rythm-engine Show documentation
A strong typed high performance Java Template engine with .Net Razor like syntax
/**
* Copyright (C) 2013-2016 The Rythm Engine project
* for LICENSE and other details see:
* https://github.com/rythmengine/rythmengine
*/
package org.rythmengine.extension;
import org.rythmengine.utils.Time;
/**
* A user application could implement this interface to provide
* customized time string parsing utility to {@link ICacheService rythm cache service}.
* and then configure the Rythm to use customized implementation via
* {@link org.rythmengine.conf.RythmConfigurationKey#CACHE_DURATION_PARSER_IMPL "cache.duration_parser.impl"}
* configuration.
* Usually user application does not need to provide it's own implementation, instead, the rythm built in time
* parser could be used as default implementation
*/
public interface IDurationParser {
/**
* Parse a string representation and return number of seconds
*
* @param s
* @return duration in seconds
*/
int parseDuration(String s);
/**
* Rythm's default implementation of {@link IDurationParser}. It allows the following type of duration string
* representations:
*
* - 1d: 1 day
* - 3h: 3 hours
* - 8mn or 8min: 8 minutes
* - 23s: 23 seconds
*
*/
public static final IDurationParser DEFAULT_PARSER = new IDurationParser() {
@Override
public int parseDuration(String s) {
return Time.parseDuration(s);
}
};
}