Class Model
- java.lang.Object
-
- com.sun.jdo.api.persistence.model.Model
-
- Direct Known Subclasses:
RuntimeModel
public abstract class Model extends Object
- Version:
- %I%
- Author:
- raccah
-
-
Field Summary
Fields Modifier and Type Field Description static ModelENHANCERDefault instance of the model used by the enhancer.static StringmessageBaseI18N message basestatic String[]NO_ARGSStandard set of empty arguments (for comparison with hashCode method and no-arg constructor).static ModelRUNTIMEDefault instance of the model for use at runtime.
-
Constructor Summary
Constructors Constructor Description Model()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaddFieldElement(PersistenceClassElement element, String fieldName)Adds a PersistenceFieldElement for the specified field to the supplied PersistenceClassElement, creating a RelationshipElement if necessary.voidconvertDefaultFields(String className)Adds the default allowable persistent fields to the persistent class with the specified name.voidconvertFields(String className, List fields)Adds the allowable persistent fields from the supplied list to the persistent class with the specified name.voidconvertToPersistenceCapable(String className)Converts the class with the supplied name to persistence-capable, then convert its default fields and save it to the xml file.voidconvertToPersistenceCapable(String className, boolean flag)Converts the class with the supplied name to or from persistence capable depending on the flag.protected abstract BufferedOutputStreamcreateFile(String className, String baseFileName, String extension)Creates a file with the given base file name and extension parallel to the supplied class (if it does not yet exist).protected abstract voiddeleteFile(String className, String fileName)Deletes the file with the given file name which is parallel to the supplied class.protected abstract StringfindPenultimateSuperclass(String className)Returns the name of the second to top (top excluding java.lang.Object) superclass for the given class name.ListgetAllFields(String className)Returns a list of names of all the field elements in the class with the specified name.ObjectgetClass(String className)Returns the class element with the specified className.abstract ObjectgetClass(String className, ClassLoader classLoader)Returns the class element with the specified className.MapgetClassLoaderCache()Returns an unmodifiable copy of the ClassLoader cache.abstract ObjectgetConstructor(String className, String[] argTypeNames)Returns the constructor element for the specified argument types in the class with the specified name.abstract StringgetDeclaringClass(Object memberElement)Returns the string representation of declaring class of the specified member element.StringgetDefaultCollectionClass(String className)Returns the default collection class for the specified class.static String[]getEqualsArgs()Standard set of arguments for comparison with equals method.abstract ObjectgetField(String className, String fieldName)Returns the field element for the specified fieldName in the class with the specified className.abstract ListgetFields(String className)Returns a list of names of all the declared field elements in the class with the specified name.StringgetFieldType(String className, String fieldName)Returns the field type for the specified fieldName in the class with the specified className.protected StringgetFileName(String className)Computes the base file name (without extension) for the supplied class name by converting the package name to a path name.protected StringgetFileNameWithExtension(String className)Computes the mapping file name (with extension) for the supplied class name by converting the package name to a path name.ObjectgetInheritedField(String className, String fieldName)Returns the inherited field element for the specified fieldName in the class with the specified className.ObjectgetInheritedMethod(String className, String methodName, String[] argTypeNames)Returns the inherited method element for the specified method name and argument types in the class with the specified name.protected abstract BufferedInputStreamgetInputStreamForResource(String className, ClassLoader classLoader, String resourceName)Returns the input stream with the supplied resource name found with the supplied class name.MapgetMappingCache()Returns an unmodifiable copy of the MappingClassElement cache.MappingClassElementgetMappingClass(String className)Returns the MappingClassElement created for the specified class name.MappingClassElementgetMappingClass(String className, ClassLoader classLoader)Returns the MappingClassElement created for the specified class name.protected static ResourceBundlegetMessages()abstract ObjectgetMethod(String className, String methodName, String[] argTypeNames)Returns the method element for the specified method name and argument types in the class with the specified name.abstract intgetModifiers(Object memberElement)Returns the modifier mask for the specified member element.protected intgetModifiers(String className, String fieldName)Returns the modifier mask for the specified fieldName in the class with the specified className.intgetModifiersForClass(String className)Returns the modifier mask for the specified className.protected PersistenceClassElementgetPersistenceClass(MappingClassElement mappingClass)Returns a PersistenceClassElement created from the mapping class.PersistenceClassElementgetPersistenceClass(String className)Returns a PersistenceClassElement created from the specified class name.PersistenceClassElementgetPersistenceClass(String className, ClassLoader classLoader)Returns a PersistenceClassElement created from the specified class name.PersistenceFieldElementgetPersistenceField(String className, String fieldName)Returns the PersistenceFieldElement with the supplied fieldName found in the supplied className.protected PersistenceFieldElementgetPersistenceFieldInternal(String className, String fieldName)Returns the PersistenceFieldElement with the supplied fieldName found in the supplied className.static String[]getReadObjectArgs()Standard set of arguments for comparison with readObject method.StringgetRelatedClass(RelationshipElement element)Gets the name of the related class for a relationship element.protected StringgetResourceName(String className)Computes the base resource name (without extension) for the supplied class name by converting the package name to a resource name.protected StringgetResourceNameWithExtension(String className)Computes the mapping file resource name (with extension) for the supplied class name by converting the package name to a resource name.protected abstract StringgetSuperclass(String className)Returns the name of the superclass for the given class name.ArrayListgetSupportedCollectionClasses(String className)Computes the list of names of the possible collection classes for the specified class.abstract StringgetType(Object element)Returns the string representation of type of the specified element.static String[]getWriteObjectArgs()Standard set of arguments for comparison with writeObject method.booleanhasClass(String className)Determines if a class with the specified className exists.booleanhasClass(String className, ClassLoader classLoader)Determines if a class with the specified className exists.abstract booleanhasConstructor(String className)Determines if the class with the specified name declares a constructor.booleanhasField(String className, String fieldName)Determines if a field with the specified fieldName exists in the class with the specified className.booleanhasPersistentSuperclass(String className)Determines if the specified className has a persistent superclass.abstract booleanimplementsInterface(Object classElement, String interfaceName)Determines if the specified class implements the specified interface.abstract booleanisArray(String className, String fieldName)Determines if a field with the specified fieldName in the class with the specified className is an array.protected booleanisByteArray(String className)Determines if the specified className represents a byte array.booleanisByteArray(String className, String fieldName)Determines if a field with the specified fieldName in the class with the specified className is a byte array.booleanisCollection(String className)Determines if the class name represents a collection.booleanisDefaultFetchGroup(String className, String fieldName)Determines if the specified className and fieldName pair represent a field which is part of the default fetch group.abstract booleanisInterface(String className)Determines if the specified className represents an interface type.booleanisKey(String className, String fieldName)Determines if the specified className and fieldName pair represent a key field.booleanisMutableSecondClassObject(String className)Determines if the specified className represents a mutable second class object.booleanisPersistenceCapableAllowed(String className)Determines if the specified className represents a legal candidate for becoming a persistence capable class.booleanisPersistent(String className)Determines if the specified className represents a persistence capable class.booleanisPersistent(String className, ClassLoader classLoader)Determines if the specified className represents a persistence capable class.booleanisPersistent(String className, String fieldName)Determines if the specified className and fieldName pair represent a persistent field.booleanisPersistentAllowed(String className, ClassLoader classLoader, String fieldName)Returnstrueif the specified field can be made persistent,falseotherwise.booleanisPersistentAllowed(String className, String fieldName)Returnstrueif the specified field can be made persistent,falseotherwise.protected booleanisPersistentTypeAllowed(String className, ClassLoader classLoader)Returnstrueif the a field of the specified class or type can be made persistent,falseotherwise.protected booleanisPrimitive(String className)Determines if the specified className represents a primitive type.booleanisPrimitive(String className, String fieldName)Determines if a field with the specified fieldName in the class with the specified className has a primitive type.booleanisSecondClassObject(String className)Determines if the specified className represents a second class object.abstract booleanisSerializable(Object fieldElement)Determines if the specified field element has a serializable type.booleanisValidKeyType(String className, String fieldName)Determines if the specified className and fieldName pair represent a field which has a type which is valid for key fields.voidlockFile(String className)protected static ModelNewModel(String testName, String modelName)Create a new Model of the requested type.booleanparse(String className)Parses the combination of java (or class) information and mapping/jdo information by running through a subset of the full validation check and aborting (and returningfalseat the first error or warning.voidremoveFieldElement(PersistenceFieldElement element)Removes the specified PersistenceFieldElement from its declaring class.voidremoveFromCache(String className)Removes the class with the supplied name from the cache of classes known to be non PC.voidremoveResourcesFromCaches(ClassLoader classLoader)Removes the classes cached with the specified class loader from all caches.protected voidremoveResourcesFromCaches(Collection classNames)Removes the specified classes from all caches.booleanshouldBePersistent(String className, String fieldName)Returnstrueif the specified field should be made persistent (i.e.voidstoreMappingClass(MappingClassElement mappingClass)Stores the supplied MappingClassElement to an xml file, creating the file if necessary.voidstoreMappingClass(MappingClassElement mappingClass, OutputStream stream)Stores the supplied MappingClassElement to an xml file in the specified output stream.voidstoreMappingClass(String className)Stores the MappingClassElement for the specified class name to an xml file, creating the file if necessary.voidunlockFile(OutputStream stream, String className)voidunlockFile(String className)voidupdateKeyForClass(MappingClassElement mappingClass, String oldName)Updates the key in the cache for the supplied MappingClassElement.Collectionvalidate(String className, ClassLoader classLoader, ResourceBundle bundle)Validates the combination of java (or class) information and mapping/jdo information by running through the full validation check and returning a collection of ModelValidationExceptions containing any errors or warnings encountered.Collectionvalidate(String className, ResourceBundle bundle)Validates the combination of java (or class) information and mapping/jdo information by running through the full validation check and returning a collection of ModelValidationExceptions containing any errors or warnings encountered.
-
-
-
Field Detail
-
RUNTIME
public static final Model RUNTIME
Default instance of the model for use at runtime.
-
ENHANCER
public static final Model ENHANCER
Default instance of the model used by the enhancer.
-
NO_ARGS
public static final String[] NO_ARGS
Standard set of empty arguments (for comparison with hashCode method and no-arg constructor).
-
messageBase
public static final String messageBase
I18N message base- See Also:
- Constant Field Values
-
-
Method Detail
-
NewModel
protected static Model NewModel(String testName, String modelName)
Create a new Model of the requested type. If the class definition exists in the class path of the environment, then this method will create a new instance of the Model.- Parameters:
modelName- the fully qualified name of the class to be instantiated.testName- the fully qualified name of the class to be tested as a precondition to loading.- Returns:
- a new instance of the requested class (which implements Model).
-
getMessages
protected static final ResourceBundle getMessages()
- Returns:
- I18N message handler for this element
-
getInputStreamForResource
protected abstract BufferedInputStream getInputStreamForResource(String className, ClassLoader classLoader, String resourceName)
Returns the input stream with the supplied resource name found with the supplied class name.- Parameters:
className- the fully qualified name of the class which will be used as a base to find the resourceclassLoader- the class loader used to find mapping informationresourceName- the name of the resource to be found- Returns:
- the input stream for the specified resource,
nullif an error occurs or none exists
-
isInterface
public abstract boolean isInterface(String className)
Determines if the specified className represents an interface type.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class name represents an interface;falseotherwise.
-
hasPersistentSuperclass
public boolean hasPersistentSuperclass(String className)
Determines if the specified className has a persistent superclass.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class name represents a class which has a persistent superclass (anywhere in the inheritance chain);falseotherwise.
-
findPenultimateSuperclass
protected abstract String findPenultimateSuperclass(String className)
Returns the name of the second to top (top excluding java.lang.Object) superclass for the given class name.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the top non-Object superclass for className,
classNameif an error occurs or none exists
-
getSuperclass
protected abstract String getSuperclass(String className)
Returns the name of the superclass for the given class name.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- thesuperclass for className,
nullif an error occurs or none exists
-
getPersistenceClass
public PersistenceClassElement getPersistenceClass(String className)
Returns a PersistenceClassElement created from the specified class name. Since our implementation of the mapping model class includes the persistence class, this method finds the persistence class by extracting it from the mapping class for the supplied name.- Parameters:
className- the fully qualified name of the persistence capable class to be returned- Returns:
- the PersistenceClassElement for className,
nullif an error occurs or none exists - See Also:
getMappingClass(java.lang.String)
-
getPersistenceClass
public PersistenceClassElement getPersistenceClass(String className, ClassLoader classLoader)
Returns a PersistenceClassElement created from the specified class name. Since our implementation of the mapping model class includes the persistence class, this method finds the persistence class by extracting it from the mapping class for the supplied name.- Parameters:
className- the fully qualified name of the persistence capable class to be returnedclassLoader- the class loader used to find mapping information- Returns:
- the PersistenceClassElement for className,
nullif an error occurs or none exists - See Also:
getMappingClass(java.lang.String)
-
getPersistenceClass
protected PersistenceClassElement getPersistenceClass(MappingClassElement mappingClass)
Returns a PersistenceClassElement created from the mapping class.- Parameters:
mappingClass- the mapping class element to which the persistence class is associated- Returns:
- the PersistenceClassElement for mappingClass,
nullif an error occurs or none exists - See Also:
getMappingClass(java.lang.String)
-
getMappingClass
public MappingClassElement getMappingClass(String className)
Returns the MappingClassElement created for the specified class name. This method looks up the class in the internal cache. If not present it loads the corresponding xml file containing the mapping information.- Parameters:
className- the fully qualified name of the mapping class- Returns:
- the MappingClassElement for class,
nullif an error occurs or none exists
-
getMappingClass
public MappingClassElement getMappingClass(String className, ClassLoader classLoader)
Returns the MappingClassElement created for the specified class name. This method looks up the class in the internal cache. If not present it loads the corresponding xml file containing the mapping information.- Parameters:
className- the fully qualified name of the mapping classclassLoader- the class loader used to find mapping information- Returns:
- the MappingClassElement for className,
nullif an error occurs or none exists - See Also:
MappingClassElementImpl.forName(java.lang.String, com.sun.jdo.api.persistence.model.Model)
-
getMappingCache
public Map getMappingCache()
Returns an unmodifiable copy of the MappingClassElement cache.- Returns:
- unmodifiable MappingClassElement cache
-
getClassLoaderCache
public Map getClassLoaderCache()
Returns an unmodifiable copy of the ClassLoader cache. This implementation returns null, but subclasses (such as RuntimeModel) can override this method if they support a class loader cache.- Returns:
- unmodifiable ClassLoader cache
-
removeResourcesFromCaches
public void removeResourcesFromCaches(ClassLoader classLoader)
Removes the classes cached with the specified class loader from all caches. This implementation does nothing, but subclasses (such as RuntimeModel) can override this method if they support a class loader cache.- Parameters:
classLoader- used to determine the classes to be removed
-
removeResourcesFromCaches
protected void removeResourcesFromCaches(Collection classNames)
Removes the specified classes from all caches. The specified collection includes the fully qualified class names of the classes to be removed. The method removes each class from the cache of MappingClassElements and the set of classes known to be non PC. Furthermore it removes the SchemaElement associated with this class from the SchemaElement cache. The next call getMappingClass will determine the status of the classes.- Parameters:
classNames- a collection of fully qualified class names
-
removeFromCache
public void removeFromCache(String className)
Removes the class with the supplied name from the cache of classes known to be non PC. The next call getMappingClass will determine the status of the class.- Parameters:
className- the fully qualified name of the class
-
storeMappingClass
public void storeMappingClass(MappingClassElement mappingClass) throws IOException
Stores the supplied MappingClassElement to an xml file, creating the file if necessary. The caller is responsible for updating the cache by calling updateKeyForClass, if necessary.- Parameters:
mappingClass- the mapping class to be saved- Throws:
IOException- if there is some error saving the class- See Also:
createFile(java.lang.String, java.lang.String, java.lang.String)
-
storeMappingClass
public void storeMappingClass(MappingClassElement mappingClass, OutputStream stream) throws IOException
Stores the supplied MappingClassElement to an xml file in the specified output stream. The caller is responsible for updating the cache by calling updateKeyForClass, if necessary.- Parameters:
mappingClass- the mapping class to be savedstream- the output stream- Throws:
IOException- if there is some error saving the class- See Also:
createFile(java.lang.String, java.lang.String, java.lang.String)
-
unlockFile
public void unlockFile(OutputStream stream, String className) throws IOException
- Throws:
IOException
-
lockFile
public void lockFile(String className) throws IOException
- Throws:
IOException
-
unlockFile
public void unlockFile(String className)
-
storeMappingClass
public void storeMappingClass(String className) throws IOException
Stores the MappingClassElement for the specified class name to an xml file, creating the file if necessary. The MappingClassElement must be present in the HashMap of classes known by the Model in order to stored.- Parameters:
className- the fully qualified name of the mapping class- Throws:
IOException- if there is some error saving the class- See Also:
storeMappingClass(com.sun.jdo.api.persistence.model.mapping.MappingClassElement)
-
updateKeyForClass
public void updateKeyForClass(MappingClassElement mappingClass, String oldName)
Updates the key in the cache for the supplied MappingClassElement.- Parameters:
mappingClass- the mapping class to be put in the cache (the new name is extracted from this element). The corresponding handling of the files is automatically handled by the data object. (usenullto remove the old key but not replace it)oldName- the fully qualified name of the old key for the mapping class (usenullto add the new key but not replace it)
-
isPersistent
public boolean isPersistent(String className)
Determines if the specified className represents a persistence capable class. A class is persistence capable only if it is directly marked as such -- not by inheritance.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class name represents a persistence capable class;falseotherwise.
-
isPersistent
public boolean isPersistent(String className, ClassLoader classLoader)
Determines if the specified className represents a persistence capable class. A class is persistence capable only if it is directly marked as such -- not by inheritance.- Parameters:
className- the fully qualified name of the class to be checkedclassLoader- the class loader used to find mapping information- Returns:
trueif this class name represents a persistence capable class;falseotherwise.
-
isPersistenceCapableAllowed
public boolean isPersistenceCapableAllowed(String className)
Determines if the specified className represents a legal candidate for becoming a persistence capable class. A class may not become persistence capable if it is declared as static or abstract, an interface, a subclass of another persistence capable class (either direct or indirect), an exception subclass, or a subclass of ejb, swing, awt, or applet classes.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class name represents a legal candidate for becoming a persistence capable class;falseotherwise.- See Also:
getModifiersForClass(java.lang.String),isInterface(java.lang.String),findPenultimateSuperclass(java.lang.String)
-
getResourceNameWithExtension
protected String getResourceNameWithExtension(String className)
Computes the mapping file resource name (with extension) for the supplied class name by converting the package name to a resource name.- Parameters:
className- the fully qualified name of the class- Returns:
- the mapping file resource name (with extension) for the supplied class name
- See Also:
MappingClassElement.MAPPING_EXTENSION
-
getResourceName
protected String getResourceName(String className)
Computes the base resource name (without extension) for the supplied class name by converting the package name to a resource name.- Parameters:
className- the fully qualified name of the class- Returns:
- the base resource name (without extension) for the supplied class name
-
getFileNameWithExtension
protected String getFileNameWithExtension(String className)
Computes the mapping file name (with extension) for the supplied class name by converting the package name to a path name.- Parameters:
className- the fully qualified name of the class- Returns:
- the mapping file name (with extension) for the supplied class name
- See Also:
getFileName(java.lang.String),MappingClassElement.MAPPING_EXTENSION
-
getFileName
protected String getFileName(String className)
Computes the base file name (without extension) for the supplied class name by converting the package name to a path name.- Parameters:
className- the fully qualified name of the class- Returns:
- the base file name (without extension) for the supplied class name
-
convertToPersistenceCapable
public void convertToPersistenceCapable(String className, boolean flag) throws IOException
Converts the class with the supplied name to or from persistence capable depending on the flag.- Parameters:
className- the fully qualified name of the classflag- iftrue, convert this class to be persistence capable, iffalse, convert this class to be non-persistence capable- Throws:
IOException- if there is some error converting the class
-
convertToPersistenceCapable
public void convertToPersistenceCapable(String className) throws IOException
Converts the class with the supplied name to persistence-capable, then convert its default fields and save it to the xml file.- Parameters:
className- the fully qualified name of the class- Throws:
IOException- if there is some error storing the class
-
convertDefaultFields
public void convertDefaultFields(String className)
Adds the default allowable persistent fields to the persistent class with the specified name. This is the second phase of converting a class to be persistence-capable.- Parameters:
className- the fully qualified name of the class- See Also:
createSkeletonMappingClass(java.lang.String),convertFields(java.lang.String, java.util.List)
-
convertFields
public void convertFields(String className, List fields)
Adds the allowable persistent fields from the supplied list to the persistent class with the specified name.- Parameters:
className- the fully qualified name of the classfields- a list of (short) field names- See Also:
convertDefaultFields(java.lang.String)
-
addFieldElement
public boolean addFieldElement(PersistenceClassElement element, String fieldName)
Adds a PersistenceFieldElement for the specified field to the supplied PersistenceClassElement, creating a RelationshipElement if necessary.- Parameters:
element- the persistence class element to be usedfieldName- the name of the field to be added
-
removeFieldElement
public void removeFieldElement(PersistenceFieldElement element) throws ModelException
Removes the specified PersistenceFieldElement from its declaring class. This method is added so that there is a common way to do this which checks if the argument is a relationship element with an inverse (in which case the inverse should first be cleared). This should really be handled by the jdo model directly, but the removeField method doesn't have access to the Model which is necessary for setting (or clearing) inverse relationships.- Parameters:
element- the persistence field element to be removed- Throws:
ModelException- if there is some error removing the field
-
getRelatedClass
public String getRelatedClass(RelationshipElement element)
Gets the name of the related class for a relationship element. This method is added so that there is a common way to do this. It checks if the argument is a collection relationship element (in which case the element class should be returned) or not (in which case the type should be returned). This should really be handled by the jdo model directly, but it doesn't have access to the Model which is necessary for finding the field type and whether it is a collection or not.- Parameters:
element- the relationship element to be examined- Returns:
- the name of the related class
-
getSupportedCollectionClasses
public ArrayList getSupportedCollectionClasses(String className)
Computes the list of names of the possible collection classes for the specified class.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- an array of supported collection classes for the specified class name.
- See Also:
getFieldType(java.lang.String, java.lang.String),getDefaultCollectionClass(java.lang.String)
-
getDefaultCollectionClass
public String getDefaultCollectionClass(String className)
Returns the default collection class for the specified class. If the specified class is an unspecified Collection type, the return will be HashSet.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the name of the default supported collection class for the specified class name.
- See Also:
getFieldType(java.lang.String, java.lang.String),getSupportedCollectionClasses(java.lang.String)
-
createFile
protected abstract BufferedOutputStream createFile(String className, String baseFileName, String extension) throws IOException
Creates a file with the given base file name and extension parallel to the supplied class (if it does not yet exist).- Parameters:
className- the fully qualified name of the classbaseFileName- the name of the base fileextension- the file extension- Returns:
- the output stream for the specified resource,
nullif an error occurs or none exists - Throws:
IOException- if there is some error creating the file
-
deleteFile
protected abstract void deleteFile(String className, String fileName) throws IOException
Deletes the file with the given file name which is parallel to the supplied class.- Parameters:
className- the fully qualified name of the classfileName- the name of the file- Throws:
IOException- if there is some error deleting the file
-
getFields
public abstract List getFields(String className)
Returns a list of names of all the declared field elements in the class with the specified name.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the names of the field elements for the specified class
-
getAllFields
public List getAllFields(String className)
Returns a list of names of all the field elements in the class with the specified name. This list includes the inherited fields.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the names of the field elements for the specified class
-
getClass
public Object getClass(String className)
Returns the class element with the specified className.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the class element for the specified className
-
getClass
public abstract Object getClass(String className, ClassLoader classLoader)
Returns the class element with the specified className.- Parameters:
className- the fully qualified name of the class to be checkedclassLoader- the class loader used to find mapping information- Returns:
- the class element for the specified className
-
hasClass
public boolean hasClass(String className)
Determines if a class with the specified className exists.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class name represents a valid class;falseotherwise.
-
hasClass
public boolean hasClass(String className, ClassLoader classLoader)
Determines if a class with the specified className exists.- Parameters:
className- the fully qualified name of the class to be checkedclassLoader- the class loader used to find mapping information- Returns:
trueif this class name represents a valid class;falseotherwise.
-
implementsInterface
public abstract boolean implementsInterface(Object classElement, String interfaceName)
Determines if the specified class implements the specified interface. Note, class element is a model specific class representation as returned by a getClass call executed on the same model instance.- Parameters:
classElement- the class element to be checkedinterfaceName- the fully qualified name of the interface to be checked- Returns:
trueif the class implements the interface;falseotherwise.- See Also:
getClass(java.lang.String)
-
hasConstructor
public abstract boolean hasConstructor(String className)
Determines if the class with the specified name declares a constructor.- Parameters:
className- the name of the class to be checked- Returns:
trueif the class declares a constructor;falseotherwise.- See Also:
getClass(java.lang.String)
-
getConstructor
public abstract Object getConstructor(String className, String[] argTypeNames)
Returns the constructor element for the specified argument types in the class with the specified name. Types are specified as type names for primitive type such as int, float or as fully qualified class names.- Parameters:
className- the name of the class which contains the constructor to be checkedargTypeNames- the fully qualified names of the argument types- Returns:
- the constructor element
- See Also:
getClass(java.lang.String)
-
getMethod
public abstract Object getMethod(String className, String methodName, String[] argTypeNames)
Returns the method element for the specified method name and argument types in the class with the specified name. Types are specified as type names for primitive type such as int, float or as fully qualified class names.- Parameters:
className- the name of the class which contains the method to be checkedmethodName- the name of the method to be checkedargTypeNames- the fully qualified names of the argument types- Returns:
- the method element
- See Also:
getClass(java.lang.String)
-
getInheritedMethod
public Object getInheritedMethod(String className, String methodName, String[] argTypeNames)
Returns the inherited method element for the specified method name and argument types in the class with the specified name. Types are specified as type names for primitive type such as int, float or as fully qualified class names. Note that the class with the specified className is not checked for this method, only superclasses are checked.- Parameters:
className- the name of the class which contains the method to be checkedmethodName- the name of the method to be checkedargTypeNames- the fully qualified names of the argument types- Returns:
- the method element
- See Also:
getClass(java.lang.String)
-
getType
public abstract String getType(Object element)
Returns the string representation of type of the specified element. If element denotes a field, it returns the type of the field. If element denotes a method, it returns the return type of the method. Note, element is either a field element as returned by getField, or a method element as returned by getMethod executed on the same model instance.- Parameters:
element- the element to be checked- Returns:
- the string representation of the type of the element
- See Also:
getField(java.lang.String, java.lang.String),getMethod(java.lang.String, java.lang.String, java.lang.String[])
-
getField
public abstract Object getField(String className, String fieldName)
Returns the field element for the specified fieldName in the class with the specified className.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the field element for the specified fieldName
-
getInheritedField
public Object getInheritedField(String className, String fieldName)
Returns the inherited field element for the specified fieldName in the class with the specified className. Note that the class with the specified className is not checked for this field, only superclasses are checked.- Parameters:
className- the fully qualified name of the class which contains a superclass with the field to be checkedfieldName- the name of the field to be checked- Returns:
- the field element for the specified fieldName
-
hasField
public boolean hasField(String className, String fieldName)
Determines if a field with the specified fieldName exists in the class with the specified className.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a valid field;falseotherwise.
-
getFieldType
public String getFieldType(String className, String fieldName)
Returns the field type for the specified fieldName in the class with the specified className.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the field type for the specified fieldName
-
isSerializable
public abstract boolean isSerializable(Object fieldElement)
Determines if the specified field element has a serializable type. A type is serializable if it is a primitive type, a class that implements java.io.Serializable or an interface that inherits from java.io.Serializable. Note, the field element is a model specific field representation as returned by a getField call executed on the same model instance.- Parameters:
fieldElement- the field element to be checked- Returns:
trueif the field element has a serializable type;falseotherwise.- See Also:
getField(java.lang.String, java.lang.String)
-
isPrimitive
public boolean isPrimitive(String className, String fieldName)
Determines if a field with the specified fieldName in the class with the specified className has a primitive type.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a primitive field;falseotherwise.- See Also:
getFieldType(java.lang.String, java.lang.String)
-
isPrimitive
protected boolean isPrimitive(String className)
Determines if the specified className represents a primitive type.- Parameters:
className- the fully qualified name of the class or type to be checked- Returns:
trueif this class represents a primitive;falseotherwise.- See Also:
getFieldType(java.lang.String, java.lang.String)
-
isArray
public abstract boolean isArray(String className, String fieldName)
Determines if a field with the specified fieldName in the class with the specified className is an array.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a java array field;falseotherwise.- See Also:
getFieldType(java.lang.String, java.lang.String)
-
isByteArray
public boolean isByteArray(String className, String fieldName)
Determines if a field with the specified fieldName in the class with the specified className is a byte array.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a byte array field;falseotherwise.- See Also:
getFieldType(java.lang.String, java.lang.String)
-
isByteArray
protected boolean isByteArray(String className)
Determines if the specified className represents a byte array.- Parameters:
className- the fully qualified name of the class or type to be checked- Returns:
trueif this class represents a byte array;falseotherwise.
-
isCollection
public boolean isCollection(String className)
Determines if the class name represents a collection.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class represents a collection;falseotherwise.- See Also:
getFieldType(java.lang.String, java.lang.String)
-
isSecondClassObject
public boolean isSecondClassObject(String className)
Determines if the specified className represents a second class object. For this release, the class name is checked against a list of supported second class objects since user-defined second class objects are not supported.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class represents a second class object;falseotherwise.- See Also:
isMutableSecondClassObject(java.lang.String),isCollection(java.lang.String),getFieldType(java.lang.String, java.lang.String)
-
isMutableSecondClassObject
public boolean isMutableSecondClassObject(String className)
Determines if the specified className represents a mutable second class object. For this release, the class name is checked against a list of supported mutable second class objects since user-defined second class objects are not supported.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif this class represents a mutable second class object;falseotherwise.- See Also:
isSecondClassObject(java.lang.String),isCollection(java.lang.String),getFieldType(java.lang.String, java.lang.String)
-
getDeclaringClass
public abstract String getDeclaringClass(Object memberElement)
Returns the string representation of declaring class of the specified member element. Note, the member element is either a class element as returned by getClass, a field element as returned by getField, a constructor element as returned by getConstructor, or a method element as returned by getMethod executed on the same model instance.- Parameters:
memberElement- the member element to be checked- Returns:
- the string representation of the declaring class of the specified memberElement
- See Also:
getClass(java.lang.String),getField(java.lang.String, java.lang.String),getConstructor(java.lang.String, java.lang.String[]),getMethod(java.lang.String, java.lang.String, java.lang.String[])
-
getModifiers
public abstract int getModifiers(Object memberElement)
Returns the modifier mask for the specified member element. Note, the member element is either a class element as returned by getClass, a field element as returned by getField, a constructor element as returned by getConstructor, or a method element as returned by getMethod executed on the same model instance.- Parameters:
memberElement- the member element to be checked- Returns:
- the modifier mask for the specified memberElement
- See Also:
Modifier,getClass(java.lang.String),getField(java.lang.String, java.lang.String),getConstructor(java.lang.String, java.lang.String[]),getMethod(java.lang.String, java.lang.String, java.lang.String[])
-
getModifiersForClass
public int getModifiersForClass(String className)
Returns the modifier mask for the specified className.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the modifier mask for the specified class
- See Also:
Modifier
-
getModifiers
protected int getModifiers(String className, String fieldName)
Returns the modifier mask for the specified fieldName in the class with the specified className.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the modifier mask for the specified field
- See Also:
Modifier
-
isPersistentAllowed
public boolean isPersistentAllowed(String className, String fieldName)
Returnstrueif the specified field can be made persistent,falseotherwise. This computation is based on the modifier and type of the field. Fields which are non-final and non-static and are primitive, persistence capable, or second class objects and not arrays returntrue.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- whether the specified field can be made persistent
- See Also:
getModifiers(String,String),isPrimitive(java.lang.String, java.lang.String),isArray(java.lang.String, java.lang.String),isPersistent(java.lang.String),isSecondClassObject(java.lang.String),shouldBePersistent(java.lang.String, java.lang.String)
-
isPersistentAllowed
public boolean isPersistentAllowed(String className, ClassLoader classLoader, String fieldName)
Returnstrueif the specified field can be made persistent,falseotherwise. This computation is based on the modifier and type of the field. Fields which are non-final and non-static and are primitive, persistence capable, byte arrays, or second class objects and not arrays returntrue.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedclassLoader- the class loader used to find mapping informationfieldName- the name of the field to be checked- Returns:
- whether the specified field can be made persistent
- See Also:
getModifiers(String,String),getFieldType(java.lang.String, java.lang.String),isPersistentTypeAllowed(java.lang.String, java.lang.ClassLoader),shouldBePersistent(java.lang.String, java.lang.String)
-
isPersistentTypeAllowed
protected boolean isPersistentTypeAllowed(String className, ClassLoader classLoader)
Returnstrueif the a field of the specified class or type can be made persistent,falseotherwise. Fields which are primitive, persistence capable, byte arrays, or second class objects and not arrays returntrue.- Parameters:
className- the fully qualified name of the class or type to be checkedclassLoader- the class loader used to find mapping information- Returns:
trueif this class represents a type which can be made persistent;falseotherwise.- See Also:
isPrimitive(java.lang.String, java.lang.String),isByteArray(java.lang.String, java.lang.String),isPersistent(java.lang.String),isSecondClassObject(java.lang.String)
-
shouldBePersistent
public boolean shouldBePersistent(String className, String fieldName)
Returnstrueif the specified field should be made persistent (i.e. does it make sense),falseotherwise. This computation is based solely on the modifier: those which are not volatile returntrue.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- whether the specified field should be made persistent see #getModifiers(String,String)
-
getPersistenceField
public PersistenceFieldElement getPersistenceField(String className, String fieldName)
Returns the PersistenceFieldElement with the supplied fieldName found in the supplied className.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the PersistenceFieldElement for the specified field,
nullif an error occurs or none exists
-
getPersistenceFieldInternal
protected PersistenceFieldElement getPersistenceFieldInternal(String className, String fieldName)
Returns the PersistenceFieldElement with the supplied fieldName found in the supplied className.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the PersistenceFieldElement for the specified field,
nullif an error occurs or none exists
-
isPersistent
public boolean isPersistent(String className, String fieldName)
Determines if the specified className and fieldName pair represent a persistent field.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a persistent field;falseotherwise.
-
isKey
public boolean isKey(String className, String fieldName)
Determines if the specified className and fieldName pair represent a key field.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a key field;falseotherwise.
-
isValidKeyType
public boolean isValidKeyType(String className, String fieldName)
Determines if the specified className and fieldName pair represent a field which has a type which is valid for key fields. Valid key field types include non-collection SCOs (wrappers, Date, Time, etc.) and primitives.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a field with a valid type for a key field;falseotherwise.
-
isDefaultFetchGroup
public boolean isDefaultFetchGroup(String className, String fieldName)
Determines if the specified className and fieldName pair represent a field which is part of the default fetch group.- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a field in the default fetch group;falseotherwise.
-
parse
public boolean parse(String className)
Parses the combination of java (or class) information and mapping/jdo information by running through a subset of the full validation check and aborting (and returningfalseat the first error or warning.- Parameters:
className- the fully qualified name of the class to be checked- Returns:
trueif no errors or warnings occur,falseotherwise.
-
validate
public Collection validate(String className, ResourceBundle bundle)
Validates the combination of java (or class) information and mapping/jdo information by running through the full validation check and returning a collection of ModelValidationExceptions containing any errors or warnings encountered.- Parameters:
className- the fully qualified name of the class to be checkedbundle- the overridden resource bundle file - specifynullif the default one should be used- Returns:
- a collection of ModelValidationExceptions containing any
errors or warnings encountered. If no errors or warnings were
encountered, the collection will be empty, not
null.
-
validate
public Collection validate(String className, ClassLoader classLoader, ResourceBundle bundle)
Validates the combination of java (or class) information and mapping/jdo information by running through the full validation check and returning a collection of ModelValidationExceptions containing any errors or warnings encountered.- Parameters:
className- the fully qualified name of the class to be checkedclassLoader- the class loader used to find mapping informationbundle- the overridden resource bundle file - specifynullif the default one should be used- Returns:
- a collection of ModelValidationExceptions containing any
errors or warnings encountered. If no errors or warnings were
encountered, the collection will be empty, not
null.
-
getReadObjectArgs
public static String[] getReadObjectArgs()
Standard set of arguments for comparison with readObject method.
-
getEqualsArgs
public static String[] getEqualsArgs()
Standard set of arguments for comparison with equals method.
-
getWriteObjectArgs
public static String[] getWriteObjectArgs()
Standard set of arguments for comparison with writeObject method.
-
-