001 /** 002 * Copyright (c) 2003 Daffodil Software Ltd all rights reserved, 003 * Modifications Copyright (c) 2008 Regiscope Digital Imaging Co, LLC, All rights reserved. 004 * This program is free software; you can redistribute it and/or modify 005 * it under the terms of version 2 of the GNU General Public License as 006 * published by the Free Software Foundation. 007 * There are special exceptions to the terms and conditions of the GPL 008 * as it is applied to this software. See the GNU General Public License for more details. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU General Public License for more details. 014 * 015 * You should have received a copy of the GNU General Public License 016 * along with this program; if not, write to the Free Software 017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 018 */ 019 020 package org.dbreplicator.graph; 021 022 /** 023 Instances of this class act as elements of a linked list. It is used for keeping 024 <CODE>JbVertex</CODE>-instances and <CODE>JbEdge</CODE>-instances in order. 025 <UL><LI>The collision management strategy of the hash table,</LI> 026 <LI>the general vertex list of the graph,</LI> 027 <LI>and the edges of a single vertex</LI> 028 </UL>are all kept in a linked list of of <CODE>JbListElement</CODE> instances. 029 */ 030 031 public class JbListElement{ 032 033 //----------- 034 // Variables 035 //----------- 036 037 /** 038 A link to the next element in the linked list. 039 */ 040 public JbListElement next; 041 042 /** 043 A link to the actual object represented by this "hanger" instance. 044 Usually an instance of <CODE>JbVertex</CODE> or <CODE>JbEdge</CODE>. 045 */ 046 public Object hangingVertexOrEdge; 047 048 //-------------- 049 // Constructor 050 //-------------- 051 052 /** 053 The null constructor gets called when we 054 initialize the hash table. We attach null- 055 containing-list elements to each hash index, for 056 ease of coding. (If you want to understand why 057 this is important, try to visualize the return 058 value of the method <CODE>findVertex</CODE> 059 without guarantee that each index in the hash 060 table will have at least one 061 <CODE>JbListElement</CODE>...) 062 */ 063 064 public JbListElement(){ 065 next=null; 066 hangingVertexOrEdge=null; 067 } 068 069 /** 070 The list element is a general linked list 071 element. It contains a link to the next element, 072 and a hanger for the vertex or the edge that 073 it represents. 074 @param objToHang The object that we wish to "hang" 075 in this list element, usually an instance of 076 <CODE>JbVertex</CODE> or <CODE>JbEdge</CODE> 077 */ 078 079 public JbListElement(Object objToHang){ 080 next=null; 081 hangingVertexOrEdge=objToHang; 082 } 083 084 //------------ 085 // Methods 086 //------------ 087 public String toString(){ 088 String str=hangingVertexOrEdge.toString(); 089 String s=str; 090 JbListElement le= this; 091 while(s!=null){ 092 le= le.next; 093 if(le!=null) 094 str+=le.hangingVertexOrEdge; 095 else 096 s=null; 097 } 098 return str; 099 } 100 } 101

