JavaDoc


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    
021    package org.dbreplicator.graph;
022    
023     import org.apache.log4j.Logger;
024       /**
025            Instances of this class act as elements of a linked list. It is used for keeping
026            <CODE>Vertex</CODE>-instances and <CODE>Edge</CODE>-instances in order.
027            <UL><LI>The collision management strategy of the hash table,</LI>
028            <LI>the general vertex list of the graph,</LI>
029            <LI>and the edges of a single vertex</LI>
030            </UL>are all kept in a linked list of of <CODE>ListElement</CODE> instances.
031        */
032    
033        public class ListElement{
034    
035            protected static Logger log = Logger.getLogger(Edge.class.getName());
036    
037           // A link to the next element in the linked list.
038            public ListElement next;
039    
040            /**
041                    A link to the actual object represented by this "hanger" instance.
042                    Usually an instance of <CODE>Vertex</CODE> or <CODE>Edge</CODE>.
043            */
044            public Object hangingVertexOrEdge;
045    
046    
047            /**
048                    The null constructor gets called when we
049                    initialize the hash table. We attach null-
050                    containing-list elements to each hash index, for
051                    ease of coding. (If you want to understand why
052                    this is important, try to visualize the return
053                    value of the method <CODE>findVertex</CODE>
054                    without guarantee that each index in the hash
055                    table will have at least one
056                    <CODE>ListElement</CODE>...)
057            */
058    
059            public ListElement(){
060              next=null;
061              hangingVertexOrEdge=null;
062            }
063    
064            /**
065                    The list element is a general linked list
066                    element. It contains a link to the next element,
067                    and a hanger for the vertex or the edge that
068                    it represents.
069                    @param objToHang The object that we wish to "hang"
070                    in this list element, usually an instance of
071                    <CODE>Vertex</CODE> or <CODE>Edge</CODE>
072            */
073    
074            public ListElement(Object objToHang){
075              next=null;
076              hangingVertexOrEdge=objToHang;
077            }
078    
079    
080    
081            public String toString(){
082              String str=hangingVertexOrEdge.toString();
083              String s=str;
084              ListElement le= this;
085              while(s!=null){
086                le= le.next;
087                if(le!=null)
088                str+=le.hangingVertexOrEdge;
089              else
090                  s=null;
091              }
092              return str;
093            }
094        }
095    





























































Powered by Drupal - Theme by Danger4k