# Coverage details for edu.uci.ics.jung.graph.decorators.ToStringLabeller

Line | Hits | Source
--- | --- | ---
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 |  | `* Created on Apr 13, 2004`
12 |  | `*/`
13 |  | `package edu.uci.ics.jung.graph.decorators;`
14 |  | ``
15 |  | `import java.util.Set;`
16 |  | ``
17 |  | `import edu.uci.ics.jung.graph.ArchetypeVertex;`
18 |  | `import edu.uci.ics.jung.graph.Graph;`
19 |  | `import edu.uci.ics.jung.graph.Vertex;`
20 |  | `import edu.uci.ics.jung.utils.UserData;`
21 |  | ``
22 |  | `/**`
23 |  | `* Labels vertices by their toString. This class functions as a drop-in`
24 |  | `* replacement for the default StringLabeller method. This class does not`
25 |  | `* guarantee unique labels; or even consistent ones; as a result,`
26 |  | `* getVertexByLabel will always return NULL.`
27 |  | `*`
28 |  | `* @author danyelf`
29 |  | `*/`
30 |  | `public class ToStringLabeller extends StringLabeller {`
31 |  | ``
32 |  | `/**`
33 |  | `* This method is not meaningful; it throws an IllegalArgumentException`
34 |  | `*/`
35 |  | `public void assignDefaultLabels(Set vertices, int offset)`
36 |  | `{`
37 | 1 | `throw new IllegalArgumentException();`
38 |  | `}`
39 |  | `/**`
40 |  | `* This method is not meaningful; it throws an IllegalArgumentException`
41 |  | `*/`
42 |  | `public Vertex removeLabel(String string) {`
43 | 1 | `throw new IllegalArgumentException();`
44 |  | `}`
45 |  | `/**`
46 |  | `* @param g`
47 |  | `*/`
48 |  | `protected ToStringLabeller(Graph g) {`
49 | 1 | `super(g);`
50 | 1 | `labelToVertex = null;`
51 | 1 | `vertexToLabel = null;`
52 |  | `// TODO Auto-generated constructor stub for ToStringLabeller`
53 | 1 | `}`
54 |  | ``
55 |  | `/**`
56 |  | `* Sets the StringLabeller of this graph, at this key, to be a`
57 |  | `* ToStringLabeller.`
58 |  | `*/`
59 |  | `public static StringLabeller setLabellerTo(Graph g, Object key) {`
60 | 1 | `StringLabeller sl = new ToStringLabeller(g);`
61 | 1 | `if (key != null) g.addUserDatum(key, sl, UserData.REMOVE);`
62 | 1 | `return sl;`
63 |  | `}`
64 |  | ``
65 |  | `/**`
66 |  | `* Sets the default StringLabeller of this graph to be a ToStringLabeller.`
67 |  | `*/`
68 |  | `public static StringLabeller setLabellerTo(Graph g) {`
69 | 1 | `return setLabellerTo(g, StringLabeller.DEFAULT_STRING_LABELER_KEY);`
70 |  | `}`
71 |  | ``
72 |  | `/**`
73 |  | `* Retunrs v.toString()`
74 |  | `*/`
75 |  | `public String getLabel(ArchetypeVertex v) {`
76 | 20 | `return v.toString();`
77 |  | `}`
78 |  | ``
79 |  | `/**`
80 |  | `* Always returns null: this impl doesn't keep a table, and so can't`
81 |  | `* meaningfully address this.`
82 |  | `*/`
83 |  | `public Vertex getVertex(String label) {`
84 | 10 | `return null;`
85 |  | `}`
86 |  | ``
87 |  | `/**`
88 |  | `* This method always throws an IllegalArgument exception: you cannot`
89 |  | `* externally set the setstring method.`
90 |  | `*/`
91 |  | `public void setLabel(Vertex v, String l) throws UniqueLabelException {`
92 | 1 | `throw new IllegalArgumentException(`
93 |  | `"Can't manually set labels on a ToString labeller");`
94 |  | `}`
95 |  | `}`

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.