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.map
Class Entity

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

All Implemented Interfaces:
  java.io.Serializable, CayenneMapEntry, XMLSerializable

Direct Known Subclasses:
  DbEntity, ObjEntity

    public abstract class Entity

extends java.lang.Object
implements CayenneMapEntry, XMLSerializable, java.io.Serializable

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

See Also:
  Serialized Form

Field Summary
`protected java.util.SortedMap<java.lang.String,Attribute>` | `attributes`
`protected DataMap` | `dataMap`
`protected java.lang.String` | `name`
`static java.lang.String` | `OUTER_JOIN_INDICATOR` A prefix or a suffix that can be used in a path component to indicate that an OUTER JOIN should be used when resolving the expression.
`static java.lang.String` | `PATH_SEPARATOR`
`protected java.util.SortedMap<java.lang.String,Relationship>` | `relationships`

Constructor Summary
`Entity()` Creates an unnamed Entity.
`Entity(java.lang.String name)` Creates a named Entity.

Method Summary
`void` | `addAttribute(Attribute attribute)` Adds new attribute to the entity, setting its parent entity to be this object.
`void` | `addRelationship(Relationship relationship)` Adds new relationship to the entity.
`void` | `clearAttributes()`
`void` | `clearRelationships()`
`Relationship` | `getAnyRelationship(Entity targetEntity)` Returns a relationship that has a specified entity as a target.
`Attribute` | `getAttribute(java.lang.String attributeName)` Returns attribute with name `attributeName` or null if no attribute with this name exists.
`java.util.SortedMap<java.lang.String,? extends Attribute>` | `getAttributeMap()` Returns an unmodifiable sorted map of entity attributes.
`java.util.Collection<? extends Attribute>` | `getAttributes()` Returns an unmodifiable collection of entity attributes.
`DataMap` | `getDataMap()`
`java.lang.String` | `getName()` Returns entity name.
`java.lang.Object` | `getParent()` Returns the parent map.
`Relationship` | `getRelationship(java.lang.String relName)` Returns relationship with name `relName`.
`java.util.SortedMap<java.lang.String,? extends Relationship>` | `getRelationshipMap()` Returns an unmodifiable map of relationships sorted by name.
`java.util.Collection<? extends Relationship>` | `getRelationships()` Returns an unmodifiable collection of Relationships that exist in this entity.
`
`<T extends Attribute,U extends Relationship> PathComponent<T,U>`
` | `lastPathComponent(Expression path, java.util.Map aliasMap)` Convenience method returning the last component in the path iterator.
`void` | `removeAttribute(java.lang.String attrName)` Removes an attribute named `attrName`.
`void` | `removeRelationship(java.lang.String relName)` Removes a relationship named `attrName`.
`abstract
`<T extends Attribute,U extends Relationship> java.lang.Iterable<PathComponent<T,U>>`
` | `resolvePath(Expression pathExp, java.util.Map aliasMap)` Returns an Iterable over the path components with elements represented as `PathComponent` instances, encapsulating a relationship, an attribute or a subpath alias.
`abstract java.util.Iterator<CayenneMapEntry>` | `resolvePathComponents(Expression pathExp)` Processes expression `pathExp` and returns an Iterator of path components that contains a sequence of Attributes and Relationships.
`java.util.Iterator<CayenneMapEntry>` | `resolvePathComponents(java.lang.String path)` Returns an Iterator over the path components that contains a sequence of Attributes and Relationships.
`void` | `setDataMap(DataMap dataMap)` Sets parent DataMap of this entity.
`void` | `setName(java.lang.String name)`
`void` | `setParent(java.lang.Object parent)` Stores the parent map.
`java.lang.String` | `toString()`
`abstract Expression` | `translateToRelatedEntity(Expression expression, java.lang.String relationshipPath)` Translates Expression rooted in this entity to an analogous expression rooted in related entity.

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

### PATH_SEPARATOR

    public static final java.lang.String PATH_SEPARATOR

See Also:
  Constant Field Values

### OUTER_JOIN_INDICATOR

    public static final java.lang.String OUTER_JOIN_INDICATOR

  A prefix or a suffix that can be used in a path component to indicate that an OUTER JOIN should be used when resolving the expression.

  Since:
    3.0
  See Also:
    Constant Field Values

### name

    protected java.lang.String name

### dataMap

    protected DataMap dataMap

### attributes

    protected java.util.SortedMap<java.lang.String,Attribute> attributes

### relationships

    protected java.util.SortedMap<java.lang.String,Relationship> relationships

Constructor Detail

### Entity

    public Entity()

  Creates an unnamed Entity.

### Entity

    public Entity(java.lang.String name)

  Creates a named Entity.

Method Detail

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getName

    public java.lang.String getName()

  Returns entity name. Name is a unique identifier of the entity within its DataMap.

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

### setName

    public void setName(java.lang.String name)

### 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`

### getDataMap

    public DataMap getDataMap()

  Returns:
    parent DataMap of this entity.

### setDataMap

    public void setDataMap(DataMap dataMap)

  Sets parent DataMap of this entity.

### getAttribute

    public Attribute getAttribute(java.lang.String attributeName)

  Returns attribute with name `attributeName` or null if no attribute with this name exists.

### addAttribute

    public void addAttribute(Attribute attribute)

  Adds new attribute to the entity, setting its parent entity to be this object. If attribute has no name, IllegalArgumentException is thrown.

### 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 relationship)

  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.SortedMap<java.lang.String,? extends Relationship> getRelationshipMap()

  Returns an unmodifiable map of relationships sorted by name.

### getAnyRelationship

    public Relationship getAnyRelationship(Entity targetEntity)

  Returns a relationship that has a specified entity as a target. If there is more than one relationship for the same target, it is unpredictable which one will be returned.

  Since:
    1.1

### getRelationships

    public java.util.Collection<? extends Relationship> getRelationships()

  Returns an unmodifiable collection of Relationships that exist in this entity.

### getAttributeMap

    public java.util.SortedMap<java.lang.String,? extends Attribute> getAttributeMap()

  Returns an unmodifiable sorted map of entity attributes.

### getAttributes

    public java.util.Collection<? extends Attribute> getAttributes()

  Returns an unmodifiable collection of entity attributes.

### translateToRelatedEntity

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

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

  Since:
    1.1

### lastPathComponent

    public <T extends Attribute,U extends Relationship> PathComponent<T,U> lastPathComponent(Expression path,
                                                                                             java.util.Map aliasMap)

  Convenience method returning the last component in the path iterator. If the last component is an alias, it is fully resolved down to the last ObjRelationship.

  Since:
    3.0

### resolvePath

    public abstract <T extends Attribute,U extends Relationship> java.lang.Iterable<PathComponent<T,U>> resolvePath(Expression pathExp,
                                                                                                                    java.util.Map aliasMap)

  Returns an Iterable over the path components with elements represented as `PathComponent` instances, encapsulating a relationship, an attribute or a subpath alias. An optional "aliasMap" parameter is used to resolve subpaths from aliases.

  This method is lazy: 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.

  Since:
    3.0

### resolvePathComponents

    public abstract java.util.Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp)
                                                                       throws ExpressionException

  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.

  Throws:
    `ExpressionException`

### resolvePathComponents

    public java.util.Iterator<CayenneMapEntry> resolvePathComponents(java.lang.String path)
                                                              throws ExpressionException

  Returns an Iterator over the 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.

  Throws:
    `ExpressionException`

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-2011 Apache Cayenne. All Rights Reserved.