当前位置: 首页>>代码示例>>Java>>正文


Java InternalContextAdapter类代码示例

本文整理汇总了Java中org.apache.velocity.context.InternalContextAdapter的典型用法代码示例。如果您正苦于以下问题:Java InternalContextAdapter类的具体用法?Java InternalContextAdapter怎么用?Java InternalContextAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InternalContextAdapter类属于org.apache.velocity.context包,在下文中一共展示了InternalContextAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
    String value = (String) node.jjtGetChild(0).value(context);
    String character = (String) node.jjtGetChild(1).value(context);
    int len = value.length();
    StringBuilder sb = new StringBuilder(len);
    sb.append(value.charAt(0));
    for (int i = 1; i < len; i++) {
        char c = value.charAt(i);
        if (Character.isUpperCase(c)) {
            sb.append(character).append(Character.toLowerCase(c));
        } else {
            sb.append(c);
        }
    }
    writer.write(sb.toString());
    return true;
}
 
开发者ID:hykes,项目名称:CodeGen,代码行数:19,代码来源:Split.java

示例2: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
    // get the bean
    ValueStack stack = (ValueStack) ctx.get("stack");
    HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
    HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
    Component bean = getBean(stack, req, res);
    Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
    container.inject(bean);
    // get the parameters
    Map params = createPropertyMap(ctx, node);
    bean.copyParams(params);
    //bean.addAllParameters(params);
    bean.start(writer);

    if (getType() == BLOCK) {
        Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1);
        body.render(ctx, writer);
    }

    bean.end(writer, "");
    return true;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:23,代码来源:AbstractDirective.java

示例3: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer,
		Node node) throws IOException, ResourceNotFoundException,
		ParseErrorException, MethodInvocationException 
{
	int argsNum = node.jjtGetNumChildren();
	for(int step = 0 ; step < argsNum; step++)
	{
		SimpleNode simpleNode = (SimpleNode) node.jjtGetChild(step);

		Object argObject = simpleNode.value(context);

		//传入参数
		if(argObject instanceof String)
		{
			System.out.println((String)argObject);
			writer.write((String)argObject);
			writer.flush();
		}
	}
	return true;
}
 
开发者ID:GooDay0923,项目名称:java-framework-with-springmvc-mybatis-proxool,代码行数:23,代码来源:TestDirective.java

示例4: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) 
  		throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
  	
  	//render content
  	StringWriter content = new StringWriter();
node.jjtGetChild(0).render(context, content);

//compress
try {
	writer.write(htmlCompressor.compress(content.toString()));
} catch (Exception e) {
	writer.write(content.toString());
	String msg = "Failed to compress content: "+content.toString();
          log.error(msg, e);
          throw new RuntimeException(msg, e);
          
}
return true;
  	
  }
 
开发者ID:ad3n,项目名称:htmlcompressor,代码行数:21,代码来源:HtmlCompressorDirective.java

示例5: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) 
  		throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
  	
  	//render content
  	StringWriter content = new StringWriter();
node.jjtGetChild(0).render(context, content);

//compress
try {
	writer.write(xmlCompressor.compress(content.toString()));
} catch (Exception e) {
	writer.write(content.toString());
	String msg = "Failed to compress content: "+content.toString();
          log.error(msg, e);
          throw new RuntimeException(msg, e);
          
}
return true;
  	
  }
 
开发者ID:ad3n,项目名称:htmlcompressor,代码行数:21,代码来源:XmlCompressorDirective.java

示例6: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException {
    String block = "";
    TypeDef clazz = null;
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
        if (node.jjtGetChild(i) != null) {
            if (!(node.jjtGetChild(i) instanceof ASTBlock)) {
                //reading and casting inline parameters
                if (i == 0) {
                    clazz = (TypeDef) node.jjtGetChild(i).value(context);
                } else {
                    break;
                }
            } else {
                //reading block content and rendering it
                StringWriter blockContent = new StringWriter();
                node.jjtGetChild(i).render(context, blockContent);

                block = blockContent.toString();
                break;
            }
        }
    }
    writeClazz(writer, clazz, block);
    return true;
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:27,代码来源:ClassDirective.java

示例7: 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;
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:18,代码来源:XPathDirective.java

示例8: 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 parameter!") ;
	}
	
	Object param2 = node.jjtGetChild(0).value(context) ;
	
	//如果为null,则什么都不输出。
	if(param2 != null){
		String param = String.valueOf(param2) ;
		param = StringUtil.replaceStringIgnoreCase(param, "<script", "< script") ;
		param = StringUtil.replaceStringIgnoreCase(param, "</script", "</ script") ;
		
		writer.append(param) ;
	}
       
       return true;
}
 
开发者ID:ryanwli,项目名称:guzz,代码行数:19,代码来源:EscapeJavascriptDirective.java

