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

Quick Search    Search Deep

org.objectstyle.cayenne.map
Class Entity  view Entity download Entity.java

java.lang.Object
  extended byorg.objectstyle.cayenne.map.MapObject
      extended byorg.objectstyle.cayenne.map.Entity
All Implemented Interfaces:
org.objectstyle.cayenne.util.CayenneMapEntry
Direct Known Subclasses:
DbEntity, ObjEntity

public abstract class Entity
extends MapObject

An Entity is an abstract descriptor for an entity mapping concept. Entity can represent either a descriptor of database table or a persistent object.


Nested Class Summary
protected  class Entity.PathIterator
           
 
Field Summary
protected  org.objectstyle.cayenne.util.CayenneMap attributes
           
protected  java.util.Map attributesMapRef
           
protected  java.util.Collection attributesRef
           
static java.lang.String PATH_SEPARATOR
           
protected  org.objectstyle.cayenne.util.CayenneMap queries
           
protected  org.objectstyle.cayenne.util.CayenneMap relationships
           
protected  java.util.Collection relationshipsRef
           
 
Fields inherited from class org.objectstyle.cayenne.map.MapObject
objName, objParent
 
Constructor Summary
Entity()
           
 
Method Summary
 void addAttribute(Attribute attr)
          Adds new attribute to the entity.
 void addQuery(java.lang.String queryName, org.objectstyle.cayenne.query.SelectQuery query)
          Creates a named association of a SelectQuery with this entity.
 void addRelationship(Relationship rel)
          Adds new relationship to the entity.
 void clearAttributes()
           
 void clearQueries()
           
 void clearRelationships()
           
 Attribute getAttribute(java.lang.String attrName)
          Returns attribute with name attrName.
 java.util.Map getAttributeMap()
          Returns entity attributes as an unmodifiable map.
 java.util.Collection getAttributes()
          Returns entity attributes.
 DataMap getDataMap()
           
 org.objectstyle.cayenne.query.SelectQuery getQuery(java.lang.String queryName)
          Returns a named query associated with this entity.
 Relationship getRelationship(java.lang.String relName)
          Returns relationship with name relName.
 java.util.Map getRelationshipMap()
           
 java.util.Collection getRelationships()
          Returns a collection of Relationships that exist in this entity.
 void removeAttribute(java.lang.String attrName)
          Removes an attribute named attrName.
 void removeQuery(java.lang.String queryName)
          Removes a named query from this Entity.
 void removeRelationship(java.lang.String relName)
          Removes a relationship named attrName.
 java.util.Iterator resolvePathComponents(org.objectstyle.cayenne.exp.Expression pathExp)
          Processes expression objPathExp and returns an Iterator of path components that contains a sequence of Attributes and Relationships.
 java.util.Iterator resolvePathComponents(java.lang.String path)
           
 void setDataMap(DataMap dataMap)
          Sets parent DataMap of this entity.
protected abstract  void validateQueryRoot(org.objectstyle.cayenne.query.Query query)
          Helper method that checks that a Query belongs to this entity by validating query root object.
 
Methods inherited from class org.objectstyle.cayenne.map.MapObject
getName, getParent, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final java.lang.String PATH_SEPARATOR
See Also:
Constant Field Values

attributes

protected org.objectstyle.cayenne.util.CayenneMap attributes

attributesMapRef

protected java.util.Map attributesMapRef

attributesRef

protected java.util.Collection attributesRef

relationships

protected org.objectstyle.cayenne.util.CayenneMap relationships

relationshipsRef

protected java.util.Collection relationshipsRef

queries

protected org.objectstyle.cayenne.util.CayenneMap queries
Constructor Detail

Entity

public Entity()
Method Detail

getDataMap

public DataMap getDataMap()

setDataMap

public void setDataMap(DataMap dataMap)
Sets parent DataMap of this entity.


getQuery

public org.objectstyle.cayenne.query.SelectQuery getQuery(java.lang.String queryName)
Returns a named query associated with this entity.


addQuery

public void addQuery(java.lang.String queryName,
                     org.objectstyle.cayenne.query.SelectQuery query)
Creates a named association of a SelectQuery with this entity. Throws IllegalArgumentException if query root can not be resolved to this entity.


removeQuery

public void removeQuery(java.lang.String queryName)
Removes a named query from this Entity.


clearQueries

public void clearQueries()

validateQueryRoot

protected abstract void validateQueryRoot(org.objectstyle.cayenne.query.Query query)
                                   throws java.lang.IllegalArgumentException
Helper method that checks that a Query belongs to this entity by validating query root object.


getAttribute

public Attribute getAttribute(java.lang.String attrName)
Returns attribute with name attrName. Will return null if no attribute with this name exists.


addAttribute

public void addAttribute(Attribute attr)
Adds new attribute to the entity. If attribute has no name, IllegalArgumentException is thrown. Also sets attr's entity to be this entity.


removeAttribute

public void removeAttribute(java.lang.String attrName)
Removes an attribute named attrName.


clearAttributes

public void clearAttributes()

getRelationship

public Relationship getRelationship(java.lang.String relName)
Returns relationship with name relName. Will return null if no relationship with this name exists in the entity.


addRelationship

public void addRelationship(Relationship rel)
Adds new relationship to the entity.


removeRelationship

public void removeRelationship(java.lang.String relName)
Removes a relationship named attrName.


clearRelationships

public void clearRelationships()

getRelationshipMap

public java.util.Map getRelationshipMap()

getRelationships

public java.util.Collection getRelationships()
Returns a collection of Relationships that exist in this entity.


getAttributeMap

public java.util.Map getAttributeMap()
Returns entity attributes as an unmodifiable map.


getAttributes

public java.util.Collection getAttributes()
Returns entity attributes.


resolvePathComponents

public java.util.Iterator resolvePathComponents(org.objectstyle.cayenne.exp.Expression pathExp)
                                         throws org.objectstyle.cayenne.exp.ExpressionException
Processes expression objPathExp 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

public java.util.Iterator resolvePathComponents(java.lang.String path)
                                         throws org.objectstyle.cayenne.exp.ExpressionException