org.ceryle.xnode
Class XNodeIDFactory

java.lang.Object
  extended by org.ceryle.xnode.XNodeIDFactory

public class XNodeIDFactory
extends Object

A factory for creating XNodeIDs and XNodeLinks.

XNodeID provides a common, convenient identifier for XNodes, combining an immutable Collection ID (cid) and Node ID (nid) and a method for obtaining the database URL reference.

Whereas XNodeID is an identifier, XNodeLink extends XNodeID as a link or reference to an XNode. An important augmentation is the ability to set and get the link strength, which is represented as a double value from 0.0D to 1.0D. Also note: XNodeLinks are not cached.

The XNodeIDFactory is a singleton class that provides a means of guaranteeing that for any combination of Collection and Node ID that a single XNodeID is created. Calling either of the two public getXNodeID() methods prior to instantiation causes the factory to be created.

TODO: have not yet implemented XNodeID caching/uniqueness guarantees, apart from those provided natively by the Hashtable.

The XNode Implementation (the package org.ceryle.xnode.*, both its source code and documentation), are released under the Apache 2.0 License. For more details, check the LICENSE file contained with the distribution, or see The Ceryle Project for more information. It is distributed with no warranty.

Since:
JDK1.3
Version:
$Id: XNodeIDFactory.java,v 3.5 2007-06-20 01:28:41 altheim Exp $
Author:
Murray Altheim
See Also:
XNode

Method Summary
static XNodeID getXNodeID(String[] ids)
          Constructor with a String array ids.
static XNodeID getXNodeID(String cid, String nid)
          Returns an XNodeID provided with the Collection and Node IDs.
static XNodeLink getXNodeLink(String cid, String nid, double weight)
          Returns an XNodeLink provided with the Collection and Node IDs, and weight.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getXNodeID

public static XNodeID getXNodeID(String[] ids)
                          throws XNodeException
Constructor with a String array ids. If either of the first two elements are null, an IllegalArgumentException is thrown. If there are more than two elements, the rest are ignored.

This is guaranteed to return the same Object for the same IDs.

Parameters:
ids - a String array containing the Collection and Node IDs, resp.
Returns:
the XNodeID corresponding to the Collection and Node IDs.
Throws:
XNodeException - if either array element 0 or 1 is null or not an XML Name.

getXNodeID

public static XNodeID getXNodeID(String cid,
                                 String nid)
                          throws XNodeException
Returns an XNodeID provided with the Collection and Node IDs.

This is guaranteed to return the same Object for the same IDs.

Parameters:
cid - the Collection ID.
nid - the Node ID.
Returns:
the XNodeID corresponding to the Collection and Node IDs.
Throws:
XNodeException - if either parameter is null or not an XML Name.

getXNodeLink

public static XNodeLink getXNodeLink(String cid,
                                     String nid,
                                     double weight)
                              throws XNodeException
Returns an XNodeLink provided with the Collection and Node IDs, and weight.

Unlike XNodeIDs, XNodeLinks are not cached.

Parameters:
cid - the Collection ID.
nid - the Node ID.
weight - the link weight between 0.0 and 1.0.
Returns:
the XNodeID corresponding to the Collection and Node IDs.
Throws:
XNodeException - if either of the cid or nid parameters is null or not an XML Name or the weight is out of range.


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.