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); } }
@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)); }
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); } }
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); } }
@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)); }
@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)); }