@author Generated from Forte @since 19-Nov-2008
Provides the base functionality for a {@link Grengine}, without all the convenience methods. @since 1.0 @author Alain Stalder @author Made in Switzerland.
The template engine - THIS IS WHERE YOU START LOOKING.
Usually this is the only class you need calling {@link #transform(String,Map)}. Like this
Engine engine = new Engine(); String transformed = engine.transform(input, model);
You have to provide the template input written in the template language and a model from String to Object. Maybe like this
String input = "${name}"; Map<String, Object> model = new HashMap<String, Object>(); model.put("name", "Minimal Template Engine"); Engine engine = new Engine(); String transformed = engine.transform(input, model); assert (transformed.equals("Minimal Template Engine"));where
input
contains the template and model
the model. Use {@link #setUseCompilation(boolean)} to switch on compilation mode. Thiswill compile the template into Java byte code before execution. Especially when the template is used often this will speed up the execution by a factor between 2 and 10. However, each compiled template results in a new class definition and a new globally cached singleton instance of it.
This class is thread safe.
@see ErrorHandler @see Tool @see Renderer @see NamedRenderer @see ModelAdaptor @see ProcessListener An Engine must support certain specialized Operations, like ZoneOperation and CloneOperationImpl, but it may also provide any number of other Operations implemented as GenericOperations. The GenericOperations supported by an Engine can be discovered through getOperationTypes()
.
@see com.lightcrafts.model.EngineFactory
com.whatevernot.engine.standard.Engine.debug
to true
. The result of inject
is a long
sequence number. If the sequence number is negative, then an error has occurred. The value of -2
indicates an attempt to inject a null
object. The value of -3
indicates an object for which no method is found in the registry.
Engine engine = Engine.getEngine();@see httl.Context#getEngine() @see httl.Template#getEngine() @see httl.Resource#getEngine() @see httl.spi.engines.DefaultEngine @author Liang Fei (liangfei0201 AT gmail DOT com)
engine
object
@author sulis
在一个Rose应用中,存在着“很多的、不同的” {@link Engine}实例,这些实例根据映射关系组成在一个树状的结构中。 @see Rose @see Mapping @author 王志亮 [qieqie.wang@gmail.com]
The child containers attached to an Engine are generally implementations of Host (representing a virtual host) or Context (representing individual an individual servlet context), depending upon the Engine implementation.
If used, an Engine is always the top level Container in a Catalina hierarchy. Therefore, the implementation's setParent()
method should throw IllegalArgumentException
.
@author Craig R. McClanahan
@version $Revision: 466595 $ $Date: 2006-10-21 23:24:41 +0100 (Sat, 21 Oct 2006) $
debug=true - 调试模式 encoding=UTF-8 - 模板文件编码集 template.path=/ - 模板根路径 left.delimiter={ - 左边界定界符 right.delimiter=} - 右边界定界符 package.function=org.lilystudio.smarty4j.statement.htmlcontrol - 函数扩展包的名称, 以:分隔 package.modifier= - 变量调节器扩展包的名称, 以:分隔@see org.lilystudio.smarty4j.Template @version 1.0.0, 2010/10/01 @author 欧阳先伟 @since Smarty 1.0
The intermediary layer is built as a DLL on Windows systems (ptmatlab.dll). This shared library is placed into the $PTII/bin directory (that should be in the user's path) when this package is built. Ptmatlab depends on matlab's engine API shared libraries (libeng and libmx) that should also be installed in the user's path (usually the case when matlab is installed and matlab's bin directory is added to the path).
The bulk of the work done by this class is the conversion between PtolemyII Tokens and matlab variables ("mxArrays").
{@link #get(long[] eng,String name)} and{@link ptolemy.matlab.Engine#get(long[],String,Engine.ConversionParameters)} convert a matlab engine mxArray(ma) variable to a Ptolemy II Token. Recursion is used if ma is a struct or cell. The type of the Token returned is determined according to the following table:
Matlab Type | PtolemyII Token |
---|---|
'double' | Double, if mxArray dimension is 1x1 and {@link Engine.ConversionParameters#getScalarMatrices} is true,DoubleMatrix otherwise. Complex, if mxArray is mxCOMPLEX, 1x1, and {@link Engine.ConversionParameters#getScalarMatrices} is true,ComplexMatrix otherwise. Note: If {@link Engine.ConversionParameters#getIntMatrices} is true andall matrix double values can be cast to integers without loss of precision then an IntToken or IntTokenMatrix is returned. |
'struct' | RecordToken, if mxArray dimension 1x1, ArrayToken of ArrayTokens of RecordTokens {{RecordToken,...}, {...}} ("two-dimensional" ArrayToken) otherwise. |
'cell' | ArrayToken of whatever Tokens the cell elements resolve to through recursion of _convertMxArrayToToken(). In the special case of a cell array of doubles, an {int} is always returned if all cell double values can be losslessly converted to integers. Note that PtolemyII is more restrictive here in that it requires all array elements to be of the same type (not all matlab cell variables may be converted to PtolemyII ArrayTokens). |
'char' | StringToken, if the mxArray is 1xn, ArrayToken of StringTokens otherwise. |
{@link #put(long[] eng,String name,Token t)} converts a PtolemyIIToken to a matlab engine mxArray. Recursion is used if t is a RecordToken or ArrayToken. The type of mxArray created is determined according to the following table.
PtolemyII Token | Matlab type |
---|---|
ArrayToken | 'cell', 1xn, elements are determined by recursing this method on ArrayToken elements. |
RecordToken | 'struct', 1x1, fields are determined by recursing this method on RecordToken fields |
StringToken | 'char', 1xn |
ComplexMatrixToken | 'double', mxCOMPLEX, nxm |
MatrixToken | 'double', mxREAL, nxm |
ComplexToken | 'double', mxCOMPLEX, 1x1 |
ScalarToken | 'double', mxREAL, 1x1 |
Debug statements to stdout are enabled by calling {@link #setDebugging} with a byte parameter > 0. 1 enables basic tracing,2 includes traces from the dll as well.
{@link #evalString(long[] eng, String)} send a string to the matlabengine for evaluation. {@link #open} and {@link #close} are used to open / close theconnection to the matlab engine.
All callers share the same matlab engine and its workspace. Methods of Engine synchronize on the static {@link #semaphore} toprevent overlapping calls to the same method from different threads. Use Engine. {@link #semaphore} to synchronize across multiple methodcalls if needed.
@author Zoltan Kemenczy and Sean Simmons, Research in Motion Limited. @version $Id: Engine.java,v 1.45 2007/12/06 18:23:36 cxh Exp $ @since Ptolemy II 2.0 @Pt.ProposedRating Yellow (zkemenczy) @Pt.AcceptedRating Red (cxh)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|