edu.UCL.xmiddle.host
Class XPathLinkTable

java.lang.Object
  |
  +--edu.UCL.xmiddle.host.XPathLinkTable
All Implemented Interfaces:
LinkTable

public class XPathLinkTable
extends java.lang.Object
implements LinkTable

XPathLinkTable.java A linktable implemented using hashtables, vectors and a lot of sweat! It basically uses three hashtables (with the application ID of the local application as key) to represent the exports, linked From and linkedBy tables. The hashtables hold Vectors of LinkTableItem. Created: Mon Jul 30 14:07:09 2001


Constructor Summary
XPathLinkTable()
          Constructs a new XPathLinkTable for the local host
XPathLinkTable(boolean local)
          Constructs a new LinkTable
XPathLinkTable(java.lang.String links)
          Constructs a new XPathLinkTable with the given data
XPathLinkTable(java.lang.String links, boolean local)
          Constructs a new XPathLinkTable with the given data
 
Method Summary
 void addExport(org.w3c.dom.Element element, java.lang.Integer appID)
          Adds a new export.
 void addExport(java.lang.String path, java.lang.Integer appID)
          Adds a new export.
 void addLinkedBy(java.lang.Object primaryID, org.w3c.dom.Element element, java.lang.Integer localAppID)
          Adds a new entry to the link table to signify that a given element was linked by a given host
 void addLinkedBy(java.lang.Object primaryID, java.lang.String path, java.lang.Integer localAppID)
          Adds a new entry to the link table to signify that a given element was linked by a given host
 void addLinkedFrom(java.lang.Object primaryID, java.lang.String src, org.w3c.dom.Element dest, java.lang.Integer remoteAppID, java.lang.Integer localAppID)
          Signifies that the local host has linked an element from a remote host, and adds that to the linktable.
 void addLinkedFrom(java.lang.Object primaryID, java.lang.String src, java.lang.String dest, java.lang.Integer remoteAppID, java.lang.Integer localAppID)
          Signifies that the local host has linked an element from a remote host, and adds that to the linktable.
 java.util.Enumeration getExportsList()
          Returns the exports
 java.util.Enumeration getLinkedByHostList(java.lang.Object primaryID)
          Returns data on all elements linked by the given host.
 java.util.Enumeration getLinkedByList()
          Returns the linked by table
 java.util.Enumeration getLinkedFromHostList(java.lang.Object primaryID)
          Returns data on all elements linked from the given host.
 java.util.Enumeration getLinkedFromList()
          Returns the linked From table
 java.lang.String getLinkTableMessage()
          Returns an XML representation of the linktable message
 boolean isExported(org.w3c.dom.Element element, java.lang.Integer appID)
          Determines whether the given element is exported
 boolean isExported(java.lang.String path, java.lang.Integer appID)
          Determines whether the given element is exported
 boolean isLinkedBy(org.w3c.dom.Element element, java.lang.Integer appID)
          Determines whether the given element is linked by another host.
 boolean isLinkedBy(java.lang.Object primaryID, org.w3c.dom.Element element, java.lang.Integer appID)
          Determines whether the given element is linked by a particular host.
 boolean isLinkedBy(java.lang.Object primaryID, java.lang.String path, java.lang.Integer appID)
          Determines whether the given element is linked by a particular host.
 boolean isLinkedBy(java.lang.String path, java.lang.Integer appID)
          Determines whether the given element is linked by another host.
 boolean isLinkedFrom(org.w3c.dom.Element element, java.lang.Integer appID)
          Determines whether the given element is linked from another host.
 boolean isLinkedFrom(java.lang.Object primaryID, org.w3c.dom.Element element, java.lang.Integer appID)
          Determines whether the given element is linked from a particular host.
 boolean isLinkedFrom(java.lang.Object primaryID, java.lang.String path, java.lang.Integer appID)
          Determines whether the given element is linked from a particular host.
 boolean isLinkedFrom(java.lang.String path, java.lang.Integer appID)
          Determines whether the given element is linked from another host.
 boolean isShared(org.w3c.dom.Element element, java.lang.Integer appID)
          Determines whether the given element is shared with another host.
 boolean isShared(java.lang.String path, java.lang.Integer appID)
          Determines whether the given element is shared with another host.
 void removeExport(org.w3c.dom.Element element, java.lang.Integer appID)
          Signifies that the local host has stopped exporting the given element
 void removeExport(java.lang.String path, java.lang.Integer appID)
          Signifies that the local host has stopped exporting the given element
 void removeLinkedBy(java.lang.Object primaryID, org.w3c.dom.Element element, java.lang.Integer localAppID)
          Signifies that the given element is not linked from the given host, and removes any such references from the linktable
 void removeLinkedBy(java.lang.Object primaryID, java.lang.String path, java.lang.Integer localAppID)
          Signifies that the given element is not linked from the given host, and removes any such references from the linktable
 void removeLinkedFrom(org.w3c.dom.Element element, java.lang.Integer appID)
          Signifies that the given element is not linked from any other host, and removes any such references from the linktable
 void removeLinkedFrom(java.lang.String path, java.lang.Integer appID)
          Signifies that the given element is not linked from any other host, and removes any such references from the linktable
 void setLinks(java.lang.Object links)
          Parses an XML string containing the linktable (of a remote host)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathLinkTable

public XPathLinkTable()
Constructs a new XPathLinkTable for the local host


XPathLinkTable

public XPathLinkTable(java.lang.String links)
Constructs a new XPathLinkTable with the given data

Parameters:
links - The XPathLinkTable in XML format

XPathLinkTable

public XPathLinkTable(boolean local)
Constructs a new LinkTable

Parameters:
local - If true, then the link table is destined for the local host.

XPathLinkTable

public XPathLinkTable(java.lang.String links,
                      boolean local)
Constructs a new XPathLinkTable with the given data

Parameters:
links - The XPathLinkTable in XML format
local - if true, then the link table is destine for the local host
Method Detail

getLinkTableMessage

public java.lang.String getLinkTableMessage()
Returns an XML representation of the linktable message

Specified by:
getLinkTableMessage in interface LinkTable
Returns:
a String value

isShared

public boolean isShared(java.lang.String path,
                        java.lang.Integer appID)
Determines whether the given element is shared with another host. A shared element is an element which is linked from or by another host

Specified by:
isShared in interface LinkTable
Parameters:
path - the element (as an XPath expression)
appID - the ID of the application under the tree of which this element resides
Returns:
true if the element is shared, or false otherwise

isShared

public boolean isShared(org.w3c.dom.Element element,
                        java.lang.Integer appID)
Determines whether the given element is shared with another host. A shared element is an element which is linked from or by another host

Specified by:
isShared in interface LinkTable
Parameters:
element - the element
appID - the ID of the application under the tree of which this element resides
Returns:
true if the element is shared, or false otherwise

isLinkedFrom

public boolean isLinkedFrom(java.lang.String path,
                            java.lang.Integer appID)
Determines whether the given element is linked from another host.

Specified by:
isLinkedFrom in interface LinkTable
Parameters:
path - The element (encoded as an XPath expression)
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked from another host, or false otherwise

isLinkedFrom

public boolean isLinkedFrom(org.w3c.dom.Element element,
                            java.lang.Integer appID)
Determines whether the given element is linked from another host.

Specified by:
isLinkedFrom in interface LinkTable
Parameters:
element - The element
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked from another host, or false otherwise

isLinkedFrom

public boolean isLinkedFrom(java.lang.Object primaryID,
                            java.lang.String path,
                            java.lang.Integer appID)
Determines whether the given element is linked from a particular host.

Specified by:
isLinkedFrom in interface LinkTable
Parameters:
primaryID - the primary ID of the remote host
path - The element (encoded as an XPath expression)
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked from the other host, or false otherwise

isLinkedFrom

public boolean isLinkedFrom(java.lang.Object primaryID,
                            org.w3c.dom.Element element,
                            java.lang.Integer appID)
Determines whether the given element is linked from a particular host.

Specified by:
isLinkedFrom in interface LinkTable
Parameters:
primaryID - the primary ID of the remote host
element - The element
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked from the other host, or false otherwise

isExported

public boolean isExported(java.lang.String path,
                          java.lang.Integer appID)
Determines whether the given element is exported

Specified by:
isExported in interface LinkTable
Parameters:
path - the element encoded as an XPath expression
appID - the id of the application under the tree of which this element resides
Returns:
true if the element is exported, or false otherwise

