org.jpox.metadata
Class MetaDataUtils

java.lang.Object
  extended byorg.jpox.metadata.MetaDataUtils

public class MetaDataUtils
extends java.lang.Object

Utilities needed for the processing of MetaData.

Version:
$Revision: 1.35 $

Field Summary
protected static Localiser LOCALISER
           
 
Constructor Summary
protected MetaDataUtils()
          Protected constructor to prevent outside instantiation
 
Method Summary
 java.lang.String[] getImplementationNamesForReferenceField(AbstractPropertyMetaData fmd, DatastoreFieldRole role, ClassLoaderResolver clr)
          Convenience method to return the class names of the available implementation types for an interface/Object field, given its required role.
static MetaDataUtils getInstance()
          Gets an instance of MetaDataUtils
 java.util.List getOrderedClassNamesFromFileList(java.net.URL[] metaDataFileURLs, java.util.Map classToMetaDataMap)
          Utility to return a list of classes declared in provided metadata files.
 java.lang.String[] getValuesForCommaSeparatedAttribute(java.lang.String attr)
          Convenience method that splits a comma-separated list of values into a String array (removing whitespace).
 boolean isValidPrimaryKeyClass(java.lang.Class pkClass, AbstractClassMetaData cmd, ClassLoaderResolver clr, int noOfPkFields)
          Utility to check if a primary-key class is valid.
 boolean storesFCO(AbstractPropertyMetaData fmd, ClassLoaderResolver clr)
          Convenience method that returns if a field stores a First-Class object (FCO).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Constructor Detail

MetaDataUtils

protected MetaDataUtils()
Protected constructor to prevent outside instantiation

Method Detail

getInstance

public static MetaDataUtils getInstance()
Gets an instance of MetaDataUtils

Returns:
a singleton instance of MetaDataUtils

getOrderedClassNamesFromFileList

public java.util.List getOrderedClassNamesFromFileList(java.net.URL[] metaDataFileURLs,
                                                       java.util.Map classToMetaDataMap)
                                                throws java.lang.Exception
Utility to return a list of classes declared in provided metadata files. The list of classes are ordered so that all superclasses occur before their subclasses. Additionally populates the provided map with entries mapping the class names to the JDO MetaData file name that the class was found in. Used by SchemaTool.

Parameters:
metaDataFileURLs - The list of JDO metadata file names.
classToMetaDataMap - A Map that will be populated mapping class name to the MetaData file name. This argument can be null.
Returns:
An ordered list of class name strings.
Throws:
java.lang.Exception

isValidPrimaryKeyClass

public boolean isValidPrimaryKeyClass(java.lang.Class pkClass,
                                      AbstractClassMetaData cmd,
                                      ClassLoaderResolver clr,
                                      int noOfPkFields)
Utility to check if a primary-key class is valid. Will throw a InvalidPrimaryKeyException if it is invalid, otherwise returning true.

Parameters:
pkClass - The Primary Key class
cmd - AbstractClassMetaData for the PersistenceCapable class
clr - the ClassLoaderResolver
noOfPkFields - Number of primary key fields
Returns:
Whether it is valid

storesFCO

public boolean storesFCO(AbstractPropertyMetaData fmd,
                         ClassLoaderResolver clr)
Convenience method that returns if a field stores a First-Class object (FCO).

Parameters:
fmd - MetaData for the field
clr - ClassLoaderResolver resolver
Returns:
Whether it stores a FCO

getValuesForCommaSeparatedAttribute

public java.lang.String[] getValuesForCommaSeparatedAttribute(java.lang.String attr)
Convenience method that splits a comma-separated list of values into a String array (removing whitespace).

Parameters:
attr - The attribute value
Returns:
The string components

getImplementationNamesForReferenceField

public java.lang.String[] getImplementationNamesForReferenceField(AbstractPropertyMetaData fmd,
                                                                  DatastoreFieldRole role,
                                                                  ClassLoaderResolver clr)
Convenience method to return the class names of the available implementation types for an interface/Object field, given its required role. Removes all duplicates from the list.

Parameters:
fmd - MetaData for the field
role - The role of the field
clr - the ClassLoaderResolver
Returns:
Names of the classes of the possible implementations of this interface/Object
Throws:
javax.jdo.JDOUserException - if no implementation types are found for the reference type field


Copyright © -2007 . All Rights Reserved.