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

## org.apache.cayenne.map
Class ObjEntity

    java.lang.Object
      org.apache.cayenne.map.Entity
          org.apache.cayenne.map.ObjEntity

All Implemented Interfaces:
  java.io.Serializable, java.util.EventListener, ObjAttributeListener, ObjEntityListener, ObjRelationshipListener, CayenneMapEntry, XMLSerializable

Direct Known Subclasses:
  EOObjEntity

    public class ObjEntity

extends Entity
implements ObjEntityListener, ObjAttributeListener, ObjRelationshipListener

ObjEntity is a mapping descriptor for a DataObject Java class. It contains the information about the Java class itself, as well as its mapping to the DbEntity layer.

Author:
  Misha Shengaout, Andrus Adamchik
See Also:
  Serialized Form

Field Summary
`protected java.lang.String` | `className`
`protected java.lang.String` | `clientClassName`
`protected java.lang.String` | `clientSuperClassName`
`protected java.lang.String` | `dbEntityName`
`protected static java.util.Collection` | `DEFAULT_GENERIC_CLASSES` A collection of default "generic" entity classes excluded from class generation.
`static int` | `LOCK_TYPE_NONE`
`static int` | `LOCK_TYPE_OPTIMISTIC`
`protected int` | `lockType`
`protected Expression` | `qualifier`
`protected boolean` | `readOnly`
`protected boolean` | `serverOnly`
`protected java.lang.String` | `superClassName`
`protected java.lang.String` | `superEntityName`

Fields inherited from class org.apache.cayenne.map.Entity
`attributes, dataMap, name, PATH_SEPARATOR, relationships`

Constructor Summary
`ObjEntity()`
`ObjEntity(java.lang.String name)`

