Coverage details for edu.uci.ics.jung.graph.predicates.UserDatumEdgePredicate

LineHitsSource
1 /*
2  * Created on Mar 17, 2004
3  *
4 * Copyright (c) 2003, 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.predicates;
13  
14 import edu.uci.ics.jung.graph.ArchetypeEdge;
15  
16  
17 /**
18  * A predicate that checks to see whether an edge's user
19  * data repository contains
20  * the constructor-specified (key,datum) pair. This predicate
21  * may be used as a constraint.
22  */
23 public class UserDatumEdgePredicate extends EdgePredicate
24 {
25     public static final String message = "UserDatumEdgePredicate: ";
26     private Object datum;
27     private Object key;
28     
29     public UserDatumEdgePredicate(Object key, Object datum)
303    {
313        if (key == null)
320            throw new IllegalArgumentException("UserDatumEdgePredicate " +
33                     "key must be non-null");
343        this.datum = datum;
353        this.key = key;
363    }
37         
38     /**
39      * Returns <code>true</code> if the datum stored by <code>e</code> with
40      * key value <code>key</code> (in the user data repository) is
41      * <code>datum</code>.
42      *
43      * @see edu.uci.ics.jung.utils.UserData
44      */
45     public boolean evaluateEdge(ArchetypeEdge e)
46     {
4723        Object value = e.getUserDatum(key);
4823        return ((datum == null && value == null) || datum.equals(value));
49 // return (e.getUserDatum(key).equals(datum));
50     }
51  
52     public String toString()
53     {
541        return message + "(" + key + ", " + datum + ")";
55     }
56     
57     /**
58      * Tests equality based on underlying objects
59      */
60     public boolean equals( Object o ) {
6113        if (! (o instanceof UserDatumEdgePredicate))
6211            return false;
632        UserDatumEdgePredicate udep = (UserDatumEdgePredicate) o;
642        return ( udep.datum.equals( datum ) && udep.key.equals(key));
65     }
66     
67     public int hashCode() {
680        return datum.hashCode() + key.hashCode();
69     }
70     
71     /**
72      * Returns the user data key which partially defines this predicate.
73      */
74     public Object getKey()
75     {
760        return key;
77     }
78     
79     /**
80      * Returns the user datum which partially defines this predicate.
81      */
82     public Object getDatum()
83     {
840        return datum;
85     }
86 }

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.