UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.properties
Class ClassProperties

java.lang.Object
  |
  +--edu.berkeley.guir.lib.properties.FlexProperties
        |
        +--edu.berkeley.guir.lib.properties.ClassProperties
All Implemented Interfaces:
PropertyConstants

public class ClassProperties
extends FlexProperties

Inheritable properties for a class.

You can put in properties for a class of objects in here, and then retrieve them by specifying a class or by passing in an object. There are two advantages to putting key-values in here over putting them as static values in the class:

  1. key-values in here are inherited by subclasses, and
  2. default values can be assigned for keys

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Jun 02 2000, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.3
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
(jasonh@cs.berkeley.edu)

Fields inherited from interface edu.berkeley.guir.lib.properties.PropertyConstants
PROPERTY_BOUND, PROPERTY_CONSTRAINED, PROPERTY_INDEXED, PROPERTY_SIMPLE
 
Constructor Summary
ClassProperties()
           
 
Method Summary
 String generateClassKey(Class cl, String key)
          Given a class and a property name, generate a key.
 String generateDefaultKey(String key)
          Generate the default value for a key.
 Object getClassProperty(Class cl, String key)
          Recursively go up the inheritance chain, finding the first class that has a value for this key.
static void main(String[] argv)
           
 Object removeClassProperty(Class cl, String key)
          Remove the property for this class and key.
 void setClassProperty(Class cl, String key, Object newVal)
          Put a property in for this class, overriding an old value if there is one.
 void setDefaultProperty(String key, Object newVal)
          Put a default value in for this key.
 
Methods inherited from class edu.berkeley.guir.lib.properties.FlexProperties
addIndexedProperty, addPropertyChangeListener, addPropertyChangeListener, addSchema, addVetoableChangeListener, addVetoableChangeListener, clearIndexedProperty, containsSchema, containsSchema, disableNotify, disableNotify, enableNotify, enableNotify, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getIndexedProperty, getIndexedProperty, getProperty, getPropertyNames, getSchema, isEnabled, isEnabled, removeIndexedProperty, removeIndexedProperty, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSchema, removeVetoableChangeListener, removeVetoableChangeListener, setDefaultPropertyType, setIndexedProperty, setProperty, setSourceObject, setSpecifiedOnly, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassProperties

public ClassProperties()
Method Detail

generateClassKey

public String generateClassKey(Class cl,
                               String key)
Given a class and a property name, generate a key. For example, java.lang.Object and "Name" becomes "java.lang.Object-Name".

generateDefaultKey

public String generateDefaultKey(String key)
Generate the default value for a key. For example, property "Name" becomes "DEFAULT-Name".

getClassProperty

public Object getClassProperty(Class cl,
                               String key)
Recursively go up the inheritance chain, finding the first class that has a value for this key.

Keep in mind that this gets a reference to the specified key. Thus, if you modify the retrieved value, you modify it for everyone. You may want to make a clone of it first.


setDefaultProperty

public void setDefaultProperty(String key,
                               Object newVal)
Put a default value in for this key. The default is the value that will be used if the class or any of its superclasses does not have a value for the specified property.

setClassProperty

public void setClassProperty(Class cl,
                             String key,
                             Object newVal)
Put a property in for this class, overriding an old value if there is one.

removeClassProperty

public Object removeClassProperty(Class cl,
                                  String key)
Remove the property for this class and key.

main

public static void main(String[] argv)
                 throws Exception

Copyright Information