SemanticNetwork
Class RelationshipInstance

java.lang.Object
  |
  +--SemanticNetwork.RelationshipInstance

public class RelationshipInstance
extends java.lang.Object

Defines a relationship to be associated with a concept instance to specify spatial relations.

Version:
Created 25 August 2003
Author:
Dan Tappan

Field Summary
private  boolean m_is_inferred
           
private  java.util.ArrayList m_referent_concept_nodes
           
private  java.lang.String m_relation_name
           
private  SemanticNetwork m_semantic_network
           
private  java.lang.String m_source_label
           
private  java.util.ArrayList m_target_labels
           
 
Constructor Summary
RelationshipInstance(java.lang.String relation_name, java.lang.String source_label, java.util.ArrayList target_labels, boolean is_inferred)
          Creates a new instance of an relationship instance to be added to a semantic network, thereby associating it with a concept instance.
RelationshipInstance(java.lang.String source_label, java.lang.String relation_name, java.lang.String target_label)
          Creates a new instance of an relationship instance to be added to a semantic network, thereby associating it with a concept instance.
 
Method Summary
 RelationshipInstance getClone()
          Returns a mixed clone of this relationship instance.
 java.util.ArrayList getReferentConceptNodes()
          Returns the referent concept nodes that many knowledge-base methods require to evaluate contexts based on which other concept nodes play a role in this relationship.
 java.lang.String getRelationName()
          Returns the relation name of this relationship instance as specified in the knowledge base.
 java.lang.String getSourceLabel()
          Returns the unique label of the concept instance that roots this relationship instance.
 java.util.ArrayList getTargetLabels()
          Returns the labels of the concept instances to which this relationship instance is directed.
 boolean hasAsTargetLabel(java.lang.String target_label)
          Returns whether the given label is in the set of labels of the concept instances to which this relationship instance is directed.
 boolean isInferred()
          Returns whether this relationship instance is inferred.
private  void relink()
          Builds or updates the referent concept nodes that many knowledge-base methods require to evaluate contexts based on which other concept nodes play a role in this relationship.
 java.lang.String serialize()
          Returns a serialized representation of this relationship instance.
protected  void setSemanticNetwork(SemanticNetwork semantic_network)
          Sets the semantic network this relationship instance was added to.
 java.lang.String toString()
          Returns a string representation of this object.
protected  void validate()
          Verifies that all concept instances this relationship instance is directed to are present in the semantic network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_relation_name

private java.lang.String m_relation_name

m_source_label

private java.lang.String m_source_label

m_target_labels

private java.util.ArrayList m_target_labels

m_is_inferred

private boolean m_is_inferred

m_semantic_network

private SemanticNetwork m_semantic_network

m_referent_concept_nodes

private java.util.ArrayList m_referent_concept_nodes
Constructor Detail

RelationshipInstance

public RelationshipInstance(java.lang.String relation_name,
                            java.lang.String source_label,
                            java.util.ArrayList target_labels,
                            boolean is_inferred)
Creates a new instance of an relationship instance to be added to a semantic network, thereby associating it with a concept instance.

Parameters:
relation_name - - the relation name as specified in the knowledge base
source_label - - the label of the concept instance from which this relationship instance originates
target_labels - - the labels of the concept instances to which this relationship is directed. Since only binary relations are currently supported, this list must contain only one element
is_inferred - - whether this relationship instance is inferred
See Also:
ConceptInstance, SemanticNetwork.addRelationshipInstance(SemanticNetwork.RelationshipInstance)

RelationshipInstance

public RelationshipInstance(java.lang.String source_label,
                            java.lang.String relation_name,
                            java.lang.String target_label)
Creates a new instance of an relationship instance to be added to a semantic network, thereby associating it with a concept instance. This is the preferred constructor for testing because it has a simple and intuitive signature.

Parameters:
source_label - - the label of the concept instance from which this relationship instance originates
relation_name - - the relation name as specified in the knowledge base
target_label - - the label of the concept instance to which this relationship is directed
See Also:
ConceptInstance, SemanticNetwork.addRelationshipInstance(SemanticNetwork.RelationshipInstance)
Method Detail

getClone

public RelationshipInstance getClone()
Returns a mixed clone of this relationship instance. Target labels are copied by reference, and all other fields by value.

Returns:
the clone

getReferentConceptNodes

public java.util.ArrayList getReferentConceptNodes()
Returns the referent concept nodes that many knowledge-base methods require to evaluate contexts based on which other concept nodes play a role in this relationship. Contrast this with ConceptInstance.getAllReferentConceptNodes(), which does the same for all relations in a concept instance.

Returns:
the referent concept nodes in this relationship
See Also:
ConceptNode.getAttributeIntervalNodes(java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance), ConceptNode.getConstraintNodes(java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance), ConceptNode.getFieldNodes(java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance), ConceptNode.getInferenceNodes(java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance, boolean, Reasoner.ObjectInference, Reasoner.ObjectInference), ConceptNode.getPropertyNodes(java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance), ConceptNode.getRelationNodes(java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance), ConceptNode.inheritFieldOrRelationOrPropertyOrAttributeInterval(int, java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance), ConceptNode.inheritInferencesOrConstraints(int, java.lang.String, java.util.ArrayList, SemanticNetwork.ConceptInstance, boolean, Reasoner.ObjectInference, Reasoner.ObjectInference), ConceptInstance.getAllReferentConceptNodes()

getRelationName

public java.lang.String getRelationName()
Returns the relation name of this relationship instance as specified in the knowledge base.

Returns:
the relation name

getSourceLabel

public java.lang.String getSourceLabel()
Returns the unique label of the concept instance that roots this relationship instance.

Returns:
the source label

getTargetLabels

public java.util.ArrayList getTargetLabels()
Returns the labels of the concept instances to which this relationship instance is directed.

Returns:
a list of labels

hasAsTargetLabel

public boolean hasAsTargetLabel(java.lang.String target_label)
Returns whether the given label is in the set of labels of the concept instances to which this relationship instance is directed.

Parameters:
target_label - - the target label
Returns:
the outcome

isInferred

public boolean isInferred()
Returns whether this relationship instance is inferred.

Returns:
the infer state

relink

private void relink()
Builds or updates the referent concept nodes that many knowledge-base methods require to evaluate contexts based on which other concept nodes play a role in this relationship.

See Also:
getReferentConceptNodes()

serialize

public java.lang.String serialize()
Returns a serialized representation of this relationship instance.

Returns:
the serialization

setSemanticNetwork

protected void setSemanticNetwork(SemanticNetwork semantic_network)
Sets the semantic network this relationship instance was added to.

Parameters:
semantic_network - - the semantic network

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String)

validate

protected void validate()
                 throws java.lang.Exception
Verifies that all concept instances this relationship instance is directed to are present in the semantic network.

It also builds or updates the links from this relationship instance to the knowledge base.

Throws:
java.lang.Exception - - if the relationship instance does not satisfy the requirements
See Also:
SemanticNetwork.validate()