org.apache.jdo.model.jdo
Interface JDOModel

All Superinterfaces:
JDOElement
All Known Implementing Classes:
JDOModelImplDynamic

public interface JDOModel
extends JDOElement

A JDOModel instance bundles a number of JDOClass instances used by an application. It provides factory methods to create and retrieve JDOClass instances. A fully qualified class name must be unique within a JDOModel instance. The model supports multiple classes having the same fully qualified name by different JDOModel instances.

Author:
Michael Bouschen

Method Summary
 JDOClass createJDOClass(java.lang.String className)
          The method returns a JDOClass instance for the specified fully qualified class name.
 JDOClass createJDOClass(java.lang.String className, boolean loadXMLMetadata)
          The method returns a JDOClass instance for the specified fully qualified class name.
 JDOPackage createJDOPackage(java.lang.String packageName)
          The method returns a JDOClass instance for the specified package name.
 JDOClass[] getDeclaredClasses()
          Returns the collection of JDOClass instances declared by this JDOModel in the format of an array.
 JDOPackage[] getDeclaredPackages()
          Returns the collection of JDOPackage instances declared by this JDOModel in the format of an array.
 JavaModel getJavaModel()
          Returns the JavaModel bound to this JDOModel instance.
 JDOClass getJDOClass(java.lang.String className)
          The method returns the JDOClass instance for the specified fully qualified class name if present.
 JDOClass getJDOClass(java.lang.String className, boolean loadXMLMetadata)
          The method returns the JDOClass instance for the specified fully qualified class name if present.
 JDOClass getJDOClassForObjectIdClass(JavaType objectIdClass)
          This method returns the JDOClass instance that defines the specified type as its objectId class.
 JDOPackage getJDOPackage(java.lang.String packageName)
          The method returns the JDOPackage instance for the specified package name, if present.
 JDOModel getParent()
          Returns the parent JDOModel instance of this JDOModel.
 void setJavaModel(JavaModel javaModel)
          Sets the JavaModel for this JDOModel instance.
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOElement
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 

Method Detail

createJDOPackage

public JDOPackage createJDOPackage(java.lang.String packageName)
                            throws ModelException
The method returns a JDOClass instance for the specified package name. If this JDOModel contains the corresponding JDOPackage instance, the existing instance is returned. Otherwise, it creates a new JDOPackage instance and returns the new instance.

Parameters:
packageName - the name of the JDOPackage instance to be returned
Returns:
a JDOPackage instance for the specified package name
Throws:
ModelException - if impossible

getJDOPackage

public JDOPackage getJDOPackage(java.lang.String packageName)
The method returns the JDOPackage instance for the specified package name, if present. The method returns null if it cannot find a JDOPackage instance for the specified name.

Parameters:
packageName - the name of the JDOPackage instance to be returned
Returns:
a JDOPackage instance for the specified package name or null if not present

getDeclaredPackages

public JDOPackage[] getDeclaredPackages()
Returns the collection of JDOPackage instances declared by this JDOModel in the format of an array.

Returns:
the packages declared by this JDOModel

createJDOClass

public JDOClass createJDOClass(java.lang.String className)
                        throws ModelException
The method returns a JDOClass instance for the specified fully qualified class name. If this JDOModel contains the corresponding JDOClass instance, the existing instance is returned. Otherwise, it creates a new JDOClass instance, sets its declaringModel and returns the new instance.

Whether this method reads XML metatdata or not is deteremined at JDOModel creation time (see flag loadXMLMetadataDefault in JDOModelFactory.getJDOModel(JavaModel javaModel, boolean loadXMLMetadataDefault)). Invoking this method is method is equivalent to createJDOClass(className, loadXMLMetadataDefault).

Parameters:
className - the fully qualified class name of the JDOClass instance to be returned
Returns:
a JDOClass instance for the specified class name
Throws:
ModelException - if impossible

createJDOClass

public JDOClass createJDOClass(java.lang.String className,
                               boolean loadXMLMetadata)
                        throws ModelException
The method returns a JDOClass instance for the specified fully qualified class name. If this JDOModel contains the corresponding JDOClass instance, the existing instance is returned. Otherwise, if the flag loadXMLMetadata is set to true the method tries to find the JDOClass instance by reading the XML metadata. If it could not be found the method creates a new JDOClass instance, sets its declaringModel and returns the instance.

Parameters:
className - the fully qualified class name of the JDOClass instance to be returned
loadXMLMetadata - indicates whether to read XML metatdata or not
Returns:
a JDOClass instance for the specified class name
Throws:
ModelException - if impossible

getJDOClass

public JDOClass getJDOClass(java.lang.String className)
The method returns the JDOClass instance for the specified fully qualified class name if present. The method returns null if it cannot find a JDOClass instance for the specified name.

Whether this method reads XML metatdata or not is deteremined at JDOModel creation time (see flag loadXMLMetadataDefault in JDOModelFactory.getJDOModel(JavaModel javaModel, boolean loadXMLMetadataDefault)). Invoking this method is method is equivalent to createJDOClass(className, loadXMLMetadataDefault).

Parameters:
className - the fully qualified class name of the JDOClass instance to be returned
Returns:
a JDOClass instance for the specified class name or null if not present

getJDOClass

public JDOClass getJDOClass(java.lang.String className,
                            boolean loadXMLMetadata)
The method returns the JDOClass instance for the specified fully qualified class name if present. If the flag loadXMLMetadata is set to true the method tries to find the JDOClass instance by reading the XML metadata. The method returns null if it cannot find a JDOClass instance for the specified name.

Parameters:
className - the fully qualified class name of the JDOClass instance to be returned
loadXMLMetadata - indicates whether to read XML metatdata or not
Returns:
a JDOClass instance for the specified class name or null if not present

getDeclaredClasses

public JDOClass[] getDeclaredClasses()
Returns the collection of JDOClass instances declared by this JDOModel in the format of an array.

Returns:
the classes declared by this JDOModel

getJavaModel

public JavaModel getJavaModel()
Returns the JavaModel bound to this JDOModel instance.

Returns:
the JavaModel

setJavaModel

public void setJavaModel(JavaModel javaModel)
Sets the JavaModel for this JDOModel instance.

Parameters:
javaModel - the JavaModel

getParent

public JDOModel getParent()
Returns the parent JDOModel instance of this JDOModel.

Returns:
the parent JDOModel

getJDOClassForObjectIdClass

public JDOClass getJDOClassForObjectIdClass(JavaType objectIdClass)
This method returns the JDOClass instance that defines the specified type as its objectId class. In the case of an inheritance hierarchy it returns the top most persistence-capable class of the hierarchy (see JDOClass.getPersistenceCapableSuperclass()).

Parameters:
objectIdClass - the type representation of the ObjectId class
Returns:
the JDOClass defining the specified class as ObjectId class