Coverage details for edu.uci.ics.jung.graph.filters.impl.AlphabeticVertexFilter

LineHitsSource
1 /*
2 * Copyright (c) 2003, the JUNG Project and the Regents of the University
3 * of California
4 * All rights reserved.
5 *
6 * This software is open-source under the BSD license; see either
7 * "license.txt" or
8 * http://jung.sourceforge.net/license.txt for a description.
9 */
10 /*
11  * (c) 2002 Danyel Fisher, Paul Dourish,
12  * and the Regents of the University of California
13  *
14  * Created on Jul 2, 2003
15  *
16  */
17 package edu.uci.ics.jung.graph.filters.impl;
18  
19 import edu.uci.ics.jung.graph.Vertex;
20 import edu.uci.ics.jung.graph.decorators.StringLabeller;
21 import edu.uci.ics.jung.graph.filters.EfficientFilter;
22 import edu.uci.ics.jung.graph.filters.GeneralVertexAcceptFilter;
23  
24 /**
25  * A small example filter that accepts vertices that are alphabetically
26  * past the input value.
27  *
28  * @author danyelf
29  */
30 public class AlphabeticVertexFilter extends GeneralVertexAcceptFilter implements EfficientFilter {
31  
32     public AlphabeticVertexFilter(
33         String threshhold,
34         StringLabeller sl,
359        boolean acceptAboveThreshold) {
36             
379        this.stringLabeller = sl;
389        this.threshhold = threshhold;
399        this.acceptThoseAboveThreshhold = acceptAboveThreshold;
40  
419    }
42  
43     private StringLabeller stringLabeller;
44     private String threshhold;
45     private boolean acceptThoseAboveThreshhold;
46  
47     /**
48      * Passes the vertex if its StringLabeller value compares over
49      * (or under) the threshold.
50      */
51     public boolean acceptVertex(Vertex vert) {
52 // String comp = GraphUtils.getLabel( stringLabeller, vert);
53307        String comp = stringLabeller.getLabel(vert);
54307        if ((comp.compareTo(threshhold) > 0) && acceptThoseAboveThreshhold)
55142            return true;
56165        return false;
57     }
58  
59     /**
60      * Returns a name for this:
61      * <tt>AlphabeticFilter(>"TestString")</tt>
62      */
63     public String getName() {
6425        String label = acceptThoseAboveThreshhold ? ">" : "<=";
6525        return "Alphabetic filter(" + label + "\"" + threshhold + "\")";
66     }
67  
68     /**
69      * Returns the current direction of the comparison:
70      * True if this accepts only strings above the
71      * threshhold, otherwise, accepts only strings at or
72      * below the threshhold.
73      *
74      * @return boolean
75      */
76     public boolean isAcceptThoseAboveThreshhold() {
770        return acceptThoseAboveThreshhold;
78     }
79  
80     /**
81      * @return String the current comparison value
82      */
83     public String getThreshhold() {
849        return threshhold;
85     }
86  
87     /**
88      * Sets the acceptThoseAboveThreshhold: if true, this accepts values over
89      * the threshhold; if false, this accepts values up to and including the
90      * threshhold, but not above it.
91      * @param acceptThoseAboveThreshhold
92      */
93     public void setAcceptThoseAboveThreshhold(boolean acceptThoseAboveThreshhold) {
940        this.acceptThoseAboveThreshhold = acceptThoseAboveThreshhold;
950    }
96  
97     /**
98      * Sets the threshhold.
99      * @param threshhold The threshhold to set
100      */
101     public void setThreshhold(String threshhold) {
10218        this.threshhold = threshhold;
10318    }
104  
105     /**
106      * Returns the String Labeller being used by this filter to check vertices with.
107      * @return StringLabeller
108      */
109     public StringLabeller getStringLabeller() {
1100        return stringLabeller;
111     }
112  
113     /**
114      * Sets the stringLabeller.
115      * @param stringLabeller The stringLabeller to set
116      */
117     public void setStringLabeller(StringLabeller stringLabeller) {
1180        this.stringLabeller = stringLabeller;
1190    }
120  
121 }

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.