View Javadoc

1   /*
2   	StatCvs - CVS statistics generation 
3   	Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
4   	http://statcvs.sf.net/
5       
6   	This library is free software; you can redistribute it and/or
7   	modify it under the terms of the GNU Lesser General Public
8   	License as published by the Free Software Foundation; either
9   	version 2.1 of the License, or (at your option) any later version.
10  
11  	This library is distributed in the hope that it will be useful,
12  	but WITHOUT ANY WARRANTY; without even the implied warranty of
13  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  	Lesser General Public License for more details.
15  
16  	You should have received a copy of the GNU Lesser General Public
17  	License along with this library; if not, write to the Free Software
18  	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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.15 2009/03/10 23:24:30 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      private String twitterUserName;
42      private String twitterUserId;
43      private boolean twitterIncludeHtml = false;
44      private boolean twitterIncludeFlash = false;
45  
46      /**
47       * Creates a new author.
48       * @param name the author's login name
49       */
50      public Author(final String name) {
51          this.name = name;
52          this.realName = name;
53      }
54  
55      /**
56       * Adds a revision for this author; called by {@link Revision} constructor
57       * @param revision a revision committed by this author
58       */
59      protected void addRevision(final Revision revision) {
60          revisions.add(revision);
61          directories.add(revision.getFile().getDirectory());
62      }
63  
64      /**
65       * Returns the author's login name.
66       * @return the author's login name
67       */
68      public String getName() {
69          return name;
70      }
71  
72      /**
73       * Returns all {@link Revision}s of this author, sorted from oldest
74       * to most recent.
75       * @return all revisions of this author
76       */
77      public SortedSet getRevisions() {
78          return revisions;
79      }
80  
81      /**
82       * Returns all {@link Directory}s the author
83       * has committed a change to, sorted by name.
84       * @return a set of <tt>Directory</tt> objects
85       */
86      public SortedSet getDirectories() {
87          return directories;
88      }
89  
90      /**
91       * Compares the instance to another author, using their login names.
92       * @see java.lang.Comparable#compareTo(java.lang.Object)
93       */
94      public int compareTo(final Object o) {
95          return name.compareTo(((Author) o).getName());
96      }
97  
98      /**
99       * {@inheritDoc}
100      */
101     public String toString() {
102         return realName + "(" + revisions.size() + " revisions)";
103     }
104 
105     public String getHomePageUrl() {
106         return homePageUrl;
107     }
108 
109     public void setHomePageUrl(final String homePageUrl) {
110         this.homePageUrl = homePageUrl;
111     }
112 
113     public String getImageUrl() {
114         return imageUrl;
115     }
116 
117     public void setImageUrl(final String imageUrl) {
118         this.imageUrl = imageUrl;
119     }
120 
121     public String getRealName() {
122         return realName;
123     }
124 
125     public void setRealName(final String realName) {
126         if (realName != null) {
127             this.realName = realName;
128         }
129     }
130 
131     public String getEmail() {
132         return email;
133     }
134 
135     public void setEmail(final String email) {
136         this.email = email;
137     }
138 
139     public String getTwitterUserName() {
140         return twitterUserName;
141     }
142 
143     public void setTwitterUserName(final String twitterUserName) {
144         this.twitterUserName = twitterUserName;
145     }
146 
147     public String getTwitterUserId() {
148         return twitterUserId;
149     }
150 
151     public void setTwitterUserId(final String twitterUserId) {
152         this.twitterUserId = twitterUserId;
153     }
154 
155     public boolean isTwitterIncludeHtml() {
156         return twitterIncludeHtml;
157     }
158 
159     public void setTwitterIncludeHtml(final boolean twitterIncludeHtml) {
160         this.twitterIncludeHtml = twitterIncludeHtml;
161     }
162 
163     public boolean isTwitterIncludeFlash() {
164         return twitterIncludeFlash;
165     }
166 
167     public void setTwitterIncludeFlash(final boolean twitterIncludeFlash) {
168         this.twitterIncludeFlash = twitterIncludeFlash;
169     }
170 }