1 52 53 package freemarker.template; 54 55 import java.util.List ; 56 import java.util.ArrayList ; 57 58 65 66 final class GeneralPurposeNothing 67 implements TemplateBooleanModel, TemplateScalarModel, TemplateSequenceModel, TemplateHashModelEx, TemplateMethodModelEx { 68 69 private static final TemplateModel instance = new GeneralPurposeNothing(); 70 71 private static final TemplateCollectionModel EMPTY_COLLECTION = new SimpleCollection(new ArrayList (0)); 72 73 private GeneralPurposeNothing() { 74 } 75 76 static TemplateModel getInstance() { 77 return instance; 78 } 79 80 public String getAsString() { 81 return ""; 82 } 83 84 public boolean getAsBoolean() { 85 return false; 86 } 87 88 public boolean isEmpty() { 89 return true; 90 } 91 92 public int size() { 93 return 0; 94 } 95 96 public TemplateModel get(int i) throws TemplateModelException { 97 throw new TemplateModelException("Empty list"); 98 } 99 100 public TemplateModel get(String key) { 101 return null; 102 } 103 104 public Object exec(List args) { 105 return null; 106 } 107 108 public TemplateCollectionModel keys() { 109 return EMPTY_COLLECTION; 110 } 111 112 public TemplateCollectionModel values() { 113 return EMPTY_COLLECTION; 114 } 115 } 116 | Popular Tags |