isExported

public boolean isExported(org.w3c.dom.Element element,
                          java.lang.Integer appID)
Determines whether the given element is exported

Specified by:
isExported in interface LinkTable
Parameters:
element - the element
appID - the id of the application under the tree of which this element resides
Returns:
true if the element is exported, or false otherwise

isLinkedBy

public boolean isLinkedBy(java.lang.Object primaryID,
                          java.lang.String path,
                          java.lang.Integer appID)
Determines whether the given element is linked by a particular host.

Specified by:
isLinkedBy in interface LinkTable
Parameters:
primaryID - the primary ID of the remote host
path - The element encoded as an XPath expression
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked by the other host, or false otherwise

isLinkedBy

public boolean isLinkedBy(java.lang.Object primaryID,
                          org.w3c.dom.Element element,
                          java.lang.Integer appID)
Determines whether the given element is linked by a particular host.

Specified by:
isLinkedBy in interface LinkTable
Parameters:
primaryID - the primary ID of the remote host
element - The element
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked by the other host, or false otherwise

isLinkedBy

public boolean isLinkedBy(java.lang.String path,
                          java.lang.Integer appID)
Determines whether the given element is linked by another host.

Specified by:
isLinkedBy in interface LinkTable
Parameters:
path - element (encoded as an XPath expression)
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked by another host, or false otherwise

isLinkedBy

public boolean isLinkedBy(org.w3c.dom.Element element,
                          java.lang.Integer appID)
Determines whether the given element is linked by another host.

Specified by:
isLinkedBy in interface LinkTable
Parameters:
element - The element
appID - The ID of the application under the tree of which this element resides.
Returns:
true if the element is linked by another host, or false otherwise

addLinkedFrom

public void addLinkedFrom(java.lang.Object primaryID,
                          java.lang.String src,
                          java.lang.String dest,
                          java.lang.Integer remoteAppID,
                          java.lang.Integer localAppID)
Signifies that the local host has linked an element from a remote host, and adds that to the linktable.

Specified by:
addLinkedFrom in interface LinkTable
Parameters:
primaryID - The primary ID of the remote host
src - The remote element which the local host linked from (encoded as XPath)
dest - The local element under which the linked element was placed at (encoded as XPath)
remoteAppID - The id of the remote application that exported the element
localAppID - The id of the local application on the data structure of which the remote element was linked

addLinkedFrom

public void addLinkedFrom(java.lang.Object primaryID,
                          java.lang.String src,
                          org.w3c.dom.Element dest,
                          java.lang.Integer remoteAppID,
                          java.lang.Integer localAppID)
Signifies that the local host has linked an element from a remote host, and adds that to the linktable.

Specified by:
addLinkedFrom in interface LinkTable
Parameters:
primaryID - The primary ID of the remote host
src - The remote element which the local host linked from (encoded as XPath)
dest - The local element under which the linked element was placed
remoteAppID - The id of the remote application that exported the element
localAppID - The id of the local application on the data structure of which the remote element was linked

removeLinkedFrom

public void removeLinkedFrom(java.lang.String path,
                             java.lang.Integer appID)
Signifies that the given element is not linked from any other host, and removes any such references from the linktable

Parameters:
path - The given element (encoded as XPath)
appID - The ID of the application under which this element resides

removeLinkedFrom

public void removeLinkedFrom(org.w3c.dom.Element element,
                             java.lang.Integer appID)
Signifies that the given element is not linked from any other host, and removes any such references from the linktable

Specified by:
removeLinkedFrom in interface LinkTable
Parameters:
element - The given element
appID - The ID of the application under which this element resides

addLinkedBy

public void addLinkedBy(java.lang.Object primaryID,
                        java.lang.String path,
                        java.lang.Integer localAppID)
Adds a new entry to the link table to signify that a given element was linked by a given host

Specified by:
addLinkedBy in interface LinkTable
Parameters:
primaryID - The primaryID of the remote host
path - The element that was linked By the remote host (encoded as XPath)
localAppID - The ID of the application under the tree of which the element that was linked by resides

addLinkedBy

public void addLinkedBy(java.lang.Object primaryID,
                        org.w3c.dom.Element element,
                        java.lang.Integer localAppID)
