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


Java ST.add方法代码示例

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


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

示例1: getSpecialCaseSetupBody

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
static String getSpecialCaseSetupBody(SchemaColumn schemaColumn) {
    STGroup group = new STGroupFile("eclectic/orc/template/methodSpecialCaseSetup.stg");
    // Special case setup is needed for lists to adjust list child vector size.
    List<SchemaColumn> listSchemaTypes = new ArrayList<>();
    Stack<SchemaColumn> structTypes = new Stack<>();
    structTypes.push(schemaColumn);
    while (!structTypes.isEmpty()) {
        for (SchemaColumn child : structTypes.pop().getComplexType().getStructChildren()) {
            if (child.getTypeInfo().isTypeStruct()) {
                structTypes.push(child);
            } else if (child.getTypeInfo().isTypeList()) {
                listSchemaTypes.add(child);
            }
        }
    }
    ST st = group.getInstanceOf("methodSpecialCaseSetup");
    st.add("list", listSchemaTypes);
    String s = st.render();
    logger.trace(s);
    return s;
}
 
开发者ID:eclecticlogic,项目名称:eclectic-orc,代码行数:22,代码来源:OrcWriterBootstrap.java

示例2: generateContent

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
@VisibleForTesting
String generateContent(final URL staticFile, final Api api) throws IOException {
    final ST st = getStGroup(staticFile);

    final String fileName = new File(staticFile.getPath()).getName();
    st.add("api", new ApiGenModel(api));
    if (fileName.equals("collection.json.stg")) {
        st.add("id", "f367b534-c9ea-e7c5-1f46-7a27dc6a30ba");
        final String readme = getStGroup(Resources.getResource("templates/postman/README.md.stg")).render();
        st.add("readme", readme);
    }
    if (fileName.equals("template.json.stg"))  {
        st.add("id", "5bb74f05-5e78-4aee-b59e-492c947bc160");
    }
    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:17,代码来源:CollectionGenerator.java

示例3: caseObjectType

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
@Override
public String caseObjectType(final ObjectType objectType) {
    if (objectType.getName() == null) {
        return null;
    } else {
        final TypeGenModel typeGenModel = new TypeGenModel(objectType);

        final ST st = stGroup.getInstanceOf(type);
        st.add("vendorName", vendorName);
        if (type.equals(TYPE_INTERFACE) || type.equals(TYPE_MODEL)) {
            st.add("type", typeGenModel);
        } else if (type.equals(TYPE_COLLECTION_INTERFACE) || type.equals(TYPE_COLLECTION_MODEL)) {
            st.add("type", new CollectionGenModel(objectType));
        }

        return st.render();
    }
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:19,代码来源:TypesGenerator.java

示例4: generateContent

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
@VisibleForTesting
String generateContent(URL staticFile, Api api) throws IOException {
    final STGroupFile stGroup = createSTGroup(staticFile);
    final String fileName = new File(staticFile.getPath()).getName();

    final ST st = stGroup.getInstanceOf("main");
    st.add("vendorName", vendorName);
    if (fileName.equals("ResourceClassMap.php.stg")) {
        st.add("package", TypeGenModel.TYPES);
    }
    if (fileName.equals("Config.php.stg")) {
        final String apiUri = api.getBaseUri().getTemplate();
        final String authUri = api.getSecuritySchemes().stream()
                .filter(securityScheme -> securityScheme.getSettings() instanceof OAuth20Settings)
                .map(securityScheme -> ((OAuth20Settings)securityScheme.getSettings()).getAccessTokenUri())
                .findFirst().orElse("");
        st.add("apiUri", apiUri);
        st.add("authUri", authUri);
    }
    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:22,代码来源:StaticGenerator.java

示例5: generateCodeForTable

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
/**
 * Generates a java code file that can later be used to generate SQL insert strings for the given extractor table.
 * All the data are taken from the {@link TableModel}, which was filled by a {@link com.btc.redg.generator.extractor.TableExtractor} (normally used by the
 * {@link com.btc.redg.generator.extractor.MetadataExtractor})
 * <p>
 * For each column in this table the generated class will contain a private variable holding the value and a builder method to set the value. Foreign key
 * columns will be a reference to the generated class/object for that table and need to be passed via the constructor to ensure that foreign key constraints
 * are met and inserts will be in the right order. Proper {@code null}-checks will be generated.
 *
 * @param table                      The extracted table model to generate code for
 * @param enableVisualizationSupport If {@code true}, the RedG visualization features will be enabled for the generated code. This will result in a small
 *                                   performance hit and slightly more memory usage if activated.
 * @return The generated source code
 */
public String generateCodeForTable(final TableModel table, final boolean enableVisualizationSupport) {
    final ST template = this.stGroup.getInstanceOf("tableClass");
    LOG.debug("Filling template...");
    template.add("table", table);
    LOG.debug("Package is {} | Class name is {}", table.getPackageName(), table.getClassName());

    template.add("colAndForeignKeys", table.hasColumnsAndForeignKeys());
    template.add("firstRowComma", (!table.getNullableForeignKeys().isEmpty() || table.hasColumnsAndForeignKeys()) && !table.getNotNullForeignKeys().isEmpty());
    template.add("secondRowComma", table.hasColumnsAndForeignKeys() && !table.getNullableForeignKeys().isEmpty());

    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(table);
        oos.close();
        String serializedData = Base64.getEncoder().encodeToString(baos.toByteArray());
        template.add("serializedTableModelString", serializedData);
    } catch (IOException e) {
        LOG.error("Could not serialize table model. Model will not be included in the file", e);
    }
    template.add("enableVisualizationSupport", enableVisualizationSupport);

    LOG.debug("Rendering template...");
    return template.render();
}
 
开发者ID:btc-ag,项目名称:redg,代码行数:40,代码来源:CodeGenerator.java

示例6: generateMainClass

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
/**
 * Generates the main class used for creating the extractor objects and later generating the insert statements.
 * For each passed table a appropriate creation method will be generated that will return the new object and internally add it to the list of objects that
 * will be used to generate the insert strings
 *
 * @param tables                     All tables that should get a creation method in the main class
 * @param enableVisualizationSupport If {@code true}, the RedG visualization features will be enabled for the generated code. This will result in a small
 *                                   performance hit and slightly more memory usage if activated.
 * @return The generated source code
 */
public String generateMainClass(final Collection<TableModel> tables, final boolean enableVisualizationSupport) {
    Objects.requireNonNull(tables);

    //get package from the table models
    final String targetPackage = ((TableModel) tables.toArray()[0]).getPackageName();
    final ST template = this.stGroup.getInstanceOf("mainClass");
    LOG.debug("Filling main class template containing helpers for {} classes...", tables.size());
    template.add("package", targetPackage);
    // TODO: make prefix usable
    template.add("prefix", "");
    template.add("enableVisualizationSupport", enableVisualizationSupport);
    LOG.debug("Package is {} | Prefix is {}", targetPackage, "");

    template.add("tables", tables);

    return template.render();
}
 
开发者ID:btc-ag,项目名称:redg,代码行数:28,代码来源:CodeGenerator.java

示例7: generateKitchenConfig

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
/**
 * Generate the kitchen yaml string for given local/remote work-order.
 *
 * @param wo work order.
 * @param sshKey ssh key path for the work order.
 * @param logKey log key
 * @return kitchen yaml string for the work-order.
 */
public String generateKitchenConfig(CmsWorkOrderSimpleBase wo, String sshKey, String logKey) {
  String inductorHome = config.getCircuitDir().replace("/packer", "");
  ST st = new ST(verifyTemplate);

  boolean isWin = isWinCompute(wo);
  String chefSolo = isWin ? "c:/opscode/chef/embedded/bin/chef-solo" : "/usr/local/bin/chef-solo";
  String rubyBindir = isWin ? "c:/opscode/chef/embedded/bin" : "/usr/bin";
  String provisionerPath = isWin ? "c:/tmp/kitchen" : "/tmp/kitchen";

  st.add("local", !isRemoteChefCall(wo));
  st.add("circuit_root", getCircuitDir(wo));
  st.add("inductor_home", inductorHome);
  st.add("recipe_name", wo.getAction());
  st.add("driver_host", getHost(wo, logKey));
  st.add("platform_name", "centos-7.1");
  st.add("user", ONEOPS_USER);
  st.add("ssh_key", sshKey);
  st.add("windows", isWin);
  st.add("chef_solo_path", chefSolo);
  st.add("ruby_bindir", rubyBindir);
  st.add("provisioner_root_path", provisionerPath);
  st.add("verifier_root_path", getVerifierPath(wo));
  return st.render();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:33,代码来源:AbstractOrderExecutor.java

示例8: createTypeDescriptionBody

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
static String createTypeDescriptionBody(SchemaColumn schemaColumn) {
    STGroup group = new STGroupFile("eclectic/orc/template/methodCreateTypeDescription.stg");
    ST st = group.getInstanceOf("methodGetTypeDescription");
    st.add("schemaColumn", schemaColumn);
    String s = st.render();
    logger.trace(s);
    return s;
}
 
开发者ID:eclecticlogic,项目名称:eclectic-orc,代码行数:9,代码来源:OrcWriterBootstrap.java

示例9: getWriteBody

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
static String getWriteBody(SchemaColumn schemaColumn, Class<?> schemaClass) {
    STGroup group = new STGroupFile("eclectic/orc/template/methodWrite.stg");
    ST st = group.getInstanceOf("methodWrite");
    st.add("schemaColumn", schemaColumn);
    st.add("sclass", schemaClass);
    String s = st.render();
    logger.trace(s);
    return s;
}
 
开发者ID:eclecticlogic,项目名称:eclectic-orc,代码行数:10,代码来源:OrcWriterBootstrap.java

示例10: caseArrayType

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
@Override
public String caseArrayType(final ArrayType arrayType) {
    final AnyType items = arrayType.getItems();
    if (items == null || items.getName() == null) {
        return null;
    }
    final ST st = stGroup.getInstanceOf(type);
    st.add("type", items);
    final Boolean builtInParentType = items.getType() == null || BuiltinType.of(items.getName()).isPresent();
    st.add("builtInParent", builtInParentType);
    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:13,代码来源:TypesGenerator.java

示例11: caseObjectType

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
@Override
public String caseObjectType(final ObjectType objectType) {
    if (objectType.getName() == null) {
        return null;
    } else {
        final ST st = stGroup.getInstanceOf(type);
        st.add("type", objectType);
        final Boolean builtInParentType = objectType.getType() == null || BuiltinType.of(objectType.getType().getName()).isPresent();
        st.add("builtInParent", builtInParentType);
        return st.render();
    }
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:13,代码来源:TypesGenerator.java

示例12: generateBuilder

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
String generateBuilder(final RootResourceGenModel resource) {
    final STGroupFile stGroup = createSTGroup(Resources.getResource(resourcesPath + TYPE_RESOURCE + ".stg"));
    final ST st = stGroup.getInstanceOf("builder");
    st.add("vendorName", vendorName);
    st.add("resource", resource);
    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:8,代码来源:RequestGenerator.java

示例13: generateRequest

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
String generateRequest(final RequestGenModel request) {
    final STGroupFile stGroup = createSTGroup(Resources.getResource(resourcesPath + TYPE_RESOURCE + ".stg"));
    final ST st = stGroup.getInstanceOf("request");
    st.add("vendorName", vendorName);
    st.add("request", request);
    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:8,代码来源:RequestGenerator.java

示例14: generateResource

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
String generateResource(final ResourceGenModel resource) {
    final STGroup stGroup = createSTGroup(Resources.getResource(resourcesPath + TYPE_RESOURCE + ".stg"));
    final ST st = stGroup.getInstanceOf("resource");
    st.add("vendorName", vendorName);
    st.add("resource", resource);


    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:10,代码来源:RequestGenerator.java

示例15: caseArrayType

import org.stringtemplate.v4.ST; //导入方法依赖的package包/类
@Override
public String caseArrayType(final ArrayType arrayType) {
    final AnyType items = arrayType.getItems();
    if (items == null || items.getName() == null) {
        return null;
    }
    final ST st = stGroup.getInstanceOf(type);
    st.add("vendorName", vendorName);
    st.add("type", new CollectionGenModel(items));
    return st.render();
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:12,代码来源:TypesGenerator.java


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