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


Java STGroupFile.load方法代码示例

本文整理汇总了Java中org.stringtemplate.v4.STGroupFile.load方法的典型用法代码示例。如果您正苦于以下问题:Java STGroupFile.load方法的具体用法?Java STGroupFile.load怎么用?Java STGroupFile.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.stringtemplate.v4.STGroupFile的用法示例。


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

示例1: createSTGroup

import org.stringtemplate.v4.STGroupFile; //导入方法依赖的package包/类
protected STGroupFile createSTGroup(final URL resource) {
    final STGroupFile stGroup = new STGroupFile(resource, "UTF-8", '<', '>');
    stGroup.load();
    stGroup.registerRenderer(String.class,
            (arg, formatString, locale) -> {
                switch (Strings.nullToEmpty(formatString)) {
                    case "capitalize":
                        return StringUtils.capitalize(arg.toString());
                    case "singularize":
                        return English.singular(arg.toString());
                    case "pluralize":
                        return English.plural(arg.toString());
                    case "upperUnderscore":
                        return StringCaseFormat.UPPER_UNDERSCORE_CASE.apply(arg.toString());
                    case "lowerHyphen":
                        return StringCaseFormat.LOWER_HYPHEN_CASE.apply(arg.toString());
                    case "lowercase":
                        return StringUtils.lowerCase(arg.toString());
                    case "uppercase":
                        return StringUtils.upperCase(arg.toString());
                    case "lowercamel":
                        return StringCaseFormat.LOWER_CAMEL_CASE.apply(arg.toString().replace(".", "-"));
                    case "uppercamel":
                        return StringCaseFormat.UPPER_CAMEL_CASE.apply(arg.toString().replace(".", "-"));
                    case "jsonescape":
                        return StringEscapeUtils.escapeJson(arg.toString());
                    default:
                        return arg.toString();
                }
            });
    return stGroup;
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:33,代码来源:AbstractTemplateGenerator.java

示例2: setFormat

import org.stringtemplate.v4.STGroupFile; //导入方法依赖的package包/类
/** The format gets reset either from the Tool if the user supplied a command line option to that effect
 *  Otherwise we just use the default "antlr".
 */
public void setFormat(String formatName) {
    this.formatName = formatName;
    String fileName = FORMATS_DIR +formatName+STGroup.GROUP_FILE_EXTENSION;
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    URL url = cl.getResource(fileName);
    if ( url==null ) {
        cl = ErrorManager.class.getClassLoader();
        url = cl.getResource(fileName);
    }
    if ( url==null && formatName.equals("antlr") ) {
        rawError("ANTLR installation corrupted; cannot find ANTLR messages format file "+fileName);
        panic();
    }
    else if ( url==null ) {
        rawError("no such message format file "+fileName+" retrying with default ANTLR format");
        setFormat("antlr"); // recurse on this rule, trying the default message format
        return;
    }

    format = new STGroupFile(fileName, "UTF-8");
    format.load();

    if ( !initSTListener.errors.isEmpty() ) {
        rawError("ANTLR installation corrupted; can't load messages format file:\n"+
                 initSTListener.toString());
        panic();
    }

    boolean formatOK = verifyFormat();
    if ( !formatOK && formatName.equals("antlr") ) {
        rawError("ANTLR installation corrupted; ANTLR messages format file "+formatName+".stg incomplete");
        panic();
    }
    else if ( !formatOK ) {
        setFormat("antlr"); // recurse on this rule, trying the default message format
    }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:41,代码来源:ErrorManager.java


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