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





























































Powered by Drupal - Theme by Danger4k