IClassInfo Interface

IClassInfo Interface

This Package | All Packages

public interface IClassInfo

Provides meta-information for a component that cannot be determined from the component itself. Examples of such meta-information include a component's set of properties, its icon, and so on.

A component never implements the IClassInfo interface directly. Rather, the component implements a public static inner class named "ClassInfo," which in turn implements the IClassInfo interface. This implementation method allows the meta-information to be separated from the class itself in situations where the it is not required (such as when the component is deployed). The following example shows a base class called Window and its associated ClassInfo implementation:


  public class Window
  {
    // Members of class Window

    public static class ClassInfo implements IClassInfo
    {
      // Implementations of all methods of the IClassInfo interface
    }
  }
 

For a component class that is a descendant of another component class, the ClassInfo of the descendant component class typically extends the ClassInfo of the base component class. For example:


  public class Button extends Window
  {
    // Members of class Button

    public static class ClassInfo extends Window.ClassInfo
    {
      // Overrides of methods of the IClassInfo interface
    }
  }

Even though a descendant component's ClassInfo typically inherits from the base component's ClassInfo, it isn't required to do so. Indeed, a descendant component's ClassInfo can be implemented from scratch or can inherit from a ClassInfo higher up in the component hierarchy. This is useful in situations where a component wants to omit properties that were introduced by a base class.

Compilation of a component class with an inner ClassInfo class produces two class files that follow the naming pattern XXX.class and XXX$ClassInfo.class, where XXX is the name of the component class. The Windows Foundation Classes for Java component manager uses this pattern to identify classes that support meta-information.

Methods
Name Description
getAttributes(IAttributes attributes) Specifies the attributes of the associated class by calling the add() method of the given IAttributes callback interface.
getCustomizer(Object component) Retrieves a customizer for the given component.
getDefaultEventName() Retrieves the name of the "default" event for the associated component class.
getDefaultPropertyName() Retrieves the name of the "default" property for the associated component class.
getEvents(IEvents events) Specifies the events of the associated class by calling the add() method of the given IEvents callback interface.
getExtenders(IExtenders extenders) Specifies the extenders of the associated class by calling the add() method of the given IExtenders callback interface.
getProperties(IProperties props) Specifies the properties of the associated class by calling the appropriate add() methods of the given IProperties callback interface.
getToolboxBitmap() Retrieves an image that contains a 16x16 pixel icon used to represent the component in toolboxes, list views, and so forth.

Methods

IClassInfo.getAttributes

Syntax
public void getAttributes( IAttributes attributes );
Parameters
Attributes
An IAttributes interface that functions as a callback for the attribute list.
Description

Specifies the attributes of the associated class by calling the add() method of the given IAttributes callback interface.

See Also
wfc.core.IAttributes

IClassInfo.getCustomizer

Syntax
public ICustomizer getCustomizer( Object component );
Description

Retrieves a customizer for the given component. The component parameter is guaranteed to be an instance of the ClassInfo's associated component class (or a subclass thereof). The return value may be null if the component doesn't support a customizer. For further details on component customizers, see the comments for the ICustomizer interface.

IClassInfo.getDefaultEventName

Syntax
public String getDefaultEventName();
Description

Retrieves the name of the "default" event for the associated component class. The exact implications of being a default event are defined by the tool that is editing the component, but it could, for example, mean that the handler method of the event is shown in the code window when a user double-clicks the component in the design environment.

IClassInfo.getDefaultPropertyName

Syntax
public String getDefaultPropertyName();
Description

Retrieves the name of the "default" property for the associated component class. The exact implications of being a default property are defined by the tool that is editing the component, but it could, for example, mean that the edit() method of the property's associated value editor is invoked when a user double-clicks the component in the design environment.

IClassInfo.getEvents

Syntax
public void getEvents( IEvents events );
Parameters
Events
An IEvents interface that functions as a callback for the event list.
Description

Specifies the events of the associated class by calling the add() method of the given IEvents callback interface.

See Also
wfc.core.IEvents

IClassInfo.getExtenders

Syntax
public void getExtenders( IExtenders extenders );
Parameters
Extenders
An IExtenders interface that functions as a callback for the extender list.
Description

Specifies the extenders of the associated class by calling the add() method of the given IExtenders callback interface.

See Also
wfc.core.IExtenders

IClassInfo.getProperties

Syntax
public void getProperties( IProperties props );
Parameters
Props
An IProperties interface that functions as a callback for the property list.
Description

Specifies the properties of the associated class by calling the appropriate add() methods of the given IProperties callback interface. Note that events are treated as properties whose types are descendants of the system-provided Closure class. In other words, the getProperties() method reports both the properties and the events of its associated component class. For a component class that is a descendant of another component class, the getProperties() method typically calls super.getProperties() before adding the properties that are particular to the descendant class. An example of an implementation of the getProperties() method follows.


  public class Edit extends Window
  {
    // Members of class Edit

    public static class ClassInfo extends Window.ClassInfo
    {
      public getProperties(IProperties properties)
      {
        super.getProperties(properties);
        properties.add("ReadOnly", boolean.class, new Boolean(false));
        properties.add("MaxLength", int.class, new Integer(0));
        properties.add("OnChange", EventHandler.class);
      }
    }
  }

Each call to properties.add() defines a new property or hides an already defined property of the same name. A call to add() must always specify the property's name and type and can optionally specify a default value and a value editor. For a property named XXX of type YYY, the associated component class is required to implement two methods of the following form:


  public YYY getXXX();
  public void setXXX(YYY value);
 

If the property type is boolean, the getXXX() method can optionally be named isXXX(). The component class can optionally implement to additional methods of the following form:


  public boolean hasDefaultXXX();
  public void resetXXX();
 

These methods control a property's default value. The hasDefaultXXX() method returns true if the current value of the XXX property is equal to the default value of the property. The resetXXX() method resets the XXX property to its default value. If the call to properties.add() that defines a particular property includes the default value of the property, the hasDefaultXXX() and resetXXX() methods are ignored. Otherwise, these methods are used to determine if a property is different from its default and to reset the property to its default.

If the call to properties.add() that defines a particular property includes a reference to a value editor, that value editor is used to edit the property. Otherwise, a system-provided value editor is used, as described in the comments for the IValueEditor interface.

For more information on implementing the getProperties() method, see the descriptions of the methods of the IProperties interface.

See Also
wfc.core.IProperties

IClassInfo.getToolboxBitmap

Syntax
public Bitmap getToolboxBitmap();
Return Value

Returns a Bitmap object that contains an iconic representation of the component. May return NULL if no such icon exists.

Description

Retrieves an image that contains a 16x16 pixel icon used to represent the component in toolboxes, list views, and so forth.