本文整理汇总了Java中org.apache.velocity.context.InternalContextAdapter.put方法的典型用法代码示例。如果您正苦于以下问题:Java InternalContextAdapter.put方法的具体用法?Java InternalContextAdapter.put怎么用?Java InternalContextAdapter.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.velocity.context.InternalContextAdapter
的用法示例。
在下文中一共展示了InternalContextAdapter.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.apache.velocity.context.InternalContextAdapter; //导入方法依赖的package包/类
public boolean render( InternalContextAdapter context, Writer writer, org.apache.velocity.runtime.parser.node.Node node ) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
String var = node.jjtGetChild( 0 ).getFirstToken().image.substring( 1 );
Node document = ( Node ) node.jjtGetChild( 1 ).value( context );
String xpath = String.valueOf( node.jjtGetChild( 2 ).value( context ) );
XPath xPath = XPathFactory.newInstance().newXPath();
try {
Node element = ( Node ) xPath.evaluate( xpath, document, XPathConstants.NODE );
if( element != null )
if( TEXT_NODES.contains( element.getNodeType() ) )
context.put( var, element.getTextContent() );
else context.put( var, element );
else log.warn( "for " + xpath + " nothing found" );
} catch( XPathExpressionException e ) {
throw new IOException( "cannot evaluate xpath: " + e.getMessage() );
}
return true;
}
示例2: render
import org.apache.velocity.context.InternalContextAdapter; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
StringWriter sw = new StringWriter();
node.jjtGetChild(1).render(context, sw);
// store the contents against the variable
context.put("body_content", sw.toString());
return super.render(context, writer, node);
}
示例3: render
import org.apache.velocity.context.InternalContextAdapter; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException
{
StringWriter sw = new StringWriter();
node.jjtGetChild(1).render(context, sw);
// store the contents against the variable
context.put("body_content", sw.toString());
return super.render(context, writer, node);
}
示例4: clean
import org.apache.velocity.context.InternalContextAdapter; //导入方法依赖的package包/类
protected void clean(InternalContextAdapter context,
Object o, ParameterMappingCollector collector, String savedItemKey) {
if (o != null) {
context.put(this.var, o);
} else {
context.remove(this.var);
}
collector.setItemKey(savedItemKey);
postRender(context);
}
示例5: render
import org.apache.velocity.context.InternalContextAdapter; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
if(node.jjtGetNumChildren() != 1){
throw new RuntimeException(getName() + " only and must accept one Map parameter!") ;
}
Map params = (Map) node.jjtGetChild(0).value(context) ;
Object business = params.get("business") ;
String ghostName ;
if(business instanceof java.lang.String){
ghostName = (String) business ;
}else{
ghostName = business.getClass().getName() ;
}
String var = (String) params.get("var") ;
Object tableCondition = params.get("tableCondition") ;
Object limit = params.get("limit") ;
Assert.assertResouceNotNull(ghostName, "parameter [business] in Map is requried.") ;
Assert.assertResouceNotNull(var, "parameter [var] in Map is requried.") ;
LinkedList conditions = new LinkedList() ;
BoundaryChain chain = (BoundaryChain) context.get(GuzzBoundaryDirective.BOUNDARY_CONTEXT_NAME) ;
if(chain != null){
if(tableCondition == null){
tableCondition = chain.getTableCondition() ;
}
conditions.addAll(chain.getBoundaryLimits()) ;
}
if(limit != null){
conditions.addLast(limit) ;
}
Business bi = guzzContext.getBusiness(ghostName) ;
ObjectMapping mapping = guzzContext.getObjectMappingManager().getObjectMapping(ghostName, tableCondition) ;
if(bi == null){
throw new ParseErrorException("unknown business:[" + business + "], business name:" + ghostName) ;
}
Object result = innerSummonGhosts(bi, mapping, tableCondition, conditions, params);
//保存结果
context.put(var, result) ;
return true;
}
示例6: put
import org.apache.velocity.context.InternalContextAdapter; //导入方法依赖的package包/类
protected void put(InternalContextAdapter context, String key, Object value) {
context.put(key, value);
}