public class Rythm extends Object
RythmEngine
.
For most cases you can play with 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 |
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 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)
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 void init(File 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()
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)
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()
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()
production
modepublic final RythmEngine prepare(ICodeType codeType, Locale locale, Map<String,Object> usrCtx)
codeType
- locale
- usrCtx
- public final RythmEngine prepare(ICodeType codeType)
codeType
- public final RythmEngine prepare(Locale locale)
locale
- public final RythmEngine prepare(Map<String,Object> userContext)
userContext
- 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)
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 © 2015. All Rights Reserved.