dsto.dfc.databeans
Class TypeInfo

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.SimpleDataObject
          extended by dsto.dfc.databeans.FancyDataObject
              extended by dsto.dfc.databeans.TypeInfo
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, Cloneable

public class TypeInfo
extends FancyDataObject

Defines metadata for a given data object type, acting in a similar role as a Java class. The key difference is that metadata can be attached dynamically to type info, allowing such things as icons, suggested editors, etc to be attached to types.

This object is used in two slightly different ways depending on whether it is metdata for "primitive" (non-IDataObject) or "complex" (IDataObject) instances.

For complex objects, the type field is a template that describes the known properties of this type. For each known property of an instance, the template has a property => TypeInfo mapping i.e. getValue (property) yeilds the TypeInfo for values of that property.

For primitive objects, the "type" field is not used, instead the class of the object is held in valueClass. If this field is java.lang.Object, it indicates any value can be present.

Author:
Matthew Phillips
See Also:
TypeRegistry

Field Summary
static String DEFAULT_VALUE
          The property name used to store the default value of a given type.
 String id
          The logical ID of this type.
 IDataObject type
          A data object that defines the "type" as a mapping of known properties to TypeInfo descriptions.
 Class valueClass
          Defines the class for instances of this type.
 
Fields inherited from class dsto.dfc.databeans.AbstractDataObject
listeners
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
TypeInfo()
          Create a new IDataObject-based type.
TypeInfo(Class valueClass)
          Create a new non-IDataObject type.
TypeInfo(int minValue, int maxValue)
          Shortcut create type info for integer values with given max/min values.
 
Method Summary
 void addPropertyInfo(Object propertyName, String propertyType)
          Add type info for the value of a given property.
 void addPropertyInfo(Object propertyName, TypeInfo propertyType)
          Add type info for the value of a given property.
protected  String createId()
           
 boolean equals(Object obj)
           
 boolean equals(TypeInfo info)
           
 TypeInfo getPropertyInfo(Object property)
          Get type info for values of a given property.
 int hashCode()
           
 boolean isDataObject()
          Test if instances of this type are IDataObject-based.
 
Methods inherited from class dsto.dfc.databeans.FancyDataObject
childPropertyChanged, getValue, isTransient, propertyIterator, setValue, shallowClone
 
Methods inherited from class dsto.dfc.databeans.SimpleDataObject
getFieldNames, getTypeInfo, setValue
 
Methods inherited from class dsto.dfc.databeans.AbstractDataObject
addFirstPropertyListener, addPropertyListener, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, getBeanValue, getBooleanValue, getBooleanValue, getCharValue, getCharValue, getDoubleValue, getDoubleValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getObjectValue, getPropertyListeners, getShortValue, getStringValue, registerValue, removePropertyListener, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, toString, unregisterValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_VALUE

public static final String DEFAULT_VALUE
The property name used to store the default value of a given type.

See Also:
Constant Field Values

type

public final IDataObject type
A data object that defines the "type" as a mapping of known properties to TypeInfo descriptions. This will be null for non-IDataObject types (see valueClass).


valueClass

public final Class valueClass
Defines the class for instances of this type. This is only used for non-IDataObject types that are not defined by type.


id

public final String id
The logical ID of this type. If two TypeInfo instances have the same ID, then they are the same logical type. For now every instance has its own unique ID, but in future we might want to allow different instances with subtle changes (eg suggested editor) that are stil the same type via their ID.

Constructor Detail

TypeInfo

public TypeInfo()
Create a new IDataObject-based type.


TypeInfo

public TypeInfo(Class valueClass)
Create a new non-IDataObject type.

Parameters:
valueClass - The class that instances of this type conform to.

TypeInfo

public TypeInfo(int minValue,
                int maxValue)
Shortcut create type info for integer values with given max/min values.

Parameters:
minValue - The min value: mapped to minValue custom property on the type info.
maxValue - The max value: mapped to maxValue custom property on the type info.
Method Detail

createId

protected String createId()

isDataObject

public boolean isDataObject()
Test if instances of this type are IDataObject-based.


addPropertyInfo

public void addPropertyInfo(Object propertyName,
                            TypeInfo propertyType)
Add type info for the value of a given property.

Parameters:
propertyName - The property name.
propertyType - The type info describing values of the property.
See Also:
addPropertyInfo(Object, String), getPropertyInfo(Object)

addPropertyInfo

public void addPropertyInfo(Object propertyName,
                            String propertyType)
Add type info for the value of a given property.

Parameters:
propertyName - The property name.
propertyType - The logical name of the type info. TypeRegistry.getTypeInfo(String)is used to resolve this to the registered TypeInfo.
Throws:
IllegalArgumentException - if propertyType is not a registered type info.
See Also:
addPropertyInfo(Object, TypeInfo), getPropertyInfo(Object)

getPropertyInfo

public TypeInfo getPropertyInfo(Object property)
Get type info for values of a given property.

Parameters:
property - The property name,
Returns:
The type info describing the property values, or null if none registered.
Throws:
IllegalArgumentException - if this is not type info for a IDataBean-based type.
See Also:
addPropertyInfo(Object, TypeInfo)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

equals

public boolean equals(TypeInfo info)

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2008 Commonwealth of Australia