Method Summary
`void` | `clearDbMapping()` Clears all the mapping between this obj entity and its current db entity.
`void` | `encodeAsXML(XMLEncoder encoder)` Prints itself as XML to the provided XMLEncoder.
`Attribute` | `getAttribute(java.lang.String name)` Returns a named attribute that either belongs to this ObjEntity or is inherited.
`ObjAttribute` | `getAttributeForDbAttribute(DbAttribute dbAttribute)` Returns ObjAttribute of this entity that maps to `dbAttribute` parameter.
`java.util.SortedMap` | `getAttributeMap()` Returns a SortedMap of all attributes that either belong to this ObjEntity or inherited.
`java.util.Collection` | `getAttributes()` Returns a Collection of all attributes that either belong to this ObjEntity or inherited.
`java.lang.String` | `getClassName()` Returns the name of DataObject class described by this entity.
`java.lang.String` | `getClientClassName()` Returns the name of ClientDataObject class described by this entity.
`ObjEntity` | `getClientEntity()` Returns an ObjEntity stripped of any server-side information, such as DbEntity mapping.
`java.lang.String` | `getClientSuperClassName()` Returns a fully-qualified name of the client-side super class of the DataObject class.
`DbEntity` | `getDbEntity()` Returns a DbEntity associated with this ObjEntity.
`java.lang.String` | `getDbEntityName()` Returns the name of the underlying DbEntity.
`java.util.Collection` | `getDeclaredAttributes()` Returns a Collection of all attributes that belong to this ObjEntity, excluding inherited attributes.
`int` | `getDeclaredLockType()` Returns the type of lock used by this ObjEntity, regardless of what locking type is used by super entities.
`Expression` | `getDeclaredQualifier()` Returns a qualifier that imposes a restriction on what objects belong to this entity.
`java.util.Collection` | `getDeclaredRelationships()` Returns a Collection of all relationships that belong to this ObjEntity, excluding inherited attributes.
`java.lang.Class` | `getJavaClass()` Returns Java class of persistent objects described by this entity.
`java.lang.Class` | `getJavaClass(java.lang.ClassLoader classLoader)` Deprecated. since 1.2 thread ClassLoader is used.
`int` | `getLockType()` Returns the type of lock used by this ObjEntity.
`Relationship` | `getRelationship(java.lang.String name)` Returns a named Relationship that either belongs to this ObjEntity or is inherited.
`ObjRelationship` | `getRelationshipForDbRelationship(DbRelationship dbRelationship)` Returns ObjRelationship of this entity that maps to `dbRelationship` parameter.
`java.util.SortedMap` | `getRelationshipMap()` Returns an unmodifiable map of relationships sorted by name.
`java.util.Collection` | `getRelationships()` Returns an unmodifiable collection of Relationships that exist in this entity.
`java.lang.String` | `getSuperClassName()` Returns a fully-qualified name of the super class of the DataObject class.
`ObjEntity` | `getSuperEntity()` Returns a "super" entity in the entity inheritance hierarchy.
`java.lang.String` | `getSuperEntityName()` Returns an entity name for a parent entity in the inheritance hierarchy.
`boolean` | `isClientAllowed()` Returns true if this entity is allowed to be used on the client.
`boolean` | `isGeneric()` Returns whether this entity is "generic", meaning it is not mapped to a unique Java class.
`boolean` | `isReadOnly()` Returns `true` if this ObjEntity represents a set of read-only objects.
`boolean` | `isServerOnly()` Returns true if this entity is not available on the client.
`boolean` | `isSubentityOf(ObjEntity entity)` Returns true if this entity directly or indirectly inherits from a given entity, false otherwise.
`void` | `objAttributeAdded(AttributeEvent e)` New attribute has been created/added.
`void` | `objAttributeChanged(AttributeEvent e)` Attribute property changed.
`void` | `objAttributeRemoved(AttributeEvent e)` Attribute has been removed.
`void` | `objEntityAdded(EntityEvent e)` New entity has been created/added.
`void` | `objEntityChanged(EntityEvent e)` ObjEntity property changed.
`void` | `objEntityRemoved(EntityEvent e)` Entity has been removed.
`void` | `objRelationshipAdded(RelationshipEvent e)` Relationship has been created/added.
`void` | `objRelationshipChanged(RelationshipEvent e)` Relationship property changed.
`void` | `objRelationshipRemoved(RelationshipEvent e)` Relationship has been removed.
`java.util.Iterator` | `resolvePathComponents(Expression pathExp)` Processes expression `pathExp` and returns an Iterator of path components that contains a sequence of Attributes and Relationships.
`void` | `setClassName(java.lang.String className)` Sets the name of the DataObject class described by this entity.
`void` | `setClientClassName(java.lang.String clientClassName)` Sets the name of the ClientDataObject class described by this entity.
`void` | `setClientSuperClassName(java.lang.String clientSuperClassName)` Sets a fully-qualified name of the client-side super class of the ClientDataObject class.
`void` | `setDbEntity(DbEntity dbEntity)` Sets the DbEntity used by this ObjEntity.
`void` | `setDbEntityName(java.lang.String string)` Sets the name of underlying DbEntity.
`void` | `setDeclaredLockType(int i)` Sets the type of lock used by this ObjEntity.
`void` | `setDeclaredQualifier(Expression qualifier)` Sets a qualifier that imposes a limit on what objects belong to this entity.
`void` | `setReadOnly(boolean readOnly)`
`void` | `setServerOnly(boolean serverOnly)` Sets whether this entity is available on the client.
`void` | `setSuperClassName(java.lang.String superClassName)` Sets a fully-qualified name of the super class of the DataObject class.
`void` | `setSuperEntityName(java.lang.String superEntityName)` Sets an entity name for a parent entity in the inheritance hierarchy.
`Expression` | `translateToDbPath(Expression expression)` Transforms an Expression to an analogous expression in terms of the underlying DbEntity.
`Expression` | `translateToRelatedEntity(Expression expression, java.lang.String relationshipPath)` Transforms an Expression rooted in this entity to an analogous expression rooted in related entity.

Methods inherited from class org.apache.cayenne.map.Entity
`addAttribute, addRelationship, clearAttributes, clearRelationships, getAnyRelationship, getDataMap, getName, getParent, lastPathComponent, removeAttribute, removeRelationship, resolvePathComponents, setDataMap, setName, setParent`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOCK_TYPE_NONE

    public static final int LOCK_TYPE_NONE

See Also:
  Constant Field Values

### LOCK_TYPE_OPTIMISTIC

    public static final int LOCK_TYPE_OPTIMISTIC

See Also:
  Constant Field Values

### DEFAULT_GENERIC_CLASSES

    protected static final java.util.Collection DEFAULT_GENERIC_CLASSES

  A collection of default "generic" entity classes excluded from class generation.

  Since:
    1.2

### superClassName

    protected java.lang.String superClassName

### className

    protected java.lang.String className

### dbEntityName

    protected java.lang.String dbEntityName

### superEntityName

    protected java.lang.String superEntityName

### qualifier

    protected Expression qualifier

### readOnly

    protected boolean readOnly

### lockType

    protected int lockType

### serverOnly

    protected boolean serverOnly

### clientClassName

    protected java.lang.String clientClassName

### clientSuperClassName

    protected java.lang.String clientSuperClassName

Constructor Detail

### ObjEntity

    public ObjEntity()

### ObjEntity

    public ObjEntity(java.lang.String name)

Method Detail

### encodeAsXML

    public void encodeAsXML(XMLEncoder encoder)

  Prints itself as XML to the provided XMLEncoder.

  Specified by:
    `encodeAsXML` in interface `XMLSerializable`
  Since:
    1.1

### getClientEntity

    public ObjEntity getClientEntity()

  Returns an ObjEntity stripped of any server-side information, such as DbEntity mapping. "clientClassName" property of this entity is used to intialize "className" property of returned entity.

  Since:
    1.2

### getJavaClass

    public java.lang.Class getJavaClass(java.lang.ClassLoader classLoader)

  Deprecated. since 1.2 thread ClassLoader is used.

  Returns Java class of persistent objects described by this entity. Casts any thrown exceptions into CayenneRuntimeException.

  Since:
    1.0.7

### getJavaClass

    public java.lang.Class getJavaClass()

  Returns Java class of persistent objects described by this entity. For generic entities with no class specified explicitly, default DataMap superclass is used, and if it is not set - CayenneDataObject is used. Casts any thrown exceptions into CayenneRuntimeException.

  Since:
    1.2

### getLockType

    public int getLockType()

  Returns the type of lock used by this ObjEntity. If this entity is not locked, this method would look in a super entity recursively, until it finds a lock somewhere in the inheritance hierarchy.

  Since:
    1.1

### getDeclaredLockType

    public int getDeclaredLockType()

  Returns the type of lock used by this ObjEntity, regardless of what locking type is used by super entities.

  Since:
    1.1

### setDeclaredLockType

    public void setDeclaredLockType(int i)

  Sets the type of lock used by this ObjEntity.

  Since:
    1.1

### isGeneric

    public boolean isGeneric()

  Returns whether this entity is "generic", meaning it is not mapped to a unique Java class. Criterion for generic entities is that it either has no Java class mapped or its class is the same as DataMap's default superclass, or it is CayenneDataObject.

  Since:
    1.2

### isClientAllowed

    public boolean isClientAllowed()

  Returns true if this entity is allowed to be used on the client. Checks that parent DataMap allows client entities and also that this entity is not explicitly disabled for the client use.

  Since:
    1.2

### isServerOnly

    public boolean isServerOnly()

  Returns true if this entity is not available on the client.

  Since:
    1.2

### setServerOnly

    public void setServerOnly(boolean serverOnly)

  Sets whether this entity is available on the client.

  Since:
    1.2

### getDeclaredQualifier

    public Expression getDeclaredQualifier()

  Returns a qualifier that imposes a restriction on what objects belong to this entity. Returned qualifier is the one declared in this entity, and does not include qualifiers declared in super entities.

  Since:
    1.1

### getSuperEntityName

    public java.lang.String getSuperEntityName()

  Returns an entity name for a parent entity in the inheritance hierarchy.

  Since:
    1.1

### setDeclaredQualifier

    public void setDeclaredQualifier(Expression qualifier)

  Sets a qualifier that imposes a limit on what objects belong to this entity.

  Since:
    1.1

