1 11 package org.eclipse.jface.text.templates; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.eclipse.jface.text.BadLocationException; 17 18 27 public abstract class TemplateContext { 28 29 30 private final TemplateContextType fContextType; 31 32 private final Map fVariables= new HashMap (); 33 34 private boolean fReadOnly; 35 36 41 protected TemplateContext(TemplateContextType contextType) { 42 fContextType= contextType; 43 fReadOnly= true; 44 } 45 46 51 public TemplateContextType getContextType() { 52 return fContextType; 53 } 54 55 60 public void setReadOnly(boolean readOnly) { 61 fReadOnly= readOnly; 62 } 63 64 69 public boolean isReadOnly() { 70 return fReadOnly; 71 } 72 73 79 public void setVariable(String name, String value) { 80 fVariables.put(name, value); 81 } 82 83 89 public String getVariable(String name) { 90 return (String ) fVariables.get(name); 91 } 92 93 105 public abstract TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException; 106 107 116 public abstract boolean canEvaluate(Template template); 117 118 } 119 | Popular Tags |