1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.statcvs.model;
21
22 import java.util.SortedSet;
23 import java.util.TreeSet;
24
25 /**
26 * Represents an author of one or more {@link Revision}s in a repository.
27 *
28 * TODO: Rename to <tt>Login</tt>
29 *
30 * @author Richard Cyganiak <richard@cyganiak.de>
31 * @version $Id: Author.java,v 1.14 2008/04/02 11:22:16 benoitx Exp $
32 */
33 public class Author implements Comparable {
34 private final String name;
35 private final SortedSet revisions = new TreeSet();
36 private final SortedSet directories = new TreeSet();
37 private String realName;
38 private String homePageUrl;
39 private String imageUrl;
40 private String email;
41
42 /**
43 * Creates a new author.
44 * @param name the author's login name
45 */
46 public Author(final String name) {
47 this.name = name;
48 this.realName = name;
49 }
50
51 /**
52 * Adds a revision for this author; called by {@link Revision} constructor
53 * @param revision a revision committed by this author
54 */
55 protected void addRevision(final Revision revision) {
56 revisions.add(revision);
57 directories.add(revision.getFile().getDirectory());
58 }
59
60 /**
61 * Returns the author's login name.
62 * @return the author's login name
63 */
64 public String getName() {
65 return name;
66 }
67
68 /**
69 * Returns all {@link Revision}s of this author, sorted from oldest
70 * to most recent.
71 * @return all revisions of this author
72 */
73 public SortedSet getRevisions() {
74 return revisions;
75 }
76
77 /**
78 * Returns all {@link Directory}s the author
79 * has committed a change to, sorted by name.
80 * @return a set of <tt>Directory</tt> objects
81 */
82 public SortedSet getDirectories() {
83 return directories;
84 }
85
86 /**
87 * Compares the instance to another author, using their login names.
88 * @see java.lang.Comparable#compareTo(java.lang.Object)
89 */
90 public int compareTo(final Object o) {
91 return name.compareTo(((Author) o).getName());
92 }
93
94 /**
95 * {@inheritDoc}
96 */
97 public String toString() {
98 return realName + "(" + revisions.size() + " revisions)";
99 }
100
101 public String getHomePageUrl() {
102 return homePageUrl;
103 }
104
105 public void setHomePageUrl(final String homePageUrl) {
106 this.homePageUrl = homePageUrl;
107 }
108
109 public String getImageUrl() {
110 return imageUrl;
111 }
112
113 public void setImageUrl(final String imageUrl) {
114 this.imageUrl = imageUrl;
115 }
116
117 public String getRealName() {
118 return realName;
119 }
120
121 public void setRealName(final String realName) {
122 if (realName != null) {
123 this.realName = realName;
124 }
125 }
126
127 public String getEmail() {
128 return email;
129 }
130
131 public void setEmail(final String email) {
132 this.email = email;
133 }
134 }