public class Rythm extends Object
Rythm is a service wrapper of the RythmEngine.
For most cases you can play with Rythm instead of an individual RythmEngine instance
Since Rythm is a wrapper class, all services are provided via static methods and delegated to an internal RythmEngine instance, which as I called, the default engine
| Modifier and Type | Class and Description |
|---|---|
static class |
Rythm.Mode
The type used to indicate the execution mode of a
RythmEngine |
static class |
Rythm.RenderTime |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
debug |
static int |
JAVA_VERSION |
| Constructor and Description |
|---|
Rythm() |
| Modifier and Type | Method and Description |
|---|---|
static String |
commonsToString(Object obj,
ToStringOption option,
org.apache.commons.lang3.builder.ToStringStyle style) |
static RythmEngine |
engine()
Return the default engine.
|
static Object |
eval(String s) |
static org.rythmengine.ShutdownService |
getShutdownService(boolean isGaeAvailable) |
static ITemplate |
getTemplate(File tmpl,
Object... args) |
static ITemplate |
getTemplate(String tmpl,
Object... args)
get a template with the given params
|
static void |
init()
Initialize default engine instance with default configuration.
|
static void |
init(File file)
Initialize default engine instance with specified configuration file
|
static void |
init(Map<String,?> conf)
Initialize default engine instance with specified configuration
|
static void |
init(RythmEngine engine)
Use an pre-initialized engine as the default engine.
|
static boolean |
insideSandbox() |
boolean |
isProdMode()
Check if default engine is running in
production mode |
RythmEngine |
prepare(ICodeType codeType)
Prepare the render operation environment settings
|
RythmEngine |
prepare(ICodeType codeType,
Locale locale,
Map<String,Object> usrCtx)
Prepare the render operation environment settings
|
RythmEngine |
prepare(Locale locale)
Prepare the render operation environment settings
|
RythmEngine |
prepare(Map<String,Object> userContext)
Prepare the render operation environment settings
|
static String |
render(File file,
Object... args) |
static String |
render(String template,
Object... args) |
static String |
renderIfTemplateExists(String template,
Object... args) |
static String |
renderStr(String template,
Object... args)
Alias of
renderString(String, Object...) |
static String |
renderString(String template,
Object... args) |
static Sandbox |
sandbox() |
static Sandbox |
sandbox(Map<String,Object> userContext) |
static void |
shutdown() |
static String |
substitute(File template,
Object... args) |
static String |
substitute(String template,
Object... args) |
static String |
toString(Object obj) |
static String |
toString(Object obj,
ToStringOption option,
ToStringStyle style) |
static String |
toString(String template,
Object obj) |
public static void init(Map<String,?> conf)
Initialize default engine instance with specified configuration
Note this method can not be called more than once during a JVM lifecycle. if the default engine instance is created already then an IllegalStateException will be thrown out
When the default engine’s shutdown method get called the default engine instance will be discard. Calling any servicing method of Rythm will cause an new RythmEngine initialized as the new default engine
conf - the configurationspublic static org.rythmengine.ShutdownService getShutdownService(boolean isGaeAvailable)
public static void init(File file)
Initialize default engine instance with specified configuration file
Note this method can not be called more than once during a JVM lifecycle. if the default engine instance is created already then an IllegalStateException will be thrown out
When the default engine’s shutdown method get called the default engine instance will be discard. Calling any servicing method of Rythm will cause an new RythmEngine initialized as the new default engine
file - the configuration filepublic static void init()
Initialize default engine instance with default configuration.
Just like init(java.util.Map) method, this method cannot be called more than once
Note this default engine instance will be implicitly initialized with the default configuration if render or the lazy load engine() methods are called before calling any init methods
public static void init(RythmEngine engine)
Use an pre-initialized engine as the default engine. Note if there are already default engine initialized then the method will raise a IllegalStateException
When the default engine’s shutdown method get called the default engine instance will be discard. Calling any servicing method of Rythm will cause an new RythmEngine initialized as the new default engine
engine - public static RythmEngine engine()
Return the default engine. If the default engine is not initialized yet, then initialize it and then return
public static boolean insideSandbox()
RythmEngine.insideSandbox()public static Sandbox sandbox()
RythmEngine.sandbox()public static Sandbox sandbox(Map<String,Object> userContext)
userContext - RythmEngine.sandbox(java.util.Map)public boolean isProdMode()
Check if default engine is running in production mode
public final RythmEngine prepare(ICodeType codeType, Locale locale, Map<String,Object> usrCtx)
Prepare the render operation environment settings
codeType - locale - usrCtx - public final RythmEngine prepare(ICodeType codeType)
Prepare the render operation environment settings
codeType - public final RythmEngine prepare(Locale locale)
Prepare the render operation environment settings
locale - public final RythmEngine prepare(Map<String,Object> userContext)
Prepare the render operation environment settings
userContext - public static final ITemplate getTemplate(String tmpl, Object... args)
get a template with the given params
tmpl - args - public static String render(String template, Object... args)
template - args - RythmEngine.render(String, Object...)public static String render(File file, Object... args)
file - args - RythmEngine.render(java.io.File, Object...)public static String substitute(String template, Object... args)
template - args - RythmEngine.substitute(String, Object...)public static String substitute(File template, Object... args)
template - args - RythmEngine.substitute(java.io.File, Object...)public static String toString(String template, Object obj)
template - obj - RythmEngine.toString(String, Object)public static String toString(Object obj)
obj - RythmEngine.toString(Object)public static String toString(Object obj, ToStringOption option, ToStringStyle style)
obj - option - style - RythmEngine.toString(Object, org.rythmengine.toString.ToStringOption, org.rythmengine.toString.ToStringStyle)public static String commonsToString(Object obj, ToStringOption option, org.apache.commons.lang3.builder.ToStringStyle style)
obj - option - style - RythmEngine.commonsToString(Object, org.rythmengine.toString.ToStringOption, org.apache.commons.lang3.builder.ToStringStyle)public static String renderStr(String template, Object... args)
Alias of renderString(String, Object...)
template - args - RythmEngine.renderString(String, Object...)public static String renderString(String template, Object... args)
template - args - RythmEngine.renderString(String, Object...)public static String renderIfTemplateExists(String template, Object... args)
template - args - RythmEngine.renderIfTemplateExists(String, Object...)public static void shutdown()
RythmEngine.shutdown()Copyright © 2017–2021 OSGL (Open Source General Library). All rights reserved.