KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > core > filter > SuggestionProperty


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.core.filter;
21
22 import org.openide.util.NbBundle;
23
24
25
26 /**
27  * Lightweight property for indirect access to suggestion
28  * properties. Replaces both reflection and property-getter-dispatchers
29  * in filters and view columns. Represents an API to add properties to
30  * task views and filters. We don't like bean properties and reflection
31  * for effectivity reasons.
32  *
33  * A property serves to extract the value it represents from
34  * a given Suggestion.
35  *
36  * Properties for different views/filters/... are difined in factories
37  * named in plural like SuggestionProperties, TaskProperties, etc.
38  */

39 public abstract class SuggestionProperty {
40   protected SuggestionProperty(String JavaDoc id, Class JavaDoc valueClass) {
41     this.id = id;
42   }
43
44   public String JavaDoc getID() { return id;}
45
46   /**
47    * Returns human readable name of this property. The name is
48    * retrieved from the bundle stored in the same directory as
49    * the real class of this property with the key:
50    * "LBL_" + getID() + "Property".
51    * @return localized String
52    */

53   public String JavaDoc getName() {
54     if (name == null) {
55       name = NbBundle.getMessage(this.getClass(), "LBL_" + id + "Property");
56     }
57     return name;
58   }
59
60   /**
61    * Returns human readable hint for this property. The hint is
62    * retrieved from the bundle stored in the same directory as
63    * the real class of this property with the key:
64    * "HNT_" + getID() + "Property".
65    * @return localized String
66    */

67   public String JavaDoc getHint() {
68     if (hint == null) {
69       hint = NbBundle.getMessage(this.getClass(), "HNT_" + id + "Property");
70     }
71     return hint;
72   }
73
74
75   /**
76    * Extract the value represented by this property from the given
77    * suggestion.
78    * @param obj the Suggestion to extract from
79    * @return Object value extracted
80    */

81   public abstract Object JavaDoc getValue(Object JavaDoc obj);
82
83   public String JavaDoc toString() { return id;}
84
85   /**
86    * Returns class of values of this property.
87    * @return Class
88    */

89   public Class JavaDoc getValueClass() { return valueClass;}
90
91
92   ///////
93
private String JavaDoc id;
94   transient private String JavaDoc name;
95   transient private String JavaDoc hint;
96   private Class JavaDoc valueClass;
97 }
98
99
Popular Tags