com.github.mustachejava.Mustache.getCodes()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中com.github.mustachejava.Mustache.getCodes()方法的一些代码示例,展示了Mustache.getCodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mustache.getCodes()方法的具体详情如下:
包路径:com.github.mustachejava.Mustache
类名称:Mustache
方法名:getCodes

Mustache.getCodes介绍

[英]Get the underlying code objects.
[中]获取底层代码对象。

代码示例

代码示例来源:origin: spullara/mustache.java

@Override
public Code[] getCodes() {
 return partial == null ? null : partial.getCodes();
}

代码示例来源:origin: spullara/mustache.java

public Code[] getCodes() {
 return mustache == null ? null : mustache.getCodes();
}

代码示例来源:origin: spullara/mustache.java

@SuppressWarnings("StatementWithEmptyBody")
@Override
public synchronized void init() {
 filterText();
 Map<String, ExtendNameCode> replaceMap = new HashMap<>();
 for (Code code : mustache.getCodes()) {
  if (code instanceof ExtendNameCode) {
   // put name codes in the map
   ExtendNameCode erc = (ExtendNameCode) code;
   replaceMap.put(erc.getName(), erc);
   erc.init();
  } else if ((code instanceof WriteCode) || (code instanceof CommentCode)) {
   // ignore text and comments
  } else {
   // fail on everything else
   throw new IllegalArgumentException(
       "Illegal code in extend section: " + code.getClass().getName());
  }
 }
 Mustache original = mf.compilePartial(partialName());
 partial = (Mustache) original.clone();
 Code[] supercodes = partial.getCodes();
 // recursively replace named sections with replacements
 Set<Code> seen = new HashSet<>();
 seen.add(partial);
 partial.setCodes(replaceCodes(supercodes, replaceMap, seen));
}

代码示例来源:origin: com.github.spullara.mustache.java/compiler

@Override
public Code[] getCodes() {
 return partial == null ? null : partial.getCodes();
}

代码示例来源:origin: com.github.spullara.mustache.java/compiler

public Code[] getCodes() {
 return mustache == null ? null : mustache.getCodes();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mustache-compiler

@Override
public Code[] getCodes() {
 return partial == null ? null : partial.getCodes();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mustache-compiler

public Code[] getCodes() {
 return mustache == null ? null : mustache.getCodes();
}

代码示例来源:origin: org.codelibs.elasticsearch.module/lang-mustache

UrlEncoderCode(TemplateContext tc, DefaultMustacheFactory df, Mustache mustache, String variable) {
  super(tc, df, mustache.getCodes(), variable);
  this.encoder = new UrlEncoder();
}

代码示例来源:origin: org.elasticsearch.plugin/lang-mustache-client

UrlEncoderCode(TemplateContext tc, DefaultMustacheFactory df, Mustache mustache, String variable) {
  super(tc, df, mustache.getCodes(), variable);
  this.encoder = new UrlEncoder();
}

代码示例来源:origin: com.github.spullara.mustache.java/compiler

@SuppressWarnings("StatementWithEmptyBody")
@Override
public synchronized void init() {
 filterText();
 Map<String, ExtendNameCode> replaceMap = new HashMap<>();
 for (Code code : mustache.getCodes()) {
  if (code instanceof ExtendNameCode) {
   // put name codes in the map
   ExtendNameCode erc = (ExtendNameCode) code;
   replaceMap.put(erc.getName(), erc);
   erc.init();
  } else if ((code instanceof WriteCode) || (code instanceof CommentCode)) {
   // ignore text and comments
  } else {
   // fail on everything else
   throw new IllegalArgumentException(
       "Illegal code in extend section: " + code.getClass().getName());
  }
 }
 Mustache original = mf.compilePartial(partialName());
 partial = (Mustache) original.clone();
 Code[] supercodes = partial.getCodes();
 // recursively replace named sections with replacements
 Set<Code> seen = new HashSet<>();
 seen.add(partial);
 partial.setCodes(replaceCodes(supercodes, replaceMap, seen));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mustache-compiler

@SuppressWarnings("StatementWithEmptyBody")
@Override
public synchronized void init() {
 filterText();
 Map<String, ExtendNameCode> replaceMap = new HashMap<>();
 for (Code code : mustache.getCodes()) {
  if (code instanceof ExtendNameCode) {
   // put name codes in the map
   ExtendNameCode erc = (ExtendNameCode) code;
   replaceMap.put(erc.getName(), erc);
   erc.init();
  } else if ((code instanceof WriteCode) || (code instanceof CommentCode)) {
   // ignore text and comments
  } else {
   // fail on everything else
   throw new IllegalArgumentException(
       "Illegal code in extend section: " + code.getClass().getName());
  }
 }
 Mustache original = mf.compilePartial(partialName());
 partial = (Mustache) original.clone();
 Code[] supercodes = partial.getCodes();
 // recursively replace named sections with replacements
 Set<Code> seen = new HashSet<>();
 seen.add(partial);
 partial.setCodes(replaceCodes(supercodes, replaceMap, seen));
}

代码示例来源:origin: org.elasticsearch.plugin/lang-mustache-client

/**
   * At compile time, this function extracts the name of the variable:
   * {{#toJson}}variable_name{{/toJson}}
   */
  protected static String extractVariableName(String fn, Mustache mustache, TemplateContext tc) {
    Code[] codes = mustache.getCodes();
    if (codes == null || codes.length != 1) {
      throw new MustacheException("Mustache function [" + fn + "] must contain one and only one identifier");
    }
    try (StringWriter capture = new StringWriter()) {
      // Variable name is in plain text and has type WriteCode
      if (codes[0] instanceof WriteCode) {
        codes[0].execute(capture, Collections.emptyList());
        return capture.toString();
      } else {
        codes[0].identity(capture);
        return capture.toString();
      }
    } catch (IOException e) {
      throw new MustacheException("Exception while parsing mustache function [" + fn + "] at line " + tc.line(), e);
    }
  }
}

代码示例来源:origin: org.codelibs.elasticsearch.module/lang-mustache

/**
   * At compile time, this function extracts the name of the variable:
   * {{#toJson}}variable_name{{/toJson}}
   */
  protected static String extractVariableName(String fn, Mustache mustache, TemplateContext tc) {
    Code[] codes = mustache.getCodes();
    if (codes == null || codes.length != 1) {
      throw new MustacheException("Mustache function [" + fn + "] must contain one and only one identifier");
    }
    try (StringWriter capture = new StringWriter()) {
      // Variable name is in plain text and has type WriteCode
      if (codes[0] instanceof WriteCode) {
        codes[0].execute(capture, Collections.emptyList());
        return capture.toString();
      } else {
        codes[0].identity(capture);
        return capture.toString();
      }
    } catch (IOException e) {
      throw new MustacheException("Exception while parsing mustache function [" + fn + "] at line " + tc.line(), e);
    }
  }
}

代码示例来源:origin: harbby/presto-connectors

/**
   * At compile time, this function extracts the name of the variable:
   * {{#toJson}}variable_name{{/toJson}}
   */
  protected static String extractVariableName(String fn, Mustache mustache, TemplateContext tc) {
    Code[] codes = mustache.getCodes();
    if (codes == null || codes.length != 1) {
      throw new MustacheException("Mustache function [" + fn + "] must contain one and only one identifier");
    }
    try (StringWriter capture = new StringWriter()) {
      // Variable name is in plain text and has type WriteCode
      if (codes[0] instanceof WriteCode) {
        codes[0].execute(capture, Collections.emptyList());
        return capture.toString();
      } else {
        codes[0].identity(capture);
        return capture.toString();
      }
    } catch (IOException e) {
      throw new MustacheException("Exception while parsing mustache function [" + fn + "] at line " + tc.line(), e);
    }
  }
}

相关文章