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


Java ParseErrorException类代码示例

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


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

示例1: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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.exception.ParseErrorException; //导入依赖的package包/类
@Override
public boolean render(RenderHandler handler)
		throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException {
	String src = handler.getStringParameter(0);
       String base = handler.getRequest().getContextPath();
       
       // 判断是否启用图片域名
       if (Global.getImageDomain()) {
       	base = Global.getImageHost();
       }
       
       StringBuffer buf = new StringBuffer();
       
       buf.append(base);
       buf.append(src);
       handler.write(buf.toString());
       return true;
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:19,代码来源:ResourceDirective.java

示例3: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的package包/类
@Override
public boolean render(RenderHandler handler) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException {
	ServletRequest request = handler.getRequest();
	
	// request 获取参数
       String ord = ServletRequestUtils.getStringParameter(request, "ord", Consts.order.NEWEST);
       int pn = ServletRequestUtils.getIntParameter(request, "pn", 1);
       
       // 标签中获取参数
       int groupId = handler.getIntParameter(0);
       String alias = handler.getStringParameter(1);
       
       Paging paging = wrapPaing(pn);
	Paging result = postPlanet.paging(paging, groupId, ord);
	
	handler.put(alias, result);
	handler.doRender();
	
	postRender(handler.getContext());
	return true;
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:22,代码来源:ContentsDirective.java

示例4: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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

示例5: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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

示例6: renderTemplate

import org.apache.velocity.exception.ParseErrorException; //导入依赖的package包/类
/**
 * Return the String representation of the template rendered using Velocity.
 *
 * @param context context use to render the template
 * @param templateFileName file name of the template in the classpath
 * @throws TemplateRenderException if there is an error with the template
 */
public static String renderTemplate(String templateFileName,
                                    VelocityContext context)
    throws TemplateRenderException {
  VelocityEngine ve = new VelocityEngine();
  ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
  ve.setProperty("classpath.resource.loader.class",
      ClasspathResourceLoader.class.getName());

  StringWriter sw = new StringWriter();

  try {
    ve.mergeTemplate(templateFileName, "UTF-8", context, sw);
  } catch (ResourceNotFoundException
      | ParseErrorException
      | MethodInvocationException e) {
    throw new TemplateRenderException("Error rendering template file: " + templateFileName, e);
  }

  return sw.toString();
}
 
开发者ID:airbnb,项目名称:reair,代码行数:28,代码来源:VelocityUtils.java

示例7: prepareVelocityTemplate

import org.apache.velocity.exception.ParseErrorException; //导入依赖的package包/类
private Set<String> prepareVelocityTemplate(String template) throws PIPException {
    VelocityContext vctx = new VelocityContext();
    EventCartridge vec = new EventCartridge();
    VelocityParameterReader reader = new VelocityParameterReader();
    vec.addEventHandler(reader);
    vec.attachToContext(vctx);

    try {
        Velocity.evaluate(vctx, new StringWriter(), "LdapResolver", template);
    } catch (ParseErrorException pex) {
        throw new PIPException("Velocity template preparation failed", pex);
    } catch (MethodInvocationException mix) {
        throw new PIPException("Velocity template preparation failed", mix);
    } catch (ResourceNotFoundException rnfx) {
        throw new PIPException("Velocity template preparation failed", rnfx);
    }
    if (this.logger.isTraceEnabled()) {
        this.logger.trace("(" + id + ") " + template + " with parameters " + reader.parameters);
    }

    return reader.parameters;
}
 
开发者ID:apache,项目名称:incubator-openaz,代码行数:23,代码来源:ConfigurableLDAPResolver.java

示例8: evaluateVelocityTemplate

import org.apache.velocity.exception.ParseErrorException; //导入依赖的package包/类
private String evaluateVelocityTemplate(String template,
                                        final Map<String, PIPRequest> templateParameters,
                                        final PIPFinder pipFinder)
    throws PIPException {
    StringWriter out = new StringWriter();
    VelocityContext vctx = new VelocityContext();
    EventCartridge vec = new EventCartridge();
    VelocityParameterWriter writer = new VelocityParameterWriter(pipFinder, templateParameters);
    vec.addEventHandler(writer);
    vec.attachToContext(vctx);

    try {
        Velocity.evaluate(vctx, out, "LdapResolver", template);
    } catch (ParseErrorException pex) {
        throw new PIPException("Velocity template evaluation failed", pex);
    } catch (MethodInvocationException mix) {
        throw new PIPException("Velocity template evaluation failed", mix);
    } catch (ResourceNotFoundException rnfx) {
        throw new PIPException("Velocity template evaluation failed", rnfx);
    }

    this.logger.warn("(" + id + ") " + " template yields " + out.toString());

    return out.toString();
}
 
开发者ID:apache,项目名称:incubator-openaz,代码行数:26,代码来源:ConfigurableLDAPResolver.java

示例9: testBuildSystemMonitorResponseInvalidVelocityTemplate

import org.apache.velocity.exception.ParseErrorException; //导入依赖的package包/类
@Test
public void testBuildSystemMonitorResponseInvalidVelocityTemplate() throws Exception
{
    // Override the configuration to use an invalid velocity template for building the system monitor response.
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.HERD_NOTIFICATION_SQS_SYS_MONITOR_RESPONSE_VELOCITY_TEMPLATE.getKey(), "#if($missingEndOfIfStatement");
    modifyPropertySourceInEnvironment(overrideMap);

    try
    {
        // Try to build a system monitor response message when velocity template is invalid.
        defaultNotificationMessageBuilder.buildSystemMonitorResponse(getTestSystemMonitorIncomingMessage());
        fail();
    }
    catch (ParseErrorException e)
    {
        assertTrue(e.getMessage().startsWith("Encountered \"<EOF>\" at systemMonitorResponse[line 1, column 28]"));
    }
    finally
    {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:25,代码来源:DefaultNotificationMessageBuilderTest.java

示例10: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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

示例11: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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

示例12: evaluate

import org.apache.velocity.exception.ParseErrorException; //导入依赖的package包/类
public String evaluate(Map<String, Object> context, TemplatePack templatePack, Template template) throws IOException {
    StringWriter sw = new StringWriter();
    try {
        engine.evaluate(new VelocityContext(context), sw, template.getName(), template.getTemplate());
        return sw.toString();
    } catch (ParseErrorException parseException) {
        handleStopFileGeneration(parseException);
        log.error("In " + templatePack.getName() + ":" + template.getName() + " template, parse exception " + parseException.getMessage(),
                parseException.getCause());
        displayLinesInError(parseException, templatePack, template);
        throw new IllegalStateException();
    } catch (MethodInvocationException mie) {
        handleStopFileGeneration(mie);
        log.error("In " + templatePack.getName() + ":" + mie.getTemplateName() + " method [" + mie.getMethodName() + "] has not been set", mie.getCause());
        displayLinesInError(mie, templatePack, template);
        throw mie;
    } finally {
        closeQuietly(sw);
    }
}
 
开发者ID:jaxio,项目名称:celerio,代码行数:21,代码来源:VelocityGenerator.java

示例13: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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

示例14: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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

示例15: render

import org.apache.velocity.exception.ParseErrorException; //导入依赖的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


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