Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.project
Class NamedObjectFactory

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

    public abstract class NamedObjectFactory

extends Object

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

- DataMap
- ObjEntity
- ObjAttribute
- ObjRelationship
- DbEntity
- DerivedDbEntity
- DbAttribute
- DerivedDbAttribute
- DbRelationship
- DataNode
- DataDomain
- Query
- Procedure
- ProcedureParameter

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

Author:
  Andrus Adamchik

Constructor Summary
`NamedObjectFactory()`

Method Summary
`protected abstract Object` | `create(String name, Object namingContext)` Internal factory method.
`static String` | `createName(Class objectClass, Object namingContext)`
`static String` | `createName(Class objectClass, Object namingContext, String nameBase)`
`static Object` | `createObject(Class objectClass, Object namingContext)` Creates an object using an appropriate factory class.
`static Object` | `createObject(Class objectClass, Object namingContext, String nameBase)`
`static Relationship` | `createRelationship(Entity srcEnt, Entity targetEnt, boolean toMany)` Creates a relationship using an appropriate factory class.
`protected abstract boolean` | `isNameInUse(String name, Object namingContext)` Checks if the name is already taken by another sibling in the same context.
`protected String` | `makeName(Object namingContext)` Creates a unique name for the new object and constructs this object.
`protected String` | `makeName(Object namingContext, String nameBase)`
`protected Object` | `makeObject(Object namingContext)` Creates a unique name for the new object and constructs this object.
`protected Object` | `makeObject(Object namingContext, String nameBase)`
`protected abstract 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 String createName(Class objectClass,
                                    Object namingContext)

### createName

    public static String createName(Class objectClass,
                                    Object namingContext,
                                    String nameBase)

  Since:
    1.0.5

### createObject

    public static Object createObject(Class objectClass,
                                      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 Object createObject(Class objectClass,
                                      Object namingContext,
                                      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 String makeName(Object namingContext)

  Creates a unique name for the new object and constructs this object.

### makeName

    protected String makeName(Object namingContext,
                              String nameBase)

  Since:
    1.0.5

### makeObject

    protected Object makeObject(Object namingContext)

  Creates a unique name for the new object and constructs this object.

### makeObject

    protected Object makeObject(Object namingContext,
                                String nameBase)

  Since:
    1.0.5

### nameBase

    protected abstract String nameBase()

  Returns a base default name, like "UntitledEntity", etc.

### create

    protected abstract Object create(String name,
                                     Object namingContext)

  Internal factory method. Invoked after the name is figured out.

### isNameInUse

    protected abstract boolean isNameInUse(String name,
                                           Object namingContext)

  Checks if the name is already taken by another sibling in the same context.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.