org.opencms.relations
Class CmsRelation

java.lang.Object
  extended by org.opencms.relations.CmsRelation

public class CmsRelation
extends java.lang.Object

A relation between two opencms resources.

Since:
6.3.0
Version:
$Revision: 1.8 $
Author:
Michael Moossen

Field Summary
static java.util.Comparator COMPARATOR
          A comparator for the source & target path plus the relation type of 2 relations.
 
Constructor Summary
CmsRelation(CmsResource source, CmsResource target, CmsRelationType type)
          Creates a new relation object of the given type between the given resources.
CmsRelation(CmsUUID sourceId, java.lang.String sourcePath, CmsUUID targetId, java.lang.String targetPath, CmsRelationType type)
          Base constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 CmsResource getSource(CmsObject cms, CmsResourceFilter filter)
          Returns the source resource when possible to read with the given filter.
 CmsUUID getSourceId()
          Returns the structure id of the source resource.
 java.lang.String getSourcePath()
          Returns the path of the source resource.
 CmsResource getTarget(CmsObject cms, CmsResourceFilter filter)
          Returns the target resource when possible to read with the given filter.
 CmsUUID getTargetId()
          Returns the structure id of the target resource.
 java.lang.String getTargetPath()
          Returns the path of the target resource.
 CmsRelationType getType()
          Returns the relation type.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPARATOR

public static final java.util.Comparator COMPARATOR
A comparator for the source & target path plus the relation type of 2 relations.

Constructor Detail

CmsRelation

public CmsRelation(CmsResource source,
                   CmsResource target,
                   CmsRelationType type)
Creates a new relation object of the given type between the given resources.

Parameters:
source - the source resource
target - the target resource
type - the relation type

CmsRelation

public CmsRelation(CmsUUID sourceId,
                   java.lang.String sourcePath,
                   CmsUUID targetId,
                   java.lang.String targetPath,
                   CmsRelationType type)
Base constructor.

Parameters:
sourceId - the source structure id
sourcePath - the source path
targetId - the target structure id
targetPath - the target path
type - the relation type
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getSource

public CmsResource getSource(CmsObject cms,
                             CmsResourceFilter filter)
                      throws CmsException
Returns the source resource when possible to read with the given filter.

Parameters:
cms - the current user context
filter - the filter to use
Returns:
the source resource
Throws:
CmsException - if something goes wrong

getSourceId

public CmsUUID getSourceId()
Returns the structure id of the source resource.

Returns:
the structure id of the source resource

getSourcePath

public java.lang.String getSourcePath()
Returns the path of the source resource.

Returns:
the path of the source resource

getTarget

public CmsResource getTarget(CmsObject cms,
                             CmsResourceFilter filter)
                      throws CmsException
Returns the target resource when possible to read with the given filter.

Parameters:
cms - the current user context
filter - the filter to use
Returns:
the target resource
Throws:
CmsException - if something goes wrong

getTargetId

public CmsUUID getTargetId()
Returns the structure id of the target resource.

Returns:
the structure id of the target resource

getTargetPath

public java.lang.String getTargetPath()
Returns the path of the target resource.

Returns:
the path of the target resource

getType

public CmsRelationType getType()
Returns the relation type.

Returns:
the relation type

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()