### setSuperEntityName

    public void setSuperEntityName(java.lang.String superEntityName)

  Sets an entity name for a parent entity in the inheritance hierarchy.

  Since:
    1.1

### getClassName

    public java.lang.String getClassName()

  Returns the name of DataObject class described by this entity.

### setClassName

    public void setClassName(java.lang.String className)

  Sets the name of the DataObject class described by this entity.

### getClientClassName

    public java.lang.String getClientClassName()

  Returns the name of ClientDataObject class described by this entity.

  Since:
    1.2

### setClientClassName

    public void setClientClassName(java.lang.String clientClassName)

  Sets the name of the ClientDataObject class described by this entity.

  Since:
    1.2

### getSuperClassName

    public java.lang.String getSuperClassName()

  Returns a fully-qualified name of the super class of the DataObject class. This value is used as a hint for class generation. If the entity inherits from another entity, a superclass is the class of that entity.

### setSuperClassName

    public void setSuperClassName(java.lang.String superClassName)

  Sets a fully-qualified name of the super class of the DataObject class. This value is used as a hint for class generation.

  An attempt to set superclass on an inherited entity has no effect, since a class of the super entity is always used as a superclass.

### getClientSuperClassName

    public java.lang.String getClientSuperClassName()

  Returns a fully-qualified name of the client-side super class of the DataObject class. This value is used as a hint for class generation. If the entity inherits from another entity, a superclass is the class of that entity.

  Since:
    1.2

### setClientSuperClassName

    public void setClientSuperClassName(java.lang.String clientSuperClassName)

  Sets a fully-qualified name of the client-side super class of the ClientDataObject class. This value is used as a hint for class generation.

  An attempt to set superclass on an inherited entity has no effect, since a class of the super entity is always used as a superclass.

  Since:
    1.2

### getSuperEntity

    public ObjEntity getSuperEntity()

  Returns a "super" entity in the entity inheritance hierarchy.

  Since:
    1.1

### getDbEntity

    public DbEntity getDbEntity()

  Returns a DbEntity associated with this ObjEntity.

### setDbEntity

    public void setDbEntity(DbEntity dbEntity)

  Sets the DbEntity used by this ObjEntity.

  Setting DbEntity on an inherited entity has no effect, since a class of the super entity is always used as a superclass.

### getAttribute

    public Attribute getAttribute(java.lang.String name)

  Returns a named attribute that either belongs to this ObjEntity or is inherited. Returns null if no matching attribute is found.

  Overrides:
    `getAttribute` in class `Entity`

### getAttributeMap

    public java.util.SortedMap getAttributeMap()

  Returns a SortedMap of all attributes that either belong to this ObjEntity or inherited.

  Overrides:
    `getAttributeMap` in class `Entity`

### getAttributes

    public java.util.Collection getAttributes()

  Returns a Collection of all attributes that either belong to this ObjEntity or inherited.

  Overrides:
    `getAttributes` in class `Entity`

### getDeclaredAttributes

    public java.util.Collection getDeclaredAttributes()

  Returns a Collection of all attributes that belong to this ObjEntity, excluding inherited attributes.

  Since:
    1.1

### getRelationship

    public Relationship getRelationship(java.lang.String name)

  Returns a named Relationship that either belongs to this ObjEntity or is inherited. Returns null if no matching attribute is found.

  Overrides:
    `getRelationship` in class `Entity`

### getRelationshipMap

    public java.util.SortedMap getRelationshipMap()

  Description copied from class: `Entity`
  Returns an unmodifiable map of relationships sorted by name.

  Overrides:
    `getRelationshipMap` in class `Entity`

### getRelationships

    public java.util.Collection getRelationships()

  Description copied from class: `Entity`
  Returns an unmodifiable collection of Relationships that exist in this entity.

  Overrides:
    `getRelationships` in class `Entity`

### getDeclaredRelationships

    public java.util.Collection getDeclaredRelationships()

  Returns a Collection of all relationships that belong to this ObjEntity, excluding inherited attributes.

  Since:
    1.1

