Qt Jambi Home

com.trolltech.qt
Class QtPropertyManager

java.lang.Object
  extended by com.trolltech.qt.QtPropertyManager

public class QtPropertyManager
extends java.lang.Object

The QtPropertyManager class implements the Qt Jambi Property system. To the outer world, a property appears to be similar to a data member; however, a property has features that distinguishes it from a normal data member:

When Qt Jambi resolves the properties of a class, it identifies them by their read, write, and reset property methods. The methods of a property are identified by annotations or by compliance with a method naming scheme. A property is set as designable with an annotation. We take a look at the annotations before we examine the scheme. For detailed usage of the annotations, see their javadoc.

.
Annotation Propety Method
QtPropertyReader The property read method.
QtPropertyWriter The property write method.
QtPropertyResetter The property reset method.
QtPropertyDesignable Decides whether the property is suitable for editing in a GUI builder.
QtPropertyOrder Gives a value that can be used for sorting properties.

The following table describe the property method naming scheme. The names are given for a property with name x and type T. Note that resetter methods can only be specified with the QtPropertyResetter annotation.

Method Name Property Method
T getX() or T x() - for boolean values also T isX() or T hasX() Property reader
setX(T) Property writer

The propery system is provided for convenience and provides the same functionality as the native Qt system, which has advantages over using ordinary data members and Java Reflection to access them by name. The code required to set, get, and reset properties are already implemented. You can set and get a property's value without knowing the method names, and the naming of property methods needs not follow a specific naming scheme. You can also query a property for whether it is designable, readable, or writeable.


Nested Class Summary
static class QtPropertyManager.Entry
          The Entry class is used to keep information about a property.
 
Constructor Summary
QtPropertyManager()
          This is a JambiDoclet generated javadoc comment for com.trolltech.qt.QtPropertyManager.
 
Method Summary
static java.util.HashMap<java.lang.String,QtPropertyManager.Entry> findProperties(java.lang.Class cl)
          Returns the properties of class cl.
static java.util.HashMap<java.lang.String,QtPropertyManager.Entry> findPropertiesRecursive(java.lang.Class cl)
          Returns a HashMap of properties declared by cl and its ancestors.
static java.lang.Object readProperty(java.lang.Object object, java.lang.String name)
          Returns the value of the proprty name of object.
static void resetProperty(java.lang.Object object, java.lang.String name)
          Resets the property name in object.
static void writeProperty(java.lang.Object object, java.lang.String name, java.lang.Object value)
          Sets the value of the property name in object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QtPropertyManager

public QtPropertyManager()
This is a JambiDoclet generated javadoc comment for com.trolltech.qt.QtPropertyManager.

Method Detail

findPropertiesRecursive

public static java.util.HashMap<java.lang.String,QtPropertyManager.Entry> findPropertiesRecursive(java.lang.Class cl)
Returns a HashMap of properties declared by cl and its ancestors. The map keys are the property names. If two properties have the same name, it is the most direct ancestor (including cl itself) that is stored.


findProperties

public static java.util.HashMap<java.lang.String,QtPropertyManager.Entry> findProperties(java.lang.Class cl)
Returns the properties of class cl. The properties are returned in a HashMap using the property names as keys. The Entry class keeps all information available for a property.


readProperty

public static java.lang.Object readProperty(java.lang.Object object,
                                            java.lang.String name)
Returns the value of the proprty name of object. It returns null if the property could not be read. If name is not a property of object, a QPropertyException is thrown.


writeProperty

public static void writeProperty(java.lang.Object object,
                                 java.lang.String name,
                                 java.lang.Object value)
Sets the value of the property name in object. It throws QPropertyException if the property is not defined for object or the property is not writeable.


resetProperty

public static void resetProperty(java.lang.Object object,
                                 java.lang.String name)
Resets the property name in object. It throws QPropertyException if the property name is undefined or the propety cannot be reset.


Qt Jambi Home