story.dbcore.links
Class LinkRepository

java.lang.Object
  extended by story.dbcore.links.LinkRepository

public class LinkRepository
extends java.lang.Object

This class is the root of the class hierarchy for the storage and management of links between nodes.

Note: this is only meant to be instantiated within a Document and other methods are only to be called from the Document. If you want to manage links, do it through the DBCoreInterface.


Constructor Summary
LinkRepository(Document parentDocument, LinkProperties linkProperties)
          Constructor.
 
Method Summary
 LinkLabelAddress addLink(GenericNode from, LinkType linkType, GenericNode to, LinkLabel label)
          Associate two nodes with a link.
 LinkLabelAddress addLinkWithExtantLabel(GenericNode from, LinkType linkType, GenericNode to, LinkLabelAddress labelAddress)
          Associate two nodes with a link and annotate it with a label already in the system.
 boolean areRelatedDirectly(GenericNode from, LinkType linkType, GenericNode to)
           
 boolean areRelatedIndirectly(GenericNode from, LinkType linkType, GenericNode to)
           
 LinkLabelAddress findLinkLabelAddress(GenericNode from, LinkType linkType, GenericNode to, LinkLabel label)
          Search to see if two nodes are linked by a LinkLabel equivalent to a given one and, if so, return the address of the matching LinkLabel.
 LinkProperties getLinkProperties()
           
 RelatedNodes getLinksFromNode(GenericNode from, LinkType linkType)
          Get a RelatedNodes of nodes and labels that occur on the right side of a given link from a given node.
 RelatedNodes getLinksOfNode(GenericNode node, LinkType linkType, LinkDirection direction)
          Get a RelatedNodes of nodes and labels that occur on a given side of a given link to a given node.
 RelatedNodes getLinksOfNode(NodeAddress node, LinkType linkType, LinkDirection direction)
          Version of getLinksOfNode that accepts a NodeAddress and will have the Document find the GenericNode.
 RelatedNodes getLinksToNode(GenericNode to, LinkType linkType)
          Get a RelatedNodes of nodes and labels that occur on the left side of a given link to a given node.
 ViaSet getLinkVias(GenericNode from, LinkType linkType, GenericNode to)
          Get the Vias of the links between two nodes.
 CommandReturn isolateNode(GenericNode node, LinkType linkType)
          Remove all links of a certain type to and from a node.
 void removeLink(GenericNode from, LinkType linkType, GenericNode to, LinkLabelAddress labelAddress)
          Remove a particular link between two nodes.
 void removeLinkLabel(LinkLabelAddress labelAddress)
           
 CommandReturn removeLinks(GenericNode from, LinkType linkType, GenericNode to)
          Remove all direct links of a particular type between two nodes.
 void validateLinkInstancings()
          Go through all the links to instancings and make sure this instancings still validate.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkRepository

public LinkRepository(Document parentDocument,
                      LinkProperties linkProperties)
Constructor.

Method Detail

getLinkProperties

public LinkProperties getLinkProperties()

getLinksFromNode

public RelatedNodes getLinksFromNode(GenericNode from,
                                     LinkType linkType)
                              throws Scheherexception
Get a RelatedNodes of nodes and labels that occur on the right side of a given link from a given node.

Parameters:
from - The node on the left side of the relation
linkType - The type of link the nodes will be related as
Throws:
Scheherexception

getLinksToNode

public RelatedNodes getLinksToNode(GenericNode to,
                                   LinkType linkType)
                            throws Scheherexception
Get a RelatedNodes of nodes and labels that occur on the left side of a given link to a given node.

Parameters:
to - The node on the right side of the relation
linkType - The type of link the nodes will be related as
Throws:
Scheherexception

getLinksOfNode

public RelatedNodes getLinksOfNode(GenericNode node,
                                   LinkType linkType,
                                   LinkDirection direction)
                            throws Scheherexception
Get a RelatedNodes of nodes and labels that occur on a given side of a given link to a given node.

