|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.map.Entity
org.apache.cayenne.map.ObjEntity
public class ObjEntity
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.
Field Summary | |
---|---|
protected boolean |
_abstract
|
protected Map<String,String> |
attributeOverrides
|
protected CallbackMap |
callbacks
|
protected String |
className
|
protected String |
clientClassName
|
protected String |
clientSuperClassName
|
protected String |
dbEntityName
|
protected static Collection<String> |
DEFAULT_GENERIC_CLASSES
A collection of default "generic" entity classes excluded from class generation. |
protected List<EntityListener> |
entityListeners
|
protected boolean |
excludingDefaultListeners
|
protected boolean |
excludingSuperclassListeners
|
static int |
LOCK_TYPE_NONE
|
static int |
LOCK_TYPE_OPTIMISTIC
|
protected int |
lockType
|
protected Expression |
qualifier
|
protected boolean |
readOnly
|
protected boolean |
serverOnly
|
protected String |
superClassName
|
protected String |
superEntityName
|
Fields inherited from class org.apache.cayenne.map.Entity |
---|
attributes, dataMap, name, OUTER_JOIN_INDICATOR, PATH_SEPARATOR, relationships |
Constructor Summary | |
---|---|
ObjEntity()
|
|
ObjEntity(String name)
|
Method Summary | |
---|---|
void |
addAttributeOverride(String attributeName,
String dbPath)
|
void |
addEntityListener(EntityListener listener)
Adds a new EntityListener. |
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(String name)
Returns a named attribute that is either declared in this ObjEntity or is inherited. |
ObjAttribute |
getAttributeForDbAttribute(DbAttribute dbAttribute)
Returns ObjAttribute of this entity that maps to dbAttribute
parameter. |
SortedMap<String,ObjAttribute> |
getAttributeMap()
Returns a SortedMap of all attributes that either belong to this ObjEntity or inherited. |
Collection<ObjAttribute> |
getAttributes()
Returns a Collection of all attributes that either belong to this ObjEntity or inherited. |
CallbackMap |
getCallbackMap()
Returns an object that stores callback methods of this entity. |
String |
getClassName()
Returns the name of DataObject class described by this entity. |
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. |
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. |
String |
getDbEntityName()
Returns the name of the underlying DbEntity. |
Map<String,String> |
getDeclaredAttributeOverrides()
|
Collection<ObjAttribute> |
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. |
Collection<ObjRelationship> |
getDeclaredRelationships()
Returns a Collection of all relationships that belong to this ObjEntity, excluding inherited attributes. |
EntityListener |
getEntityListener(String className)
|
List<EntityListener> |
getEntityListeners()
Returns an unmodifiable list of registered EntityListener objects. |
Class<?> |
getJavaClass()
Returns Java class of persistent objects described by this entity. |
int |
getLockType()
Returns the type of lock used by this ObjEntity. |
Collection<String> |
getPrimaryKeyNames()
Returns the names of DbAtributes that comprise the primary key of the parent DbEntity. |
Collection<ObjAttribute> |
getPrimaryKeys()
Returns an unmodifiable collection of ObjAttributes representing the primary key of the table described by this DbEntity. |
Relationship |
getRelationship(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. |
SortedMap<String,ObjRelationship> |
getRelationshipMap()
Returns an unmodifiable map of relationships sorted by name. |
Collection<ObjRelationship> |
getRelationships()
Returns an unmodifiable collection of Relationships that exist in this entity. |
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. |
String |
getSuperEntityName()
Returns an entity name for a parent entity in the inheritance hierarchy. |
boolean |
isAbstract()
|
boolean |
isClientAllowed()
Returns true if this entity is allowed to be used on the client. |
boolean |
isExcludingDefaultListeners()
Returns true if the default lifecycle listeners should not be notified of this entity lifecycle events. |
boolean |
isExcludingSuperclassListeners()
Returns true if the lifeycle listeners defined on the superclasses should not be notified of this entity lifecycle events. |
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. |
PathComponent<ObjAttribute,ObjRelationship> |
lastPathComponent(Expression path,
Map aliasMap)
Convenience method returning the last component in the path iterator. |
void |
objAttributeAdded(AttributeEvent e)
Deprecated. since 3.0 ObjEntity no longer implements ObjAttributeListener |
void |
objAttributeChanged(AttributeEvent e)
Deprecated. since 3.0 ObjEntity no longer implements ObjAttributeListener |
void |
objAttributeRemoved(AttributeEvent e)
Deprecated. since 3.0 ObjEntity no longer implements ObjAttributeListener |
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)
Deprecated. since 3.0 ObjEntity no longer implements ObjRelationshipListener |
void |
objRelationshipChanged(RelationshipEvent e)
Deprecated. since 3.0 ObjEntity no longer implements ObjRelationshipListener |
void |
objRelationshipRemoved(RelationshipEvent e)
Deprecated. since 3.0 ObjEntity no longer implements ObjRelationshipListener |
void |
removeEntityListener(String className)
Removes a listener matching class name. |
Iterable<PathComponent<ObjAttribute,ObjRelationship>> |
resolvePath(Expression pathExp,
Map aliasMap)
Returns an Iterable instance over expression path components based on this entity. |
Iterator<CayenneMapEntry> |
resolvePathComponents(Expression pathExp)
Processes expression pathExp and returns an Iterator of path
components that contains a sequence of Attributes and Relationships. |
void |
setAbstract(boolean isAbstract)
Sets whether this entity is abstract only. |
void |
setClassName(String className)
Sets the name of the DataObject class described by this entity. |
void |
setClientClassName(String clientClassName)
Sets the name of the ClientDataObject class described by this entity. |
void |
setClientSuperClassName(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(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 |
setExcludingDefaultListeners(boolean excludingDefaultListeners)
|
void |
setExcludingSuperclassListeners(boolean excludingSuperclassListeners)
|
void |
setReadOnly(boolean readOnly)
|
void |
setServerOnly(boolean serverOnly)
Sets whether this entity is available on the client. |
void |
setSuperClassName(String superClassName)
Sets a fully-qualified name of the super class of the DataObject class. |
void |
setSuperEntityName(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,
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, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int LOCK_TYPE_NONE
public static final int LOCK_TYPE_OPTIMISTIC
protected static final Collection<String> DEFAULT_GENERIC_CLASSES
protected String superClassName
protected String className
protected String dbEntityName
protected String superEntityName
protected Expression qualifier
protected boolean readOnly
protected int lockType
protected boolean _abstract
protected boolean serverOnly
protected String clientClassName
protected String clientSuperClassName
protected List<EntityListener> entityListeners
protected CallbackMap callbacks
protected boolean excludingDefaultListeners
protected boolean excludingSuperclassListeners
protected Map<String,String> attributeOverrides
Constructor Detail |
---|
public ObjEntity()
public ObjEntity(String name)
Method Detail |
---|
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public ObjEntity getClientEntity()
public Class<?> getJavaClass()
public List<EntityListener> getEntityListeners()
EntityListener
objects. Note
that since the order of listeners is significant a list, not just a generic
Collection is returned.
public void addEntityListener(EntityListener listener)
IllegalArgumentException
- if a listener for the same class name is already
registered.public void removeEntityListener(String className)
public EntityListener getEntityListener(String className)
public CallbackMap getCallbackMap()
public int getLockType()
public int getDeclaredLockType()
public void setDeclaredLockType(int i)
public boolean isGeneric()
public boolean isClientAllowed()
public boolean isAbstract()
public void setAbstract(boolean isAbstract)
public boolean isServerOnly()
public void setServerOnly(boolean serverOnly)
public Expression getDeclaredQualifier()
public String getSuperEntityName()
public void setDeclaredQualifier(Expression qualifier)
public void setSuperEntityName(String superEntityName)
public String getClassName()
public void setClassName(String className)
public String getClientClassName()
public void setClientClassName(String clientClassName)
public String getSuperClassName()
public void setSuperClassName(String superClassName)
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.
public String getClientSuperClassName()
public void setClientSuperClassName(String clientSuperClassName)
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.
public ObjEntity getSuperEntity()
public DbEntity getDbEntity()
public void setDbEntity(DbEntity dbEntity)
Setting DbEntity on an inherited entity has no effect, since a class of the super entity is always used as a superclass.
public Collection<ObjAttribute> getPrimaryKeys()
public Attribute getAttribute(String name)
getAttribute
in class Entity
public SortedMap<String,ObjAttribute> getAttributeMap()
getAttributeMap
in class Entity
public void addAttributeOverride(String attributeName, String dbPath)
public Map<String,String> getDeclaredAttributeOverrides()
public Collection<ObjAttribute> getAttributes()
getAttributes
in class Entity
public Collection<ObjAttribute> getDeclaredAttributes()
public Relationship getRelationship(String name)
getRelationship
in class Entity
public SortedMap<String,ObjRelationship> getRelationshipMap()
Entity
getRelationshipMap
in class Entity
public Collection<ObjRelationship> getRelationships()
Entity
getRelationships
in class Entity
public Collection<ObjRelationship> getDeclaredRelationships()
public ObjAttribute getAttributeForDbAttribute(DbAttribute dbAttribute)
dbAttribute
parameter. Returns null if no such attribute is found.
public Collection<String> getPrimaryKeyNames()
public ObjRelationship getRelationshipForDbRelationship(DbRelationship dbRelationship)
dbRelationship
parameter. Returns null if no such relationship is found.
public void clearDbMapping()
public boolean isReadOnly()
true
if this ObjEntity represents a set of read-only objects.
public void setReadOnly(boolean readOnly)
public boolean isSubentityOf(ObjEntity entity)
public PathComponent<ObjAttribute,ObjRelationship> lastPathComponent(Expression path, Map aliasMap)
Entity
lastPathComponent
in class Entity
public Iterable<PathComponent<ObjAttribute,ObjRelationship>> resolvePath(Expression pathExp, Map aliasMap)
resolvePath
in class Entity
public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionException
Entity
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.
resolvePathComponents
in class Entity
ExpressionException
public Expression translateToDbPath(Expression expression)
public Expression translateToRelatedEntity(Expression expression, String relationshipPath)
translateToRelatedEntity
in class Entity
public String getDbEntityName()
public void setDbEntityName(String string)
public void objEntityChanged(EntityEvent e)
objEntityChanged
in interface ObjEntityListener
public void objEntityAdded(EntityEvent e)
objEntityAdded
in interface ObjEntityListener
public void objEntityRemoved(EntityEvent e)
objEntityRemoved
in interface ObjEntityListener
@Deprecated public void objAttributeChanged(AttributeEvent e)
@Deprecated public void objAttributeAdded(AttributeEvent e)
@Deprecated public void objAttributeRemoved(AttributeEvent e)
@Deprecated public void objRelationshipChanged(RelationshipEvent e)
@Deprecated public void objRelationshipAdded(RelationshipEvent e)
@Deprecated public void objRelationshipRemoved(RelationshipEvent e)
public boolean isExcludingDefaultListeners()
public void setExcludingDefaultListeners(boolean excludingDefaultListeners)
public boolean isExcludingSuperclassListeners()
public void setExcludingSuperclassListeners(boolean excludingSuperclassListeners)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |