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    import java.util.*;
025    
026    /**
027      Instances of this class act as edges in the graph. Instances of this
028      class always "hang" from a <CODE>JbListElement</CODE> instance. They
029      have a <CODE>int weight</CODE> and a link to the vertex object to
030      which they lead. Null target vertices are not supported.
031     */
032    
033    public class Edge {
034    
035      protected static Logger log = Logger.getLogger(Edge.class.getName());
036      // The weight of this edge.
037      private int weight;
038    
039      //  The vertex where the edge leads to.
040      public Vertex targetVertex;
041    
042    
043      private ArrayList attributesList;
044    
045      /**
046         An edge object leading from one vertex to another.
047         Edges are unique, there can only be one edge
048         from vertex A to vertex B. The weight cannot be changed
049         after the object is constructed.
050       */
051    
052      public Edge(Vertex target, int weightValue, ArrayList listOfAttributes) {
053        this.weight = weightValue;
054        targetVertex = target;
055        this.attributesList = listOfAttributes;
056      }
057    
058      public Edge(Vertex target, int weightValue) {
059        this.weight = weightValue;
060        targetVertex = target;
061        attributesList = new ArrayList();
062      }
063    
064    
065    
066      /**
067       Return the weight of the edge.
068      */
069    
070      public int whatIsWeight() {
071        return this.weight;
072      }
073    
074      public void addAttribute(String[] attributes) {
075        if(attributesList ==null)
076          attributesList= new ArrayList();
077        attributesList.add(attributes);
078      }
079    
080      public ArrayList getAttributesList() {
081        return this.attributesList;
082      }
083    }
084    





























































Powered by Drupal - Theme by Danger4k