Parameters:
node - The node on the right side of the relation
linkType - The type of link the nodes will be related as
direction - The appropriate LinkDirection: From for nodes that occur on the right side of the given node; To for nodes on the left side.
Throws:
Scheherexception

getLinksOfNode

public RelatedNodes getLinksOfNode(NodeAddress node,
                                   LinkType linkType,
                                   LinkDirection direction)
                            throws Scheherexception
Version of getLinksOfNode that accepts a NodeAddress and will have the Document find the GenericNode.

Throws:
Scheherexception

addLink

public LinkLabelAddress addLink(GenericNode from,
                                LinkType linkType,
                                GenericNode to,
                                LinkLabel label)
                         throws Scheherexception
Associate two nodes with a link.

This function assumes that the two nodes are in themselves valid; i.e., they come from the same Document or whatever restrictions are necessary. (Those checks should be done by the Document calling this function.) This function makes sure the link between them is valid: the types are the required types, single-link rules are observed, etc.

Parameters:
from - The node on the left side of the link.
linkType - The type of link with which to associate the nodes.
to - The node on the right side of the link.
label - The label for the link.
Throws:
Scheherexception - For any error including those listed above.

addLinkWithExtantLabel

public LinkLabelAddress addLinkWithExtantLabel(GenericNode from,
                                               LinkType linkType,
                                               GenericNode to,
                                               LinkLabelAddress labelAddress)
                                        throws Scheherexception
Associate two nodes with a link and annotate it with a label already in the system. Will throw an exception if the label does not actually exist.

Throws:
Scheherexception

removeLink

public void removeLink(GenericNode from,
                       LinkType linkType,
                       GenericNode to,
                       LinkLabelAddress labelAddress)
                throws Scheherexception
Remove a particular link between two nodes.

Parameters:
from - The node on the left side of the link.
linkType - The type of link with which to associate the nodes.
to - The node on the right side of the link.
label - The label of the link to remove.
Throws:
Scheherexception - For any error including those listed above.

removeLinks

public CommandReturn removeLinks(GenericNode from,
                                 LinkType linkType,
                                 GenericNode to)
                          throws Scheherexception
Remove all direct links of a particular type between two nodes.

Parameters:
from - The node on the left side of the link.
linkType - The type of link with which to associate the nodes.
to - The node on the right side of the link.
Throws:
Scheherexception - For any error including those listed above.

findLinkLabelAddress

public LinkLabelAddress findLinkLabelAddress(GenericNode from,
                                             LinkType linkType,
                                             GenericNode to,
                                             LinkLabel label)
                                      throws Scheherexception
Search to see if two nodes are linked by a LinkLabel equivalent to a given one and, if so, return the address of the matching LinkLabel. If not, returns null.

Throws:
Scheherexception

removeLinkLabel

public void removeLinkLabel(LinkLabelAddress labelAddress)
                     throws Scheherexception
Throws:
Scheherexception

isolateNode

public CommandReturn isolateNode(GenericNode node,
                                 LinkType linkType)
                          throws Scheherexception
Remove all links of a certain type to and from a node.

Throws:
Scheherexception

getLinkVias

public ViaSet getLinkVias(GenericNode from,
                          LinkType linkType,
                          GenericNode to)
                   throws Scheherexception
Get the Vias of the links between two nodes.

Throws:
Scheherexception

validateLinkInstancings

public void validateLinkInstancings()
                             throws Scheherexception
Go through all the links to instancings and make sure this instancings still validate.

Throws:
Scheherexception

areRelatedDirectly

public boolean areRelatedDirectly(GenericNode from,
                                  LinkType linkType,
                                  GenericNode to)
                           throws Scheherexception
Throws:
Scheherexception

areRelatedIndirectly

public boolean areRelatedIndirectly(GenericNode from,
                                    LinkType linkType,
                                    GenericNode to)
                             throws Scheherexception
Throws:
Scheherexception


Copyright © 2011 David K. Elson. All Rights Reserved.