Holger's Java API

## com.antelmann.db
Class DefaultEntryRelationship

    java.lang.Object
      com.antelmann.db.AbstractDBEntry
          com.antelmann.db.DefaultEntryRelationship

All Implemented Interfaces:
  DBEntry, EntryRelationship, LifeCycleObject, Serializable

Direct Known Subclasses:
  DefaultSpecialRelationship

    public class DefaultEntryRelationship

extends AbstractDBEntry
implements EntryRelationship

a default implementation for an EntryRelationship

Since:
  12.09.2008, 22:23:23
Author:
  Holger Antelmann
See Also:
  Serialized Form

Field Summary

Fields inherited from interface com.antelmann.db.DBEntry
`ENTRY_FLAVOR, ENTRY_LIST_FLAVOR`

Constructor Summary
`DefaultEntryRelationship(Object id, DBReference fromReference, DBReference toReference, Object type)`
`DefaultEntryRelationship(Object id, DBReference fromReference, DBReference toReference, Object type, boolean bidirectional)`
`DefaultEntryRelationship(Object id, EntryRelationship er)` subclasses are strongly encouraged to provide a constructor with this same signature

Method Summary
`Date` `getBeginTime()`
`String` `getComment()` specifies a comment for this relationship
`Date` `getEndTime()`
`DBReference` `getFromReference()` represents the first entry of this relationship
`String` `getFromReferenceString()`
`Object` `getRelationOption()` optionally allows to specify an option along with this relationship
`Object` `getRelationType()` defines the kind of relationship
`EntryRelationship` `getReverseRelationship()` if this relationship is bidirectional, the reversed relationship (swapped to-/from references) is returned with the same ID as this one; otherwise null is returned.
`DBReference` `getToReference()` represents the second entry of this relationship
`String` `getToReferenceString()`
`boolean` `isBidirectional()` determines whether this relationship also applies when swapping to- and fromReference
`boolean` `isBroken(Database<?> db)` a relationship is NOT broken only if the following applies for both, the from-reference and the to-reference: there is a store in the database for the specified type there exists an entry with the id of the reference in the store
`boolean` `sameAs(EntryRelationship rel, boolean allFields)` if allFields is false, only the references and the type are checked
`void` `setBeginTime(Date beginTime)`
`void` `setComment(String comment)`
`void` `setEndTime(Date endTime)`
`void` `setRelationOption(Object option)`
`String` `toString()`

Methods inherited from class com.antelmann.db.AbstractDBEntry
`equals, getID, hashCode, hashEntry, sameEntry`

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

Methods inherited from interface com.antelmann.db.DBEntry
`getID`

Constructor Detail

### DefaultEntryRelationship

    public DefaultEntryRelationship(Object id,
                                    EntryRelationship er)
                             throws IllegalArgumentException

  subclasses are strongly encouraged to provide a constructor with this same signature

  Throws:
    `IllegalArgumentException`

### DefaultEntryRelationship

    public DefaultEntryRelationship(Object id,
                                    DBReference fromReference,
                                    DBReference toReference,
                                    Object type)

### DefaultEntryRelationship

    public DefaultEntryRelationship(Object id,
                                    DBReference fromReference,
                                    DBReference toReference,
                                    Object type,
                                    boolean bidirectional)

Method Detail

### isBroken

    public boolean isBroken(Database<?> db)
                     throws DatabaseException

  a relationship is NOT broken only if the following applies for both, the from-reference and the to-reference:
  - there is a store in the database for the specified type
  - there exists an entry with the id of the reference in the store

  Parameters:
    `db` - the database where the references need to be resolved
  Returns:
    true only if both, to- and from-reference can be resolved within the given database
  Throws:
    `DatabaseException` - if

### sameAs

    public boolean sameAs(EntryRelationship rel,
                          boolean allFields)

  if allFields is false, only the references and the type are checked

### getReverseRelationship

    public EntryRelationship getReverseRelationship()

  if this relationship is bidirectional, the reversed relationship (swapped to-/from references) is returned with the same ID as this one; otherwise null is returned.

### toString

    public String toString()

  Overrides:
    `toString` in class `AbstractDBEntry`

### isBidirectional

    public boolean isBidirectional()

  Description copied from interface: `EntryRelationship`
  determines whether this relationship also applies when swapping to- and fromReference

  Specified by:
    `isBidirectional` in interface `EntryRelationship`

### setComment

    public void setComment(String comment)

### getComment

    public String getComment()

  Description copied from interface: `EntryRelationship`
  specifies a comment for this relationship

  Specified by:
    `getComment` in interface `EntryRelationship`

### getFromReference

    public DBReference getFromReference()

  Description copied from interface: `EntryRelationship`
  represents the first entry of this relationship

  Specified by:
    `getFromReference` in interface `EntryRelationship`

### getFromReferenceString

    public String getFromReferenceString()

### getRelationType

    public Object getRelationType()

  Description copied from interface: `EntryRelationship`
  defines the kind of relationship

  Specified by:
    `getRelationType` in interface `EntryRelationship`

### getToReference

    public DBReference getToReference()

  Description copied from interface: `EntryRelationship`
  represents the second entry of this relationship

  Specified by:
    `getToReference` in interface `EntryRelationship`

### getToReferenceString

    public String getToReferenceString()

### getRelationOption

    public Object getRelationOption()

  Description copied from interface: `EntryRelationship`
  optionally allows to specify an option along with this relationship

  Specified by:
    `getRelationOption` in interface `EntryRelationship`

### setRelationOption

    public void setRelationOption(Object option)
                           throws IllegalArgumentException,
                                  UnsupportedOperationException

  Throws:
    `IllegalArgumentException`
    `UnsupportedOperationException`

### getBeginTime

    public Date getBeginTime()

  Specified by:
    `getBeginTime` in interface `LifeCycleObject`

### setBeginTime

    public void setBeginTime(Date beginTime)

### getEndTime

    public Date getEndTime()

  Specified by:
    `getEndTime` in interface `LifeCycleObject`

### setEndTime

    public void setEndTime(Date endTime)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads