org.apache.cayenne.map
Class Relationship

java.lang.Object
  extended by org.apache.cayenne.map.Relationship
All Implemented Interfaces:
java.io.Serializable, CayenneMapEntry, XMLSerializable
Direct Known Subclasses:
DbRelationship, ObjRelationship

public abstract class Relationship
extends java.lang.Object
implements CayenneMapEntry, XMLSerializable, java.io.Serializable

Defines a relationship between two entities. In a DataMap graph relationships represent "arcs" connecting entity "nodes". Relationships are directional, i.e. they have a notion of source and target entity. This makes DataMap a "digraph".

See Also:
Serialized Form

Field Summary
protected  java.lang.String name
           
protected  Entity sourceEntity
           
protected  java.lang.String targetEntityName
           
protected  boolean toMany
           
 
Constructor Summary
Relationship()
          Creates an unnamed relationship.
Relationship(java.lang.String name)
          Creates a named relationship.
 
Method Summary
 java.lang.String getName()
          Returns the name property of this object.
 java.lang.Object getParent()
          Returns the parent map.
 Entity getSourceEntity()
          Returns relationship source entity.
abstract  Entity getTargetEntity()
          Returns a target entity of the relationship.
 java.lang.String getTargetEntityName()
          Returns the name of a target entity.
 boolean isToMany()
          Returns a boolean value that determines relationship multiplicity.
 void setName(java.lang.String name)
           
 void setParent(java.lang.Object parent)
          Stores the parent map.
 void setSourceEntity(Entity sourceEntity)
          Sets relationship source entity.
 void setTargetEntity(Entity targetEntity)
          Sets relationship target entity.
 void setTargetEntityName(java.lang.String targetEntityName)
          Sets the name of relationship target entity.
 java.lang.String toString()
          Overrides Object.toString() to return informative description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cayenne.util.XMLSerializable
encodeAsXML
 

Field Detail

name

protected java.lang.String name

sourceEntity

protected Entity sourceEntity

targetEntityName

protected java.lang.String targetEntityName

toMany

protected boolean toMany
Constructor Detail

Relationship

public Relationship()
Creates an unnamed relationship.


Relationship

public Relationship(java.lang.String name)
Creates a named relationship.

Method Detail

getName

public java.lang.String getName()
Description copied from interface: CayenneMapEntry
Returns the name property of this object.

Specified by:
getName in interface CayenneMapEntry
Returns:
name of this entry.

setName

public void setName(java.lang.String name)

getSourceEntity

public Entity getSourceEntity()
Returns relationship source entity.


setSourceEntity

public void setSourceEntity(Entity sourceEntity)
Sets relationship source entity.


getTargetEntity

public abstract Entity getTargetEntity()
Returns a target entity of the relationship.


setTargetEntity

public void setTargetEntity(Entity targetEntity)
Sets relationship target entity. Internally calls setTargetEntityName.


getTargetEntityName

public java.lang.String getTargetEntityName()
Returns the name of a target entity.


setTargetEntityName

public void setTargetEntityName(java.lang.String targetEntityName)
Sets the name of relationship target entity.


isToMany

public boolean isToMany()
Returns a boolean value that determines relationship multiplicity. This defines semantics of the connection between two nodes described by the source and target entities. E.g. to-many relationship between two Persistent object classes means that a source object would have a collection of target objects. This is a read-only property.


getParent

public java.lang.Object getParent()
Description copied from interface: CayenneMapEntry
Returns the parent map.

Specified by:
getParent in interface CayenneMapEntry

setParent

public void setParent(java.lang.Object parent)
Description copied from interface: CayenneMapEntry
Stores the parent map.

Specified by:
setParent in interface CayenneMapEntry

toString

public java.lang.String toString()
Overrides Object.toString() to return informative description.

Overrides:
toString in class java.lang.Object


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