KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > editor > settings > CodeTemplateDescription


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.editor.settings;
21
22 import java.util.List JavaDoc;
23
24 /**
25  * Description of the code template includes abbreviation name,
26  * description and parametrized text.
27  * <br/>
28  * The descriptions are provided from
29  * {@link CodeTemplateSettings#getCodeTemplateDescriptions()}.
30  *
31  * @author Miloslav Metelka
32  */

33 public final class CodeTemplateDescription {
34
35     private final String JavaDoc abbreviation;
36
37     private final String JavaDoc description;
38
39     private final String JavaDoc parametrizedText;
40
41     /**
42      * Construct code template description.
43      * It can be constructed e.g. from the templates stored in an xml format.
44      *
45      * @param abbreviation non-null abbreviation.
46      * @param description non-null description.
47      * @param parametrizedText non-null parametrized text.
48      */

49     public CodeTemplateDescription(String JavaDoc abbreviation, String JavaDoc description, String JavaDoc parametrizedText) {
50         this(abbreviation, description, parametrizedText, null);
51     }
52     
53     public CodeTemplateDescription(String JavaDoc abbreviation, String JavaDoc description, String JavaDoc parametrizedText, List JavaDoc<String JavaDoc> contexts) {
54         assert (abbreviation != null);
55         assert (description != null);
56         assert (parametrizedText != null);
57         this.abbreviation = abbreviation;
58         this.description = description;
59         this.parametrizedText = parametrizedText;
60         this.contexts = contexts;
61     }
62     
63     private final List JavaDoc<String JavaDoc> contexts;
64     
65     /**
66      * Get abbreviation that triggers expansion of this code template.
67      * <br>
68      * It should be unique among code templates for a single mime-type
69      * so that each code template can be expanded individually.
70      *
71      * @return non-null abbreviation that expands to this template.
72      */

73     public String JavaDoc getAbbreviation() {
74         return abbreviation;
75     }
76
77     /**
78      * Get textual description of this code template.
79      * <br>
80      * It's being displayed e.g. in the code completion window.
81      *
82      * @return non-null description text.
83      */

84     public String JavaDoc getDescription() {
85         return description;
86     }
87
88     /**
89      * Get the parametrized text of this code template.
90      * <br>
91      * The parameters have form "${...}" and there can be arbitrary
92      * number of them.
93      *
94      * @return non-null parametrized text.
95      */

96     public String JavaDoc getParametrizedText() {
97         return parametrizedText;
98     }
99
100     public List JavaDoc<String JavaDoc> getContexts() {
101         return contexts;
102     }
103
104     public String JavaDoc toString() {
105         return "abbrev='" + getAbbreviation() + "', parametrizedText='" + getParametrizedText() + "'"; // NOI18N
106
}
107     
108 }
109
Popular Tags