1 19 20 package org.netbeans.lib.editor.codetemplates.api; 21 22 import java.util.List ; 23 import javax.swing.text.JTextComponent ; 24 import org.netbeans.lib.editor.codetemplates.CodeTemplateManagerOperation; 25 import org.netbeans.lib.editor.codetemplates.CodeTemplateSpiPackageAccessor; 26 import org.netbeans.lib.editor.codetemplates.spi.CodeTemplateInsertRequest; 27 28 40 public final class CodeTemplate { 41 42 private final CodeTemplateManagerOperation managerOperation; 43 44 private final String abbreviation; 45 46 private final String description; 47 48 private final String parametrizedText; 49 50 private final List contexts; 51 52 CodeTemplate(CodeTemplateManagerOperation managerOperation, 53 String abbreviation, String description, String parametrizedText, List contexts) { 54 55 assert (managerOperation != null); 56 if (abbreviation == null) { 57 throw new NullPointerException ("abbreviation cannot be null"); } 59 if (description == null) { 60 throw new NullPointerException ("description cannot be null"); } 62 if (parametrizedText == null) { 63 throw new NullPointerException ("parametrizedText cannot be null"); } 65 66 this.managerOperation = managerOperation; 67 this.abbreviation = abbreviation; 68 this.description = description; 69 this.parametrizedText = parametrizedText; 70 this.contexts = contexts; 71 } 72 73 79 public void insert(JTextComponent component) { 80 managerOperation.insert(this, component); 81 } 82 83 88 public String getAbbreviation() { 89 return abbreviation; 90 } 91 92 99 public String getDescription() { 100 return description; 101 } 102 103 111 public String getParametrizedText() { 112 return parametrizedText; 113 } 114 115 public List getContexts() { 116 return contexts; 117 } 118 119 122 CodeTemplateManagerOperation getOperation() { 123 return managerOperation; 124 } 125 126 public String toString() { 127 return "abbrev='" + getAbbreviation() + "', parametrizedText='" + getParametrizedText() + "'"; } 129 130 } 131 | Popular Tags |