示例9: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
	Object value = node.jjtGetChild(0).value(context);
	
	boolean isEmpty = false ;
	if(value == null){
		isEmpty = true ;
	}else{
		if(value instanceof String){
			isEmpty = StringUtil.isEmpty((String) value) ;
		}else if(value instanceof Collection){
			isEmpty = ((Collection) value).isEmpty() ;
		}else if(value.getClass().isArray()){
			isEmpty = Array.getLength(value) > 0 ;
		}
	}
	
       if (isEmpty) {
           Node content = node.jjtGetChild(1);
           content.render(context, writer);
       }
       
       return true;
}
 
开发者ID:ryanwli,项目名称:guzz,代码行数:24,代码来源:IsEmptyDirective.java

示例10: 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() != 2){
		throw new RuntimeException(getName() + " accepts 2 parameters. The first is a boolean value indicating whether or not to add this conditon; the second is a List containing your conditions!") ;
	}
	
	Boolean test = (Boolean) node.jjtGetChild(0).value(context) ;
	if(Boolean.FALSE.equals(test)){ //ignore this condition.
		return true ;
	}
	
	Collection conditions = (Collection) node.jjtGetChild(1).value(context) ;
	
	BoundaryChain chain = (BoundaryChain) context.get(GuzzBoundaryDirective.BOUNDARY_CONTEXT_NAME) ;
	if(chain == null){
		throw new ParseErrorException(getName() + " must be resided inside a guzzBoundary directive.") ;
	}
	
	chain.addLimitConditions(conditions) ;
       
       return true;
}
 
开发者ID:ryanwli,项目名称:guzz,代码行数:22,代码来源:GuzzAddLimitDirective.java

示例11: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
	Object value = node.jjtGetChild(0).value(context);

	
	boolean isEmpty = false ;
	if(value == null){
		isEmpty = true ;
	}else{
		if(value instanceof String){
			isEmpty = StringUtil.isEmpty((String) value) ;
		}else if(value instanceof Collection){
			isEmpty = ((Collection) value).isEmpty() ;
		}else if(value.getClass().isArray()){
			isEmpty = Array.getLength(value) > 0 ;
		}
	}
	if (!isEmpty) {
           Node content = node.jjtGetChild(1);
           content.render(context, writer);
       }
       
       return true;
}
 
开发者ID:ryanwli,项目名称:guzz,代码行数:24,代码来源:NotEmptyDirective.java

示例12: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer,
		Node node) throws IOException, ResourceNotFoundException,
		ParseErrorException, MethodInvocationException {
	Node bodyNode = getBodyNode(context, node);
	if (AsynchronousContain.isAsyncConext()) {
		StringWriter sw = new StringWriter();
		bodyNode.render(context, sw);
		PipelineTask task = (PipelineTask) context
				.get(PipelineTask.ATTR_KEY);
		task.addJsCode(sw.toString());
	} else {
		writer.write("<script type=\"text/javascript\">\r\n");
		bodyNode.render(context, writer);
		writer.write("</script>\r\n");
	}
	return true;
}
 
开发者ID:xiyelife,项目名称:jresplus,代码行数:19,代码来源:JsCodeDirective.java

示例13: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
        throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {

    //setting default params
    String moneyValue = null;

    //reading params
    if (node.jjtGetChild(0) != null) {
        moneyValue = node.jjtGetChild(0).value(context) == null ? null : String.valueOf(node.jjtGetChild(0).value(context));
    }

    //truncate and write result to writer
    writer.write(moneyUAH(moneyValue));
    return true;

}
 
开发者ID:javadev,项目名称:jasper-xml-to-pdf-generator,代码行数:17,代码来源:MoneyUAHDirective.java

示例14: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
        throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {

    //setting default params
    String ukrValue = null;

    //reading params
    if (node.jjtGetChild(0) != null) {
        ukrValue = node.jjtGetChild(0).value(context) == null ? null : String.valueOf(node.jjtGetChild(0).value(context));
    }

    if (ukrValue == null) {
        return false;
    }
    //truncate and write result to writer
    writer.write(UkrainianToLatin.generateLat(ukrValue));
    return true;

}
 
开发者ID:javadev,项目名称:jasper-xml-to-pdf-generator,代码行数:20,代码来源:UkrToLatinDirective.java

示例15: render

import org.apache.velocity.context.InternalContextAdapter; //导入依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
        throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {

    //setting default params
    String moneyValue = null;

    //reading params
    if (node.jjtGetChild(0) != null) {
        moneyValue = String.valueOf(node.jjtGetChild(0).value(context));
    }

    //truncate and write result to writer
    writer.write(moneyToStrUAH(moneyValue));
    return true;

}
 
开发者ID:javadev,项目名称:jasper-xml-to-pdf-generator,代码行数:17,代码来源:MoneyToStrDirective.java


注:本文中的org.apache.velocity.context.InternalContextAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。