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


Java SoyListData类代码示例

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


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

示例1: serve

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
void serve(final Webpath webpath) throws IOException {
  response.setContentType(MediaType.HTML_UTF_8);
  response.setPayload(
      TOFU.newRenderer(ListingSoyInfo.LISTING)
          .setData(
              new SoyMapData(
                  ListingSoyInfo.ListingSoyTemplateInfo.LABEL,
                  config.get().getLabel(),
                  ListingSoyInfo.ListingSoyTemplateInfo.PATHS,
                  new SoyListData(
                      FluentIterable.from(webpaths)
                          .filter(
                              new Predicate<Webpath>() {
                                @Override
                                public boolean apply(Webpath path) {
                                  return path.startsWith(webpath);
                                }
                              })
                          .transform(Functions.toStringFunction()))))
          .render()
          .getBytes(StandardCharsets.UTF_8));
}
 
开发者ID:bazelbuild,项目名称:rules_closure,代码行数:23,代码来源:ListingPage.java

示例2: doGetHtml

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
@Override
protected void doGetHtml(HttpServletRequest req, HttpServletResponse res) throws IOException {
  Map<String, RepositoryDescription> descs = getDescriptions(req, res);
  if (descs == null) {
    return;
  }
  SoyListData repos = new SoyListData();
  for (RepositoryDescription desc : descs.values()) {
    repos.add(toSoyMapData(desc, ViewFilter.getView(req)));
  }

  renderHtml(req, res, "gitiles.hostIndex", ImmutableMap.of(
      "hostName", urls.getHostName(req),
      "baseUrl", urls.getBaseGitUrl(req),
      "repositories", repos));
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:17,代码来源:HostIndexServlet.java

示例3: getDiffTemplateData

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
/**
 * Generate a Soy list of maps representing each line of the unified diff. The line maps will have
 * a 'type' key which maps to one of 'common', 'add' or 'remove' and a 'text' key which maps to
 * the line's content.
 */
private SoyListData getDiffTemplateData() {
  SoyListData result = new SoyListData();
  Splitter lineSplitter = Splitter.on(System.getProperty("line.separator"));
  for (String diffLine : lineSplitter.split(getUnifiedDiff())) {
    SoyMapData lineData = new SoyMapData();
    lineData.put("text", diffLine);

    // Skip empty lines and lines that look like diff headers.
    if (diffLine.isEmpty() || diffLine.startsWith("---") || diffLine.startsWith("+++")) {
      lineData.put("type", "common");
    } else {
      switch (diffLine.charAt(0)) {
        case '+':
          lineData.put("type", "add");
          break;
        case '-':
          lineData.put("type", "remove");
          break;
        default:
          lineData.put("type", "common");
          break;
      }
    }
    result.add(lineData);
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:ChangeEmail.java

示例4: main

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
/**
 * Prints the generated HTML to stdout.
 *
 * @param args Not used.
 */
public static void main(String[] args) {

  // Compile the template.
  SoyFileSet sfs = SoyFileSet.builder().add(Resources.getResource("simple.soy")).build();
  SoyTofu tofu = sfs.compileToTofu();

  // Example 1.
  writeExampleHeader();
  System.out.println(tofu.newRenderer("soy.examples.simple.helloWorld").render());

  // Create a namespaced tofu object to make calls more concise.
  SoyTofu simpleTofu = tofu.forNamespace("soy.examples.simple");

  // Example 2.
  writeExampleHeader();
  System.out.println(
      simpleTofu.newRenderer(".helloName").setData(new SoyMapData("name", "Ana")).render());

  // Example 3.
  writeExampleHeader();
  System.out.println(
      simpleTofu
          .newRenderer(".helloNames")
          .setData(new SoyMapData("names", new SoyListData("Bob", "Cid", "Dee")))
          .render());
}
 
开发者ID:google,项目名称:closure-templates,代码行数:32,代码来源:SimpleUsage.java

示例5: put

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
/**
 * Puts data into this data tree at the specified key string.
 *
 * @param keyStr One or more map keys and/or list indices (separated by '.' if multiple parts).
 *     Indicates the path to the location within this data tree.
 * @param value The data to put at the specified location.
 */
public void put(String keyStr, SoyData value) {

  List<String> keys = split(keyStr, '.');
  int numKeys = keys.size();

  CollectionData collectionData = this;
  for (int i = 0; i <= numKeys - 2; ++i) {

    SoyData nextSoyData = collectionData.getSingle(keys.get(i));
    if (nextSoyData != null && !(nextSoyData instanceof CollectionData)) {
      throw new SoyDataException("Failed to evaluate key string \"" + keyStr + "\" for put().");
    }
    CollectionData nextCollectionData = (CollectionData) nextSoyData;

    if (nextCollectionData == null) {
      // Create the SoyData object that will be bound to keys.get(i). We need to check the first
      // part of keys[i+1] to know whether to create a SoyMapData or SoyListData (checking the
      // first char is sufficient).
      nextCollectionData =
          (Character.isDigit(keys.get(i + 1).charAt(0))) ? new SoyListData() : new SoyMapData();
      collectionData.putSingle(keys.get(i), nextCollectionData);
    }
    collectionData = nextCollectionData;
  }

  collectionData.putSingle(keys.get(numKeys - 1), ensureValidValue(value));
}
 
开发者ID:google,项目名称:closure-templates,代码行数:35,代码来源:CollectionData.java

示例6: getTraces

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
@VisibleForTesting
SoyListData getTraces() {
  File[] traceFiles = tracesHelper.listTraceFiles();
  Arrays.sort(traceFiles, SORT_BY_LAST_MODIFIED);

  SoyListData traces = new SoyListData();
  for (File file : traceFiles) {
    String name = file.getName();
    if (TRACE_TO_IGNORE.equals(name)) {
      continue;
    }

    SoyMapData trace = new SoyMapData();
    trace.put("name", name);

    Matcher matcher = TRACE_FILE_NAME_PATTERN.matcher(name);
    if (matcher.matches()) {
      trace.put("id", matcher.group(1));
    }

    TraceAttributes traceAttributes = tracesHelper.getTraceAttributesFor(file);
    trace.put("dateTime", traceAttributes.getFormattedDateTime());
    if (traceAttributes.getCommand().isPresent()) {
      trace.put("command", traceAttributes.getCommand().get());
    } else {
      trace.put("command", "");
    }

    traces.add(trace);
  }
  return traces;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:33,代码来源:TracesHandlerDelegate.java

示例7: convert

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
public SoyListData convert(Set<ConvertedField> convertedFields) {
    SoyListData soyListData = new SoyListData();

    for(ConvertedField field : convertedFields) {
        soyListData.add(convert(field));
    }

    return soyListData;
}
 
开发者ID:AllTheDucks,项目名称:remotegenerator,代码行数:10,代码来源:ConvertedModelToSoyMapDataConverter.java

示例8: getListData

import com.google.template.soy.data.SoyListData; //导入依赖的package包/类
/**
 * Precondition: The specified key string is the path to a SoyListData object. Gets the
 * SoyListData at the specified key string.
 *
 * @param keyStr One or more map keys and/or list indices (separated by '.' if multiple parts).
 *     Indicates the path to the location within this data tree.
 * @return The SoyListData at the specified key string, or null if no data is stored there.
 */
public SoyListData getListData(String keyStr) {
  return (SoyListData) get(keyStr);
}
 
开发者ID:google,项目名称:closure-templates,代码行数:12,代码来源:CollectionData.java


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