Coverage Report - net.sf.statcvs.model.Author
 
Classes in this File Line Coverage Branch Coverage Complexity
Author
0%
0/83
0%
0/14
1.28
 
 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.16 2009/08/20 17:44:05 benoitx Exp $
 32  
  */
 33  
 public class Author implements Comparable {
 34  
     private final String name;
 35  0
     private final SortedSet revisions = new TreeSet();
 36  0
     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  0
     private boolean twitterIncludeHtml = false;
 44  0
     private boolean twitterIncludeFlash = false;
 45  
 
 46  0
     /**
 47  0
      * Creates a new author.
 48  0
      * @param name the author's login name
 49  0
      */
 50  0
     public Author(final String name) {
 51  0
         this.name = name;
 52  0
         this.realName = name;
 53  0
     }
 54  
 
 55  
     /**
 56  0
      * Adds a revision for this author; called by {@link Revision} constructor
 57  0
      * @param revision a revision committed by this author
 58  0
      */
 59  
     protected void addRevision(final Revision revision) {
 60  0
         revisions.add(revision);
 61  0
         directories.add(revision.getFile().getDirectory());
 62  0
     }
 63  
 
 64  
     /**
 65  0
      * Returns the author's login name.
 66  
      * @return the author's login name
 67  
      */
 68  
     public String getName() {
 69  0
         return name;
 70  
     }
 71  
 
 72  
     /**
 73  
      * Returns all {@link Revision}s of this author, sorted from oldest
 74  0
      * to most recent.
 75  
      * @return all revisions of this author
 76  
      */
 77  
     public SortedSet getRevisions() {
 78  0
         return revisions;
 79  
     }
 80  
 
 81  
     /**
 82  
      * Returns all {@link Directory}s the author
 83  0
      * has committed a change to, sorted by name.
 84  
      * @return a set of <tt>Directory</tt> objects
 85  
      */
 86  
     public SortedSet getDirectories() {
 87  0
         return directories;
 88  
     }
 89  
 
 90  
     /**
 91  0
      * 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  0
         return name.compareTo(((Author) o).getName());
 96  
     }
 97  
     
 98  0
     public boolean equals(final Object rhs) {
 99  0
         if (rhs == null) {
 100  0
             return false;
 101  
         }
 102  0
         if (!(rhs instanceof Author)) {
 103  0
             return false;
 104  
         }
 105  0
         final Author that = (Author) rhs;
 106  0
         if (this.getName() == null || that.getName() == null) {
 107  0
             return false;
 108  
         }
 109  0
         return this.getName().equals(that.getName());
 110  0
     }
 111  0
     
 112  
     public int hashCode() {
 113  0
         return getName().hashCode();
 114  0
     }
 115  0
 
 116  
     /**
 117  
      * {@inheritDoc}
 118  0
      */
 119  0
     public String toString() {
 120  0
         return realName + "(" + revisions.size() + " revisions)";
 121  
     }
 122  0
 
 123  0
     public String getHomePageUrl() {
 124  0
         return homePageUrl;
 125  0
     }
 126  0
 
 127  0
     public void setHomePageUrl(final String homePageUrl) {
 128  0
         this.homePageUrl = homePageUrl;
 129  0
     }
 130  
 
 131  
     public String getImageUrl() {
 132  0
         return imageUrl;
 133  0
     }
 134  
 
 135  
     public void setImageUrl(final String imageUrl) {
 136  0
         this.imageUrl = imageUrl;
 137  0
     }
 138  
 
 139  
     public String getRealName() {
 140  0
         return realName;
 141  
     }
 142  
 
 143  
     public void setRealName(final String realName) {
 144  0
         if (realName != null) {
 145  0
             this.realName = realName;
 146  
         }
 147  0
     }
 148  0
 
 149  
     public String getEmail() {
 150  0
         return email;
 151  
     }
 152  0
 
 153  0
     public void setEmail(final String email) {
 154  0
         this.email = email;
 155  0
     }
 156  0
 
 157  
     public String getTwitterUserName() {
 158  0
         return twitterUserName;
 159  
     }
 160  0
 
 161  0
     public void setTwitterUserName(final String twitterUserName) {
 162  0
         this.twitterUserName = twitterUserName;
 163  0
     }
 164  0
 
 165  
     public String getTwitterUserId() {
 166  0
         return twitterUserId;
 167  
     }
 168  0
 
 169  0
     public void setTwitterUserId(final String twitterUserId) {
 170  0
         this.twitterUserId = twitterUserId;
 171  0
     }
 172  
 
 173  
     public boolean isTwitterIncludeHtml() {
 174  0
         return twitterIncludeHtml;
 175  
     }
 176  
 
 177  
     public void setTwitterIncludeHtml(final boolean twitterIncludeHtml) {
 178  0
         this.twitterIncludeHtml = twitterIncludeHtml;
 179  0
     }
 180  
 
 181  
     public boolean isTwitterIncludeFlash() {
 182  0
         return twitterIncludeFlash;
 183  
     }
 184  
 
 185  
     public void setTwitterIncludeFlash(final boolean twitterIncludeFlash) {
 186  0
         this.twitterIncludeFlash = twitterIncludeFlash;
 187  0
     }
 188  
 }