1 52 53 package freemarker.core; 54 55 import java.io.IOException ; 56 import java.util.ArrayList ; 57 import freemarker.template.*; 58 59 final class AttemptBlock extends TemplateElement { 60 61 private TemplateElement attemptBlock, recoveryBlock; 62 63 AttemptBlock(TemplateElement attemptBlock, TemplateElement recoveryBlock) { 64 this.attemptBlock = attemptBlock; 65 this.recoveryBlock = recoveryBlock; 66 nestedElements = new ArrayList (); 67 nestedElements.add(attemptBlock); 68 nestedElements.add(recoveryBlock); 69 } 70 71 void accept(Environment env) throws TemplateException, IOException 72 { 73 env.visit(attemptBlock, recoveryBlock); 74 } 75 76 public String getCanonicalForm() { 77 StringBuffer buf = new StringBuffer ("<#attempt>"); 78 if (attemptBlock != null) { 79 buf.append(attemptBlock.getCanonicalForm()); 80 } 81 if (recoveryBlock != null) { 82 buf.append(recoveryBlock.getCanonicalForm()); 83 } 84 return buf.toString(); 85 } 86 87 public String getDescription() { 88 return "attempt block"; 89 } 90 } 91 | Popular Tags |