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


Java Node类代码示例

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


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

示例1: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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.runtime.parser.node.Node; //导入依赖的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.runtime.parser.node.Node; //导入依赖的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.runtime.parser.node.Node; //导入依赖的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.runtime.parser.node.Node; //导入依赖的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: visit

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的package包/类
/**
 * @see org.apache.velocity.runtime.parser.node.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTIfStatement,
 *      java.lang.Object)
 */
public Object visit(ASTIfStatement aNode, Object aData)
{
    // Check for first embedded #ELSE or #ELSEIF directive to get end line
    int endLine = aNode.getLastToken().endLine;
    int numChildren = aNode.jjtGetNumChildren();
    for (int i = 1; i < numChildren; i++)
    {
        Node node = aNode.jjtGetChild(i);
        if (node instanceof ASTElseStatement || node instanceof ASTElseIfStatement)
        {
            endLine = node.getFirstToken().beginLine - 1;
            break;
        }
    }
    Directive directive = new Directive(Directive.TYPE_IF, aNode.jjtGetChild(0).literal(), "", (ITreeNode) fCurrentBlock, aNode.getFirstToken().beginLine, endLine);
    return visitBlockDirective(aNode, aData, directive, false);
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:22,代码来源:NodeVisitor.java

示例7: visitBlockDirective

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的package包/类
private Object visitBlockDirective(Node aNode, Object aData, Directive aDirective, boolean anAddToParentBlock)
{
    if (anAddToParentBlock && fCurrentBlock instanceof Directive)
    {
        IBlock parent = (IBlock) ((Directive) fCurrentBlock).getParent();
        parent.addDirective(aDirective);
    } else
    {
        fCurrentBlock.addDirective(aDirective);
    }
    fBlocks.push(fCurrentBlock);
    fCurrentBlock = aDirective;
    aData = aNode.childrenAccept(this, aData);
    fCurrentBlock = (IBlock) fBlocks.pop();
    return aData;
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:17,代码来源:NodeVisitor.java

示例8: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例9: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例10: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例11: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例12: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例13: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例14: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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

示例15: render

import org.apache.velocity.runtime.parser.node.Node; //导入依赖的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


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