edu.columbia.cs.ref.model.relationship
Class RelationshipType

java.lang.Object
  extended by edu.columbia.cs.ref.model.relationship.RelationshipType
All Implemented Interfaces:
java.io.Serializable

public class RelationshipType
extends java.lang.Object
implements java.io.Serializable

The Class RelationshipType represents a type of relationship that we are interested in.

The RelationshipType contains more than the label indicating the semantics of the relationship. Namely, a relationship type may also contain some constraints imposed over roles, the relationship itself and the entities that can be matched. These constraints are used to check if, given a RelationshipType, a given relationship is valid.

Since:
2011-09-27
Version:
0.1
Author:
Pablo Barrio, Goncalo Simoes
See Also:
Serialized Form

Field Summary
static java.lang.String NOT_A_RELATIONSHIP
          The Constant NOT_A_RELATIONSHIP.
 
Constructor Summary
RelationshipType(java.lang.String type, java.lang.String... roles)
          Instantiates a new relationship type.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 RoleConstraint getConstraint(java.lang.String role)
          Gets the constraint imposed over some role
 int getIndex(java.lang.String role)
          Gets the index of the role in a vector representation of a relationship.
 EntityMatcher getMatchers(java.lang.String role)
          Gets the entity matcher for a given role
 int getNumberEntities()
          Gets the number of entities involved in this relationship type.
 RelationshipConstraint getRelationshipConstraint()
          Gets the relationship constraint for this relationship type.
 java.util.Set<java.lang.String> getRoles()
          Gets the roles used in this relationship type.
 java.lang.String getType()
          Gets the label of the relationships.
 int hashCode()
           
 boolean isType(java.lang.String relType)
          Checks if the type of relationship is the same as a given string.
 void setConstraints(RelationshipConstraint constraint)
          Sets the relationship constraint for this relationship type.
 void setConstraints(RoleConstraint constraint, java.lang.String role)
          Sets the constraint imposed over some role
 void setMatchers(EntityMatcher matcher, java.lang.String role)
          Sets the entity matcher for a given role
 void setType(java.lang.String type)
          Sets the label of the relationships.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_A_RELATIONSHIP

public static final java.lang.String NOT_A_RELATIONSHIP
The Constant NOT_A_RELATIONSHIP.

See Also:
Constant Field Values
Constructor Detail

RelationshipType

public RelationshipType(java.lang.String type,
                        java.lang.String... roles)
Instantiates a new relationship type. The relationship type is created by providing a String which is an indication of the semantics of the relationship and zero or more roles involved in this relationship type

Parameters:
type - the type
roles - the roles
Method Detail

getIndex

public int getIndex(java.lang.String role)
Gets the index of the role in a vector representation of a relationship.

Parameters:
role - the role for which we want to check the index
Returns:
the index of the role in a vector representation of a relationship

setType

public void setType(java.lang.String type)
Sets the label of the relationships.

Parameters:
type - the new label of the relationships

getType

public java.lang.String getType()
Gets the label of the relationships.

Returns:
the label of the relationships

getNumberEntities

public int getNumberEntities()
Gets the number of entities involved in this relationship type.

Returns:
the number of entities involved in this relationship type

getRoles

public java.util.Set<java.lang.String> getRoles()
Gets the roles used in this relationship type.

Returns:
the roles used in this relationship type

isType

public boolean isType(java.lang.String relType)
Checks if the type of relationship is the same as a given string.

Parameters:
relType - the relationship type label
Returns:
true, if the label of the relationship type is the input of this method

setConstraints

public void setConstraints(RoleConstraint constraint,
                           java.lang.String role)
Sets the constraint imposed over some role

Parameters:
constraint - the constraint
role - the role

getConstraint

public RoleConstraint getConstraint(java.lang.String role)
Gets the constraint imposed over some role

Parameters:
role - the role
Returns:
the constraint

setMatchers

public void setMatchers(EntityMatcher matcher,
                        java.lang.String role)
Sets the entity matcher for a given role

Parameters:
matcher - the matcher
role - the role

getMatchers

public EntityMatcher getMatchers(java.lang.String role)
Gets the entity matcher for a given role

Parameters:
role - the role
Returns:
the matchers

setConstraints

public void setConstraints(RelationshipConstraint constraint)
Sets the relationship constraint for this relationship type.

Parameters:
constraint - the new constraints

getRelationshipConstraint

public RelationshipConstraint getRelationshipConstraint()
Gets the relationship constraint for this relationship type.

Returns:
the relationship constraint for this relationship type

hashCode

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

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object