Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.objectstyle.cayenne.project
Class NamedObjectFactory  view NamedObjectFactory download NamedObjectFactory.java

java.lang.Object
  extended byorg.objectstyle.cayenne.project.NamedObjectFactory
Direct Known Subclasses:
NamedObjectFactory.DataDomainFactory, NamedObjectFactory.DataMapFactory, NamedObjectFactory.DataNodeFactory, NamedObjectFactory.DbEntityFactory, NamedObjectFactory.ObjAttributeFactory, NamedObjectFactory.ObjEntityFactory, NamedObjectFactory.ObjRelationshipFactory, NamedObjectFactory.ProcedureFactory, NamedObjectFactory.ProcedureParameterFactory

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.


Nested Class Summary
(package private) static class NamedObjectFactory.DataDomainFactory
           
(package private) static class NamedObjectFactory.DataMapFactory
           
(package private) static class NamedObjectFactory.DataNodeFactory
           
(package private) static class NamedObjectFactory.DbAttributeFactory
           
(package private) static class NamedObjectFactory.DbEntityFactory
           
(package private) static class NamedObjectFactory.DbRelationshipFactory
           
(package private) static class NamedObjectFactory.DerivedDbAttributeFactory
           
(package private) static class NamedObjectFactory.DerivedDbEntityFactory
           
(package private) static class NamedObjectFactory.ObjAttributeFactory
           
(package private) static class NamedObjectFactory.ObjEntityFactory
           
(package private) static class NamedObjectFactory.ObjRelationshipFactory
           
(package private) static class NamedObjectFactory.ProcedureFactory
           
(package private) static class NamedObjectFactory.ProcedureParameterFactory
           
 
Field Summary
private static java.util.Map factories
           
 
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.Object createObject(java.lang.Class objectClass, java.lang.Object namingContext)
          Creates an object using an appropriate factory class.
static org.objectstyle.cayenne.map.Relationship createRelationship(org.objectstyle.cayenne.map.Entity srcEnt, org.objectstyle.cayenne.map.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.Object makeObject(java.lang.Object namingContext)
          Creates a unique name for the new object and constructs this object.
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
 

Field Detail

factories

private static final java.util.Map factories
Constructor Detail

NamedObjectFactory

public NamedObjectFactory()
Method Detail

createName

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

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.


createRelationship

public static org.objectstyle.cayenne.map.Relationship createRelationship(org.objectstyle.cayenne.map.Entity srcEnt,
                                                                          org.objectstyle.cayenne.map.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.


makeObject

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


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.