/* * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package java.beans; import com.sun.beans.TypeResolver; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.lang.ref.SoftReference; import java.lang.reflect.Method; import java.util.Enumeration; import java.util.Hashtable; import java.util.Map.Entry; /** * The FeatureDescriptor class is the common baseclass for PropertyDescriptor, * EventSetDescriptor, and MethodDescriptor, etc. *
* It supports some common information that can be set and retrieved for * any of the introspection descriptors. *
* In addition it provides an extension mechanism so that arbitrary
* attribute/value pairs can be associated with a design feature.
*/
public class FeatureDescriptor {
private static final String TRANSIENT = "transient";
private ReferenceFeatureDescriptor
.
*/
public FeatureDescriptor() {
}
/**
* Gets the programmatic name of this feature.
*
* @return The programmatic name of the property/method/event
*/
public String getName() {
return name;
}
/**
* Sets the programmatic name of this feature.
*
* @param name The programmatic name of the property/method/event
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the localized display name of this feature.
*
* @return The localized display name for the property/method/event.
* This defaults to the same as its programmatic name from getName.
*/
public String getDisplayName() {
if (displayName == null) {
return getName();
}
return displayName;
}
/**
* Sets the localized display name of this feature.
*
* @param displayName The localized display name for the
* property/method/event.
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* The "expert" flag is used to distinguish between those features that are
* intended for expert users from those that are intended for normal users.
*
* @return True if this feature is intended for use by experts only.
*/
public boolean isExpert() {
return expert;
}
/**
* The "expert" flag is used to distinguish between features that are
* intended for expert users from those that are intended for normal users.
*
* @param expert True if this feature is intended for use by experts only.
*/
public void setExpert(boolean expert) {
this.expert = expert;
}
/**
* The "hidden" flag is used to identify features that are intended only
* for tool use, and which should not be exposed to humans.
*
* @return True if this feature should be hidden from human users.
*/
public boolean isHidden() {
return hidden;
}
/**
* The "hidden" flag is used to identify features that are intended only
* for tool use, and which should not be exposed to humans.
*
* @param hidden True if this feature should be hidden from human users.
*/
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
/**
* The "preferred" flag is used to identify features that are particularly
* important for presenting to humans.
*
* @return True if this feature should be preferentially shown to human users.
*/
public boolean isPreferred() {
return preferred;
}
/**
* The "preferred" flag is used to identify features that are particularly
* important for presenting to humans.
*
* @param preferred True if this feature should be preferentially shown
* to human users.
*/
public void setPreferred(boolean preferred) {
this.preferred = preferred;
}
/**
* Gets the short description of this feature.
*
* @return A localized short description associated with this
* property/method/event. This defaults to be the display name.
*/
public String getShortDescription() {
if (shortDescription == null) {
return getDisplayName();
}
return shortDescription;
}
/**
* You can associate a short descriptive string with a feature. Normally
* these descriptive strings should be less than about 40 characters.
* @param text A (localized) short description to be associated with
* this property/method/event.
*/
public void setShortDescription(String text) {
shortDescription = text;
}
/**
* Associate a named attribute with this feature.
*
* @param attributeName The locale-independent name of the attribute
* @param value The value.
*/
public void setValue(String attributeName, Object value) {
getTable().put(attributeName, value);
}
/**
* Retrieve a named attribute with this feature.
*
* @param attributeName The locale-independent name of the attribute
* @return The value of the attribute. May be null if
* the attribute is unknown.
*/
public Object getValue(String attributeName) {
return (this.table != null)
? this.table.get(attributeName)
: null;
}
/**
* Gets an enumeration of the locale-independent names of this
* feature.
*
* @return An enumeration of the locale-independent names of any
* attributes that have been registered with setValue.
*/
public Enumerationnull
if object is null
*
* @see SoftReference
*/
static null
if object is null
*
* @see WeakReference
*/
static