### getAttributeForDbAttribute

    public ObjAttribute getAttributeForDbAttribute(DbAttribute dbAttribute)

  Returns ObjAttribute of this entity that maps to `dbAttribute` parameter. Returns null if no such attribute is found.

### getRelationshipForDbRelationship

    public ObjRelationship getRelationshipForDbRelationship(DbRelationship dbRelationship)

  Returns ObjRelationship of this entity that maps to `dbRelationship` parameter. Returns null if no such relationship is found.

### clearDbMapping

    public void clearDbMapping()

  Clears all the mapping between this obj entity and its current db entity. Clears mapping between entities, attributes and relationships.

### isReadOnly

    public boolean isReadOnly()

  Returns `true` if this ObjEntity represents a set of read-only objects.

  Returns:
    boolean

### setReadOnly

    public void setReadOnly(boolean readOnly)

### isSubentityOf

    public boolean isSubentityOf(ObjEntity entity)

  Returns true if this entity directly or indirectly inherits from a given entity, false otherwise.

  Since:
    1.1

### resolvePathComponents

    public java.util.Iterator resolvePathComponents(Expression pathExp)
                                             throws ExpressionException

  Description copied from class: `Entity`
  Processes expression `pathExp` and returns an Iterator of path components that contains a sequence of Attributes and Relationships. Note that if path is invalid and can not be resolved from this entity, this method will still return an Iterator, but an attempt to read the first invalid path component will result in ExpressionException.

  Specified by:
    `resolvePathComponents` in class `Entity`
  Throws:
    `ExpressionException`

### translateToDbPath

    public Expression translateToDbPath(Expression expression)

  Transforms an Expression to an analogous expression in terms of the underlying DbEntity.

  Since:
    1.1

### translateToRelatedEntity

    public Expression translateToRelatedEntity(Expression expression,
                                               java.lang.String relationshipPath)

  Transforms an Expression rooted in this entity to an analogous expression rooted in related entity.

  Specified by:
    `translateToRelatedEntity` in class `Entity`
  Since:
    1.1

### getDbEntityName

    public java.lang.String getDbEntityName()

  Returns the name of the underlying DbEntity.

  Since:
    1.1

### setDbEntityName

    public void setDbEntityName(java.lang.String string)

  Sets the name of underlying DbEntity.

  Since:
    1.1

### objEntityChanged

    public void objEntityChanged(EntityEvent e)

  ObjEntity property changed. May be name, attribute or relationship added or removed, etc. Attribute and relationship property changes are handled in respective listeners.

  Specified by:
    `objEntityChanged` in interface `ObjEntityListener`
  Since:
    1.2

### objEntityAdded

    public void objEntityAdded(EntityEvent e)

  New entity has been created/added.

  Specified by:
    `objEntityAdded` in interface `ObjEntityListener`

### objEntityRemoved

    public void objEntityRemoved(EntityEvent e)

  Entity has been removed.

  Specified by:
    `objEntityRemoved` in interface `ObjEntityListener`

### objAttributeChanged

    public void objAttributeChanged(AttributeEvent e)

  Attribute property changed.

  Specified by:
    `objAttributeChanged` in interface `ObjAttributeListener`

### objAttributeAdded

    public void objAttributeAdded(AttributeEvent e)

  New attribute has been created/added.

  Specified by:
    `objAttributeAdded` in interface `ObjAttributeListener`

### objAttributeRemoved

    public void objAttributeRemoved(AttributeEvent e)

  Attribute has been removed.

  Specified by:
    `objAttributeRemoved` in interface `ObjAttributeListener`

### objRelationshipChanged

    public void objRelationshipChanged(RelationshipEvent e)

  Relationship property changed.

  Specified by:
    `objRelationshipChanged` in interface `ObjRelationshipListener`

### objRelationshipAdded

    public void objRelationshipAdded(RelationshipEvent e)

  Relationship has been created/added.

  Specified by:
    `objRelationshipAdded` in interface `ObjRelationshipListener`

### objRelationshipRemoved

    public void objRelationshipRemoved(RelationshipEvent e)

  Relationship has been removed.

  Specified by:
    `objRelationshipRemoved` in interface `ObjRelationshipListener`

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

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