Coverage details for edu.uci.ics.jung.graph.impl.AbstractArchetypeEdge

LineHitsSource
1 /*
2  * Created on Apr 27, 2005
3  *
4  * Copyright (c) 2005, the JUNG Project and the Regents of the University
5  * of California
6  * All rights reserved.
7  *
8  * This software is open-source under the BSD license; see either
9  * "license.txt" or
10  * http://jung.sourceforge.net/license.txt for a description.
11  */
12 package edu.uci.ics.jung.graph.impl;
13  
14 import java.util.Iterator;
15 import java.util.Set;
16  
17 import edu.uci.ics.jung.exceptions.FatalException;
18 import edu.uci.ics.jung.graph.ArchetypeEdge;
19 import edu.uci.ics.jung.graph.ArchetypeGraph;
20 import edu.uci.ics.jung.graph.ArchetypeVertex;
21  
22 /**
23  *
24  * @author Joshua O'Madadhain
25  */
26147361public abstract class AbstractArchetypeEdge extends AbstractElement implements
27         ArchetypeEdge
28 {
29  
30     public Set getIncidentElements()
31     {
320        return getIncidentVertices();
33     }
34     
35     /**
36      * @see edu.uci.ics.jung.graph.ArchetypeEdge#getEqualEdge(edu.uci.ics.jung.graph.ArchetypeGraph)
37      */
38     public ArchetypeEdge getEqualEdge(ArchetypeGraph ag)
39     {
40277149        if (ag instanceof AbstractArchetypeGraph)
41         {
42124795            AbstractArchetypeGraph aag = (AbstractArchetypeGraph)ag;
43124795            return aag.getEdgeByID(this.getID());
44         }
45         else
46152354            return null;
47     }
48     
49     /**
50      * @deprecated As of version 1.4, renamed to getEqualEdge(ag).
51      */
52     public ArchetypeEdge getEquivalentEdge(ArchetypeGraph ag)
53     {
540        return getEqualEdge(ag);
55     }
56  
57     /**
58      * @see edu.uci.ics.jung.graph.ArchetypeEdge#numVertices()
59      */
60     public int numVertices()
61     {
620        return getIncidentVertices().size();
63     }
64  
65     /**
66      * @see edu.uci.ics.jung.graph.ArchetypeEdge#isIncident(edu.uci.ics.jung.graph.ArchetypeVertex)
67      */
68     public boolean isIncident(ArchetypeVertex v)
69     {
700        return getIncidentVertices().contains(v);
71     }
72  
73     /**
74      * @see edu.uci.ics.jung.graph.ArchetypeEdge#copy(edu.uci.ics.jung.graph.ArchetypeGraph)
75      */
76     public ArchetypeEdge copy(ArchetypeGraph g)
77     {
78895        if (g == this.getGraph())
791            throw new IllegalArgumentException("Source and destination " +
80                 "graphs must be different");
81         
82894        for (Iterator iter = getIncidentVertices().iterator(); iter.hasNext(); )
83         {
841753            ArchetypeVertex av = (ArchetypeVertex)iter.next();
851753            if (av.getEqualVertex(g) == null)
861                throw new IllegalArgumentException("Cannot create edge: " +
87                         "source edge's incident vertex " + av + "has no equivalent " +
88                         "in target graph");
89         }
90  
91         AbstractArchetypeEdge e;
92         try
93         {
94893            e = (AbstractArchetypeEdge)this.clone();
95         }
960        catch (CloneNotSupportedException cnse)
97         {
980            throw new FatalException("Can't copy edge " + this, cnse);
99893        }
100893        e.initialize();
101893        e.importUserData(this);
102893        return e;
103     }
104  
105     /**
106      * Returns <code>true</code> if <code>o</code> is an instance of
107      * <code>ArchetypeEdge</code> that is equivalent to this edge.
108      * Respects the edge
109      * equivalences which are established by <code>copy()</code> and
110      * referenced by <code>getEquivalentEdge()</code>.
111      *
112      * @see java.lang.Object#equals(java.lang.Object)
113      * @see ArchetypeEdge#getEqualEdge(ArchetypeGraph)
114      * @see ArchetypeEdge#copy
115      */
116     public boolean equals(Object o)
117     {
118277970        if (this == o)
119         {
1201464            return true;
121         }
122276506        if (!(o instanceof ArchetypeEdge))
1230            return false;
124276506        ArchetypeEdge e = (ArchetypeEdge) o;
125276506        return (this == e.getEqualEdge(this.getGraph()));
126     }
127 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.