org.progeeks.meta.util
Class MetaObjectUtils

java.lang.Object
  extended by org.progeeks.meta.util.MetaObjectUtils

public class MetaObjectUtils
extends java.lang.Object

Utilities useful for working with meta-objects.

Version:
$Revision: 1.35 $
Author:
Paul Wisneskey

Field Summary
static MetaClass ANNOTATION_CLASS
           
static java.lang.String ANNOTATION_KEY
           
static java.lang.String ANNOTATION_TYPE
           
static java.lang.String ANNOTATION_VALUE
           
static MetaClass CONTAINER_PROPERTY_INFO_CLASS
          Defines a meta-class for ContainerPropertyInfo so that it can subclass PropertyInfo and pick up its custom properties.
static java.lang.String CONTAINER_PROPERTY_INFO_NAME
           
static java.lang.String META_CLASS_ANNOTATIONS
           
static java.lang.String META_CLASS_IDENTITY
           
static java.lang.String META_CLASS_NAME
           
static java.lang.String META_CLASS_PROPERTIES
           
static java.lang.String META_CLASS_PROPERTY_DEFS
           
static java.lang.String META_CLASS_SUPERCLASSES
           
static java.lang.String META_CLASS_TEMPLATE_FACTORY
           
static java.lang.String META_CLASS_TEMPLATE_NAME
           
static MetaClass META_CLASS_TYPE
          Creates a MetaClass representing the properties of a MetaClass.
static java.lang.String PROPERTY_ANNOTATIONS
           
static java.lang.String PROPERTY_CLASS_TYPE
           
static MetaClass PROPERTY_INFO_CLASS
          Defines a meta-class for PropertyInfo so that we can add some custom properties.
static java.lang.String PROPERTY_INFO_NAME
           
static java.lang.String PROPERTY_META_CLASS_TYPE
           
 
Constructor Summary
MetaObjectUtils()
           
 
Method Summary
static boolean areEqualValues(MetaObject m1, MetaObject m2)
          Returns true if both meta-objects are the same class and have the same values for all of their properties.
static java.lang.Object bytesToObject(byte[] bytes, Cache cache)
          Converts a byte array into the un-serialized Serializable object it contains.
static MetaObject cloneMetaObject(MetaObject source)
          Creates a shallow clone of the supplied meta-object.
static void copyMetaObject(MetaObject source, MetaObject destination)
          Performs a shallow copy of one meta-object to another.
static void copyMetaObject(MetaObject source, MetaObject destination, boolean copyReadOnly)
          Performs a shallow copy of one meta-object to another.
static MetaClass createMetaClass(MetaObject metaClassInfo)
          Creates a MetaClass for the specified MetaObject representation of a MetaClass.
static MetaClass createMetaClass(MetaObject metaClassInfo, MetaClassRegistry registry)
          Creates a MetaClass for the specified MetaObject representation of a MetaClass.
static MetaObject createMetaObjectForMetaClass(MetaClass metaClass)
          Creates a MetaObject representation of the specified MetaClass.
static PropertyInfo createPropertyInfo(MetaObject propInfo)
          Creates a PropertyInfo object for the specified PropertyInfo MetaObject representation.
static PropertyInfo findPropertyInfo(java.lang.String property, java.util.List propertyInfos)
          Finds the PropertyInfo for the specified name in the specified list.
static byte[] objectToBytes(java.io.Serializable object)
          Converts a serializable object into a byte[] array.
static PropertyInfo removePropertyInfo(java.lang.String property, java.util.List propertyInfos)
          Finds and removes the PropertyInfo for the specified name in the specified list.
static void replacePropertyType(java.util.List propertyInfos, java.lang.String property, PropertyType type)
          Replaces the specified field's type with the specified type.
static void resetDefaultValues(MetaObject metaObject)
          Resets the state of the MetaObject to use any default values defined in the MetaClass definition.
static void setPropertyInfoAttributes(PropertyInfo propInfo, MetaObject mInfo)
          Sets the attributes of the specified PropertyInfo object to those contained in the MetaObject representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META_CLASS_TYPE

public static final MetaClass META_CLASS_TYPE
Creates a MetaClass representing the properties of a MetaClass. This MetaClass can be used by IO or UI routines to allow saving/loading/displaying of a meta-class. Utility methods are provided for creating MetaObject representations of a meta-class and creating MetaClass instances from MetaObject instances.


META_CLASS_NAME

public static final java.lang.String META_CLASS_NAME
See Also:
Constant Field Values

META_CLASS_IDENTITY

public static final java.lang.String META_CLASS_IDENTITY
See Also:
Constant Field Values

META_CLASS_PROPERTIES

public static final java.lang.String META_CLASS_PROPERTIES
See Also:
Constant Field Values

META_CLASS_SUPERCLASSES

public static final java.lang.String META_CLASS_SUPERCLASSES
See Also:
Constant Field Values

META_CLASS_ANNOTATIONS

public static final java.lang.String META_CLASS_ANNOTATIONS
See Also:
Constant Field Values

META_CLASS_TEMPLATE_FACTORY

public static final java.lang.String META_CLASS_TEMPLATE_FACTORY
See Also:
Constant Field Values

META_CLASS_TEMPLATE_NAME

public static final java.lang.String META_CLASS_TEMPLATE_NAME
See Also:
Constant Field Values

META_CLASS_PROPERTY_DEFS

public static final java.lang.String META_CLASS_PROPERTY_DEFS
See Also:
Constant Field Values

PROPERTY_INFO_CLASS

public static final MetaClass PROPERTY_INFO_CLASS
Defines a meta-class for PropertyInfo so that we can add some custom properties.


PROPERTY_INFO_NAME

public static final java.lang.String PROPERTY_INFO_NAME
See Also:
Constant Field Values

PROPERTY_ANNOTATIONS

public static final java.lang.String PROPERTY_ANNOTATIONS
See Also:
Constant Field Values

PROPERTY_CLASS_TYPE

public static final java.lang.String PROPERTY_CLASS_TYPE
See Also:
Constant Field Values

PROPERTY_META_CLASS_TYPE

public static final java.lang.String PROPERTY_META_CLASS_TYPE
See Also:
Constant Field Values

CONTAINER_PROPERTY_INFO_CLASS

public static final MetaClass CONTAINER_PROPERTY_INFO_CLASS
Defines a meta-class for ContainerPropertyInfo so that it can subclass PropertyInfo and pick up its custom properties.


CONTAINER_PROPERTY_INFO_NAME

public static final java.lang.String CONTAINER_PROPERTY_INFO_NAME
See Also:
Constant Field Values

ANNOTATION_CLASS

public static final MetaClass ANNOTATION_CLASS

ANNOTATION_TYPE

public static final java.lang.String ANNOTATION_TYPE
See Also:
Constant Field Values

ANNOTATION_KEY

public static final java.lang.String ANNOTATION_KEY
See Also:
Constant Field Values

ANNOTATION_VALUE

public static final java.lang.String ANNOTATION_VALUE
See Also:
Constant Field Values
Constructor Detail

MetaObjectUtils

public MetaObjectUtils()
Method Detail

areEqualValues

public static boolean areEqualValues(MetaObject m1,
                                     MetaObject m2)
Returns true if both meta-objects are the same class and have the same values for all of their properties. Normal meta-object .equals() does not always compare all property values.


copyMetaObject

public static void copyMetaObject(MetaObject source,
                                  MetaObject destination)
Performs a shallow copy of one meta-object to another. Does not affect any of the property change listeners in the destination object.

Parameters:
source - Meta-object to copy from.
destination - Meta-object to copy to.

copyMetaObject

public static void copyMetaObject(MetaObject source,
                                  MetaObject destination,
                                  boolean copyReadOnly)
Performs a shallow copy of one meta-object to another. Does not affect any of the property change listeners in the destination object.

Parameters:
source - Meta-object to copy from.
destination - Meta-object to copy to.
copyReadOnly - Set to true to force a field copy of read-only properties. This only works if the destination object supports setting read-only fields.

cloneMetaObject

public static MetaObject cloneMetaObject(MetaObject source)
Creates a shallow clone of the supplied meta-object. Note that the clone does not have any of the property change listeners from the source.

Parameters:
source - Meta-object to clone.
Returns:
Copy of the cloned meta-object.

findPropertyInfo

public static PropertyInfo findPropertyInfo(java.lang.String property,
                                            java.util.List propertyInfos)
Finds the PropertyInfo for the specified name in the specified list.


removePropertyInfo

public static PropertyInfo removePropertyInfo(java.lang.String property,
                                              java.util.List propertyInfos)
Finds and removes the PropertyInfo for the specified name in the specified list. The located property info is returned.


replacePropertyType

public static void replacePropertyType(java.util.List propertyInfos,
                                       java.lang.String property,
                                       PropertyType type)
Replaces the specified field's type with the specified type.


createMetaObjectForMetaClass

public static MetaObject createMetaObjectForMetaClass(MetaClass metaClass)
Creates a MetaObject representation of the specified MetaClass. This is useful for displaying a MetaClass in a UI and allowing editing. Changes are _not_ pushed back to the real MetaClass since they are immutable.


createMetaClass

public static MetaClass createMetaClass(MetaObject metaClassInfo)
Creates a MetaClass for the specified MetaObject representation of a MetaClass. This is useful for create meta-classes from information read from files.


createMetaClass

public static MetaClass createMetaClass(MetaObject metaClassInfo,
                                        MetaClassRegistry registry)
Creates a MetaClass for the specified MetaObject representation of a MetaClass. This is useful for create meta-classes from information read from files.


createPropertyInfo

public static PropertyInfo createPropertyInfo(MetaObject propInfo)
Creates a PropertyInfo object for the specified PropertyInfo MetaObject representation.


setPropertyInfoAttributes

public static void setPropertyInfoAttributes(PropertyInfo propInfo,
                                             MetaObject mInfo)
Sets the attributes of the specified PropertyInfo object to those contained in the MetaObject representation.


objectToBytes

public static byte[] objectToBytes(java.io.Serializable object)
Converts a serializable object into a byte[] array. This should be moved into a more general util class.


bytesToObject

public static java.lang.Object bytesToObject(byte[] bytes,
                                             Cache cache)
Converts a byte array into the un-serialized Serializable object it contains. This should be moved into a more general util class.


resetDefaultValues

public static void resetDefaultValues(MetaObject metaObject)
Resets the state of the MetaObject to use any default values defined in the MetaClass definition.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.