Adds a new entry to the link table to signify that a given element was linked by a given host

Specified by:
addLinkedBy in interface LinkTable
Parameters:
primaryID - The primaryID of the remote host
element - The element that was linked By the remote host
localAppID - The ID of the application under the tree of which the element that was linked by resides

removeLinkedBy

public void removeLinkedBy(java.lang.Object primaryID,
                           java.lang.String path,
                           java.lang.Integer localAppID)
Signifies that the given element is not linked from the given host, and removes any such references from the linktable

Specified by:
removeLinkedBy in interface LinkTable
Parameters:
primaryID - The primaryID of the remote host
path - The given element (encoded as XPath)
localAppID - The ID of the local application to which the element belonged

removeLinkedBy

public void removeLinkedBy(java.lang.Object primaryID,
                           org.w3c.dom.Element element,
                           java.lang.Integer localAppID)
Signifies that the given element is not linked from the given host, and removes any such references from the linktable

Specified by:
removeLinkedBy in interface LinkTable
Parameters:
primaryID - The primaryID of the remote host
element - The given element
localAppID - The ID of the local application to which the element belonged

addExport

public void addExport(java.lang.String path,
                      java.lang.Integer appID)
Adds a new export.

Specified by:
addExport in interface LinkTable
Parameters:
path - The element to export (encoded as XPath)
appID - The ID of the application under the tree of which the element resides

addExport

public void addExport(org.w3c.dom.Element element,
                      java.lang.Integer appID)
Adds a new export.

Specified by:
addExport in interface LinkTable
Parameters:
element - The element to export
appID - The ID of the application under the tree of which the element resides

removeExport

public void removeExport(java.lang.String path,
                         java.lang.Integer appID)
Signifies that the local host has stopped exporting the given element

Specified by:
removeExport in interface LinkTable
Parameters:
path - The element to stop exporting (Encoded as XPath)
appID - The ID of the application under which the element resides

removeExport

public void removeExport(org.w3c.dom.Element element,
                         java.lang.Integer appID)
Signifies that the local host has stopped exporting the given element

Specified by:
removeExport in interface LinkTable
Parameters:
appID - The ID of the application under which the element resides
element - The Element

setLinks

public void setLinks(java.lang.Object links)
Parses an XML string containing the linktable (of a remote host)

Specified by:
setLinks in interface LinkTable
Parameters:
links - a String representation of the XML-formated version of a linktable. Warning: this method includes no checks. links must be formatted exactly according to the guidelines of getLinkTableMessage() above.

getLinkedFromHostList

public java.util.Enumeration getLinkedFromHostList(java.lang.Object primaryID)
Returns data on all elements linked from the given host.

Specified by:
getLinkedFromHostList in interface LinkTable
Parameters:
primaryID - The primaryID of the host to be checked.
Returns:
An Enumeration containing LinkTableItems. If no elements are linked, then null is returned.

getLinkedByHostList

public java.util.Enumeration getLinkedByHostList(java.lang.Object primaryID)
Returns data on all elements linked by the given host.

Specified by:
getLinkedByHostList in interface LinkTable
Parameters:
primaryID - The primaryID of the host to be checked.
Returns:
An Enumeration containing LinkTableItems. If no elements are linked, or no linkedBy table is present, then null is returned

getLinkedFromList

public java.util.Enumeration getLinkedFromList()
Returns the linked From table

Specified by:
getLinkedFromList in interface LinkTable
Returns:
The structure is as follows: each element in the enumeration is a Vector. The vector holds LinkTableItem objects of type LINKED_FROM
See Also:
LinkTableItem

getLinkedByList

public java.util.Enumeration getLinkedByList()
Returns the linked by table

Specified by:
getLinkedByList in interface LinkTable
Returns:
The structure is as follows: each element in the enumeration is a Vector. The vector holds LinkTableItem objects of type LINKED_BY
See Also:
LinkTableItem

getExportsList

public java.util.Enumeration getExportsList()
Returns the exports

Specified by:
getExportsList in interface LinkTable
Returns:
The structure is as follows: each element in the enumeration is a Vector. The vector holds LinkTableItem objects of type EXPORT
See Also:
LinkTableItem