1 11 package org.eclipse.jface.text.templates; 12 13 import org.eclipse.core.runtime.Assert; 14 15 22 public class Template { 23 24 25 private String fName; 26 27 private String fDescription; 28 29 private String fContextTypeId; 30 31 private String fPattern; 32 36 private final boolean fIsAutoInsertable; 37 38 41 public Template() { 42 this("", "", "", "", true); } 44 45 50 public Template(Template template) { 51 this(template.getName(), template.getDescription(), template.getContextTypeId(), template.getPattern(), template.isAutoInsertable()); 52 } 53 54 63 public Template(String name, String description, String contextTypeId, String pattern) { 64 this(name, description, contextTypeId, pattern, true); } 66 67 77 public Template(String name, String description, String contextTypeId, String pattern, boolean isAutoInsertable) { 78 Assert.isNotNull(description); 79 fDescription= description; 80 fName= name; 81 Assert.isNotNull(contextTypeId); 82 fContextTypeId= contextTypeId; 83 fPattern= pattern; 84 fIsAutoInsertable= isAutoInsertable; 85 } 86 87 90 public int hashCode() { 91 return fName.hashCode() ^ fPattern.hashCode() ^ fContextTypeId.hashCode(); 92 } 93 94 100 public void setDescription(String description) { 101 Assert.isNotNull(description); 102 fDescription= description; 103 } 104 105 110 public String getDescription() { 111 return fDescription; 112 } 113 114 120 public void setContextTypeId(String contextTypeId) { 121 Assert.isNotNull(contextTypeId); 122 fContextTypeId= contextTypeId; 123 } 124 125 130 public String getContextTypeId() { 131 return fContextTypeId; 132 } 133 134 140 public void setName(String name) { 141 fName= name; 142 } 143 144 149 public String getName() { 150 return fName; 151 } 152 153 159 public void setPattern(String pattern) { 160 fPattern= pattern; 161 } 162 163 168 public String getPattern() { 169 return fPattern; 170 } 171 172 181 public boolean matches(String prefix, String contextTypeName) { 182 return fContextTypeId.equals(contextTypeName); 183 } 184 185 188 public boolean equals(Object o) { 189 if (!(o instanceof Template)) 190 return false; 191 192 Template t= (Template) o; 193 if (t == this) 194 return true; 195 196 return t.fName.equals(fName) 197 && t.fPattern.equals(fPattern) 198 && t.fContextTypeId.equals(fContextTypeId) 199 && t.fDescription.equals(fDescription) 200 && t.fIsAutoInsertable == fIsAutoInsertable; 201 } 202 203 209 public boolean isAutoInsertable() { 210 return fIsAutoInsertable; 211 } 212 } 213 | Popular Tags |