org.apache.cayenne.project
Class NamedObjectFactory

java.lang.Object
  extended by org.apache.cayenne.project.NamedObjectFactory

public abstract class NamedObjectFactory
extends java.lang.Object

Factory class that generates various Cayenne objects with default names that are unique in their corresponding context. Supports creation of the following objects:

This is a helper class used mostly by GUI and database reengineering classes.

Author:
Andrei Adamchik

Constructor Summary
NamedObjectFactory()
           
 
Method Summary
protected abstract  java.lang.Object create(java.lang.String name, java.lang.Object namingContext)
          Internal factory method.
static java.lang.String createName(java.lang.Class objectClass, java.lang.Object namingContext)
           
static java.lang.String createName(java.lang.Class objectClass, java.lang.Object namingContext, java.lang.String nameBase)
           
static java.lang.Object createObject(java.lang.Class objectClass, java.lang.Object namingContext)
          Creates an object using an appropriate factory class.
static java.lang.Object createObject(java.lang.Class objectClass, java.lang.Object namingContext, java.lang.String nameBase)
           
static Relationship createRelationship(Entity srcEnt, Entity targetEnt, boolean toMany)
          Creates a relationship using an appropriate factory class.
protected abstract  boolean isNameInUse(java.lang.String name, java.lang.Object namingContext)
          Checks if the name is already taken by another sibling in the same context.
protected  java.lang.String makeName(java.lang.Object namingContext)
          Creates a unique name for the new object and constructs this object.
protected  java.lang.String makeName(java.lang.Object namingContext, java.lang.String nameBase)
           
protected  java.lang.Object makeObject(java.lang.Object namingContext)
          Creates a unique name for the new object and constructs this object.
protected  java.lang.Object makeObject(java.lang.Object namingContext, java.lang.String nameBase)
           
protected abstract  java.lang.String nameBase()
          Returns a base default name, like "UntitledEntity", etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedObjectFactory

public NamedObjectFactory()
Method Detail

createName

public static java.lang.String createName(java.lang.Class objectClass,
                                          java.lang.Object namingContext)

createName

public static java.lang.String createName(java.lang.Class objectClass,
                                          java.lang.Object namingContext,
                                          java.lang.String nameBase)
Since:
1.0.5

createObject

public static java.lang.Object createObject(java.lang.Class objectClass,
                                            java.lang.Object namingContext)
Creates an object using an appropriate factory class. If no factory is found for the object, NullPointerException is thrown.

Note that newly created object is not added to the parent. This behavior can be changed later.


createObject

public static java.lang.Object createObject(java.lang.Class objectClass,
                                            java.lang.Object namingContext,
                                            java.lang.String nameBase)
Since:
1.0.5

createRelationship

public static Relationship createRelationship(Entity srcEnt,
                                              Entity targetEnt,
                                              boolean toMany)
Creates a relationship using an appropriate factory class. If no factory is found for the object, NullPointerException is thrown.

Note that newly created object is not added to the parent. This behavior can be changed later.


makeName

protected java.lang.String makeName(java.lang.Object namingContext)
Creates a unique name for the new object and constructs this object.


makeName

protected java.lang.String makeName(java.lang.Object namingContext,
                                    java.lang.String nameBase)
Since:
1.0.5

makeObject

protected java.lang.Object makeObject(java.lang.Object namingContext)
Creates a unique name for the new object and constructs this object.


makeObject

protected java.lang.Object makeObject(java.lang.Object namingContext,
                                      java.lang.String nameBase)
Since:
1.0.5

nameBase

protected abstract java.lang.String nameBase()
Returns a base default name, like "UntitledEntity", etc.


create

protected abstract java.lang.Object create(java.lang.String name,
                                           java.lang.Object namingContext)
Internal factory method. Invoked after the name is figured out.


isNameInUse

protected abstract boolean isNameInUse(java.lang.String name,
                                       java.lang.Object namingContext)
Checks if the name is already taken by another sibling in the same context.



Copyright © 2001-2006 Apache.org All Rights Reserved.