alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.tasklist.client;

import org.openide.util.NbBundle;



/**
 * Lightweight property for indirect access to suggestion
 * properties. Replaces both reflection and property-getter-dispatchers
 * in filters and view columns. Represents an API to add properties to
 * task views and filters. We don't like bean properties and reflection
 * for effectivity reasons.
 * 
 * A property serves to extract the value it represents from
 * a given Suggestion. 
 *
 * Properties for different views/filters/... are difined in factories
 * named in plural like SuggestionProperties, TaskProperties, etc.
 */
public abstract class SuggestionProperty {
  protected SuggestionProperty(String id, Class valueClass) {
    this.id = id;
  }

  public String getID() { return id;}

  /**
   * Returns human readable name of this property. The name is
   * retrieved from the bundle stored in the same directory as 
   * the real class of this property with the key: 
   * "LBL_" + getID() + "Property". 
   * @return localized String
   */
  public String getName() { 
    if (name == null) {
      name = NbBundle.getMessage(this.getClass(), "LBL_" + id + "Property"); 
    }
    return name;
  }

  /**
   * Returns human readable hint for this property. The hint is
   * retrieved from the bundle stored in the same directory as 
   * the real class of this property with the key: 
   * "HNT_" + getID() + "Property". 
   * @return localized String
   */
  public String getHint() { 
    if (hint == null) {
      hint = NbBundle.getMessage(this.getClass(), "HNT_" + id + "Property"); 
    }
    return hint;
  }


  /**
   * Extract the value represented by this property from the given 
   * suggestion.
   * @param obj the Suggestion to extract from
   * @return Object value extracted
   */ 
  public abstract Object getValue(Object obj);

  public String toString() { return id;}

  /** 
   * Returns class of values of this property.
   * @return Class
   */
  public Class getValueClass() { return valueClass;}


  ///////
  private String id;
  transient private String name;
  transient private String hint;
  private Class valueClass;
}

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.