KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > docscan > TaskTag


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.modules.tasklist.docscan;
21
22 import java.io.Externalizable JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.io.ObjectInput JavaDoc;
25 import java.io.ObjectOutput JavaDoc;
26
27 import org.netbeans.modules.tasklist.client.SuggestionPriority;
28
29
30 /** Represents a tag in the user's source code that should be interpreted
31  * as a task.
32  *
33  * @author Tor Norbye */

34 public final class TaskTag implements Externalizable JavaDoc {
35
36     static final long serialVersionUID = 1L;
37     private String JavaDoc token = null;
38     private SuggestionPriority priority = SuggestionPriority.MEDIUM;
39
40     public TaskTag() {
41     }
42     
43     /**
44      * Create a task tag with the given attributes
45      * @param token The token string that needs to occur in the source
46      * @param priority The priority to assign to tasks for these tokens
47      */

48     public TaskTag(String JavaDoc token, SuggestionPriority priority) {
49         this.token = token;
50         this.priority = priority;
51     }
52     
53     /** Set the token associated with the tag - this is a case sensitive
54      * string which when present in the user's code marks a task.
55      */

56     public void setToken(String JavaDoc token) {
57         this.token = token;
58     }
59
60     public String JavaDoc getToken() {
61         return token;
62     }
63
64     public void setPriority(SuggestionPriority priority) {
65         this.priority = priority;
66     }
67
68     public SuggestionPriority getPriority() {
69         return priority;
70     }
71
72     /** Generate a string summary of the tag; only used
73      * for debugging. DO NOT depend on this format for anything!
74      * @return summary string */

75     public String JavaDoc toString() {
76         return "TaskTag[\"" + token + "\", " + priority + "]"; // NOI18N
77
}
78
79
80     /** Read in a serialized version of the task tag
81      * @param objectInput object stream to read from
82      * @todo Use a more robust serialization format (not int uid based)
83      * @throws IOException
84      * @throws ClassNotFoundException */

85     public void readExternal(ObjectInput JavaDoc objectInput) throws IOException JavaDoc, java.lang.ClassNotFoundException JavaDoc {
86     int ver = objectInput.read();
87         //assert ver == 1 : "serialization version incorrect; should be 1";
88

89         // Read in the token
90
token = (String JavaDoc)objectInput.readObject();
91
92         // Read in the priority
93
int prioNum = ((Integer JavaDoc)objectInput.readObject()).intValue();
94         // TODO - this should really be a static factory in SuggestionPriority!
95
switch (prioNum) {
96         case 1: priority = SuggestionPriority.HIGH; break;
97         case 2: priority = SuggestionPriority.MEDIUM_HIGH; break;
98         case 3: priority = SuggestionPriority.MEDIUM; break;
99         case 4: priority = SuggestionPriority.MEDIUM_LOW; break;
100         case 5: priority = SuggestionPriority.LOW; break;
101         default: priority = SuggestionPriority.MEDIUM; break;
102         }
103     }
104
105     /** Write out relevant task tag settings data
106      * @param objectOutput Object stream to write to
107      * @throws IOException */

108     public void writeExternal(ObjectOutput JavaDoc objectOutput) throws IOException JavaDoc {
109         objectOutput.write(1); // SERIAL VERSION
110
objectOutput.writeObject(token);
111     objectOutput.writeObject(new Integer JavaDoc(priority.intValue()));
112     }
113
114 }
115
116
117
118
Popular Tags