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

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

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

Mustache.clone介绍

[英]Deep clone of the mustache object.
[中]胡须对象的深度克隆。

代码示例

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

public Object clone(Set<Code> seen) {
 try {
  DefaultCode code = (DefaultCode) super.clone();
  Code[] codes = code.getCodes();
  if (codes != null) {
   // Create a new set of codes
   codes = codes.clone();
   for (int i = 0; i < codes.length; i++) {
    // If the code hasn't been seen before
    // use this one, else clone it.
    if (!seen.add(codes[i])) {
     codes[i] = (Code) codes[i].clone(seen);
     seen.remove(codes[i]);
    }
   }
   code.setCodes(codes);
  }
  if (mustache != null) {
   if (!seen.add(mustache)) {
    code.mustache = (Mustache) mustache.clone(seen);
    seen.remove(mustache);
   }
  }
  return code;
 } catch (CloneNotSupportedException e) {
  throw new MustacheException("Clone not supported", e, tc);
 }
}

代码示例来源: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

public Object clone(Set<Code> seen) {
 try {
  DefaultCode code = (DefaultCode) super.clone();
  Code[] codes = code.getCodes();
  if (codes != null) {
   // Create a new set of codes
   codes = codes.clone();
   for (int i = 0; i < codes.length; i++) {
    // If the code hasn't been seen before
    // use this one, else clone it.
    if (!seen.add(codes[i])) {
     codes[i] = (Code) codes[i].clone(seen);
     seen.remove(codes[i]);
    }
   }
   code.setCodes(codes);
  }
  if (mustache != null) {
   if (!seen.add(mustache)) {
    code.mustache = (Mustache) mustache.clone(seen);
    seen.remove(mustache);
   }
  }
  return code;
 } catch (CloneNotSupportedException e) {
  throw new MustacheException("Clone not supported", e, tc);
 }
}

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

public Object clone(Set<Code> seen) {
 try {
  DefaultCode code = (DefaultCode) super.clone();
  Code[] codes = code.getCodes();
  if (codes != null) {
   // Create a new set of codes
   codes = codes.clone();
   for (int i = 0; i < codes.length; i++) {
    // If the code hasn't been seen before
    // use this one, else clone it.
    if (!seen.add(codes[i])) {
     codes[i] = (Code) codes[i].clone(seen);
     seen.remove(codes[i]);
    }
   }
   code.setCodes(codes);
  }
  if (mustache != null) {
   if (!seen.add(mustache)) {
    code.mustache = (Mustache) mustache.clone(seen);
    seen.remove(mustache);
   }
  }
  return code;
 } catch (CloneNotSupportedException e) {
  throw new MustacheException("Clone not supported", e, tc);
 }
}

代码示例来源: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));
}

相关文章