Java 类org.apache.velocity.exception.TemplateInitException 实例源码

项目:velocity-scripting    文件:InDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) {
  super.init(rs, context, node);
  final int n = node.jjtGetNumChildren() - 1;
  for (int i = 1; i < n; i++) {
    Node child = node.jjtGetChild(i);
    if (i == 1) {
      if (child.getType() == ParserTreeConstants.JJTREFERENCE) {
        this.var = ((ASTReference) child).getRootString();
      }
      else {
        throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
      }
    }
    else if (child.getType() == ParserTreeConstants.JJTSTRINGLITERAL) {
      String value = (String) ((ASTStringLiteral) child).value(context);
      if (i == 2) {
        this.column = value;
      }
    }
    else {
      throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
    }
  }
  this.uberInfo = new Info(this.getTemplateName(), getLine(), getColumn());
}
项目:mblog    文件:BaseDirective.java   
/** 
 * 重载init方法,初始自定义指令的配制参数 
 */  
@Override  
public void init(RuntimeServices rs, InternalContextAdapter context, Node node)  
    throws TemplateInitException {  
    super.init(rs, context, node);

    initBean();
}
项目:htmlcompressor    文件:JavaScriptCompressorDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);
    log = rs.getLog();

    //set compressor properties
    enabled = rs.getBoolean("userdirective.compressJs.enabled", true);
    jsCompressor = rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI);
    yuiJsNoMunge = rs.getBoolean("userdirective.compressJs.yuiJsNoMunge", false);
    yuiJsPreserveAllSemiColons = rs.getBoolean("userdirective.compressJs.yuiJsPreserveAllSemiColons", false);
    yuiJsLineBreak = rs.getInt("userdirective.compressJs.yuiJsLineBreak", -1);
    closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE);
}
项目:htmlcompressor    文件:CssCompressorDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);
    log = rs.getLog();

    //set compressor properties
    enabled = rs.getBoolean("userdirective.compressCss.enabled", true);
    yuiCssLineBreak = rs.getInt("userdirective.compressCss.yuiCssLineBreak", -1);
}
项目:htmlcompressor    文件:XmlCompressorDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);
    log = rs.getLog();

    //set compressor properties
    xmlCompressor.setEnabled(rs.getBoolean("userdirective.compressXml.enabled", true));
    xmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressXml.removeComments", true));
    xmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressXml.removeIntertagSpaces", true));
}
项目:guzz    文件:VelocityTemplatedSQLService.java   
public void addImutableSql(String id, ObjectMapping mapping, String sqlStatement) {
    try {
        this.templates.put(id, new TemplateData(mapping, sqlStatement.getBytes("UTF-8"))) ;
    } catch (UnsupportedEncodingException e) {
        throw new TemplateInitException(e.getMessage(), id, 1, 1) ;
    }
}
项目:guzz    文件:VelocityTemplatedSQLService.java   
public void addImutableSql(String id, String ormName, String sqlStatement) {
    try {
        this.templates.put(id, new TemplateData(ormName, sqlStatement.getBytes("UTF-8"))) ;
    } catch (UnsupportedEncodingException e) {
        throw new TemplateInitException(e.getMessage(), id, 1, 1) ;
    }
}
项目:velocity-scripting    文件:RepeatDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) {
  super.init(rs, context, node);
  final int n = node.jjtGetNumChildren() - 1;
  for (int i = 1; i < n; i++) {
    Node child = node.jjtGetChild(i);
    if (i == 1) {
      if (child.getType() == ParserTreeConstants.JJTREFERENCE) {
        this.var = ((ASTReference) child).getRootString();
      } else {
        throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
      }
    } else if (child.getType() == ParserTreeConstants.JJTSTRINGLITERAL) {
      String value = (String) ((ASTStringLiteral)child).value(context);
      switch (i) {
        case 2:
          this.separator = value;
          break;
        case 3:
          this.open = value;
          break;
        case 4:
          this.close = value;
          break;
        default:
          break;
      }
    } else {
      throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
    }
  }
  this.uberInfo = new Info(this.getTemplateName(), getLine(), getColumn());
}
项目:htmlcompressor    文件:HtmlCompressorDirective.java   
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);
    log = rs.getLog();

    boolean compressJavaScript = rs.getBoolean("userdirective.compressHtml.compressJavaScript", false);

    //set compressor properties
    htmlCompressor.setEnabled(rs.getBoolean("userdirective.compressHtml.enabled", true));
    htmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressHtml.removeComments", true));
    htmlCompressor.setRemoveMultiSpaces(rs.getBoolean("userdirective.compressHtml.removeMultiSpaces", true));
    htmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressHtml.removeIntertagSpaces", false));
    htmlCompressor.setRemoveQuotes(rs.getBoolean("userdirective.compressHtml.removeQuotes", false));
    htmlCompressor.setPreserveLineBreaks(rs.getBoolean("userdirective.compressHtml.preserveLineBreaks", false));
    htmlCompressor.setCompressJavaScript(compressJavaScript);
    htmlCompressor.setCompressCss(rs.getBoolean("userdirective.compressHtml.compressCss", false));
    htmlCompressor.setYuiJsNoMunge(rs.getBoolean("userdirective.compressHtml.yuiJsNoMunge", false));
    htmlCompressor.setYuiJsPreserveAllSemiColons(rs.getBoolean("userdirective.compressHtml.yuiJsPreserveAllSemiColons", false));
    htmlCompressor.setYuiJsLineBreak(rs.getInt("userdirective.compressHtml.yuiJsLineBreak", -1));
    htmlCompressor.setYuiCssLineBreak(rs.getInt("userdirective.compressHtml.yuiCssLineBreak", -1));
    htmlCompressor.setSimpleDoctype(rs.getBoolean("userdirective.compressHtml.simpleDoctype", false));
    htmlCompressor.setRemoveScriptAttributes(rs.getBoolean("userdirective.compressHtml.removeScriptAttributes", false));
    htmlCompressor.setRemoveStyleAttributes(rs.getBoolean("userdirective.compressHtml.removeStyleAttributes", false));
    htmlCompressor.setRemoveLinkAttributes(rs.getBoolean("userdirective.compressHtml.removeLinkAttributes", false));
    htmlCompressor.setRemoveFormAttributes(rs.getBoolean("userdirective.compressHtml.removeFormAttributes", false));
    htmlCompressor.setRemoveInputAttributes(rs.getBoolean("userdirective.compressHtml.removeInputAttributes", false));
    htmlCompressor.setSimpleBooleanAttributes(rs.getBoolean("userdirective.compressHtml.simpleBooleanAttributes", false));
    htmlCompressor.setRemoveJavaScriptProtocol(rs.getBoolean("userdirective.compressHtml.removeJavaScriptProtocol", false));
    htmlCompressor.setRemoveHttpProtocol(rs.getBoolean("userdirective.compressHtml.removeHttpProtocol", false));
    htmlCompressor.setRemoveHttpsProtocol(rs.getBoolean("userdirective.compressHtml.removeHttpsProtocol", false));


    if(compressJavaScript && rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI).equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) {
        String closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE);

        ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor();
        if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) {
            closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS);
        } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) {
            closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY);
        } else {
            closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS);
        }

        htmlCompressor.setJavaScriptCompressor(closureCompressor);
    }
}
项目:guzz    文件:GuzzAddInLimitDirective.java   
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);

    this.guzzContext = (GuzzContext) rs.getApplicationAttribute(SummonDirective.GUZZ_CONTEXT_NAME) ;
}
项目:guzz    文件:SummonDirective.java   
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);

    this.guzzContext = (GuzzContext) rs.getApplicationAttribute(GUZZ_CONTEXT_NAME) ;
}
项目:guzz    文件:GuzzAddLimitDirective.java   
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);
}
项目:guzz    文件:GuzzIncDirective.java   
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
    super.init(rs, context, node);

    this.guzzContext = (GuzzContext) rs.getApplicationAttribute(SummonDirective.GUZZ_CONTEXT_NAME) ;
    this.slowUpdateService = (SlowUpdateService) this.guzzContext.getService(Service.FAMOUSE_SERVICE.SLOW_UPDATE) ;
}