Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
32   217   24   2,29
14   78   0,75   14
14     1,71  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  TrackBack       Line # 44 32 0% 24 2 96,7% 0.96666664
 
  (76)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble.domain;
33   
34    import net.sourceforge.pebble.api.event.trackback.TrackBackEvent;
35   
36    import java.util.Date;
37   
38    /**
39    * Represents a MovableType TrackBack - see
40    * http://www.movabletype.org/docs/mttrackback.html for more information.
41    *
42    * @author Simon Brown
43    */
 
44    public class TrackBack extends Response {
45   
46    /** the excerpt */
47    private String excerpt;
48   
49    /** the url */
50    private String url;
51   
52    /** the blog name */
53    private String blogName;
54   
55    /**
56    * Creates a new TrackBack with the specified properties.
57    *
58    * @param title the title of the entry
59    * @param excerpt the excerpt of the entry
60    * @param url the url (permalink) of the entry
61    * @param blogName the name of the blog
62    * @param ipAddress the IP address of the author
63    * @param date the date that this TrackBack was left
64    * @param state the stats of this TrackBack
65    * @param blogEntry the owning blog entry
66    */
 
67  154 toggle TrackBack(String title, String excerpt, String url, String blogName, String ipAddress, Date date, State state, BlogEntry blogEntry) {
68  154 super(title, ipAddress, date, state, blogEntry);
69   
70  154 setExcerpt(excerpt);
71  154 setUrl(url);
72  154 setBlogName(blogName);
73    }
74   
75    /**
76    * Gets the title of the blog entry for this trackback.
77    *
78    * @return the title as a String
79    */
 
80  134 toggle public String getTitle() {
81  134 if (title != null && title.length() > 0) {
82  130 return title;
83    } else {
84  4 return url;
85    }
86    }
87   
88    /**
89    * Gets the excerpt of the blog entry for this trackback.
90    *
91    * @return return the excerpt as a String
92    */
 
93  90 toggle public String getExcerpt() {
94  90 return excerpt;
95    }
96   
97    /**
98    * Sets the excerpt of the blog entry for this trackback.
99    *
100    * @param excerpt the excerpt as a String
101    */
 
102  182 toggle public void setExcerpt(String excerpt) {
103  182 if (excerpt != null) {
104  180 this.excerpt = excerpt;
105    } else {
106  2 this.excerpt = "";
107    }
108    }
109   
110    /**
111    * Gets the content of this response.
112    *
113    * @return a String
114    */
 
115  60 toggle public String getContent() {
116  60 return getExcerpt();
117    }
118   
119    /**
120    * Gets the url (permalink) of the blog entry for this trackback.
121    *
122    * @return return the url as a String
123    */
 
124  56 toggle public String getUrl() {
125  56 return url;
126    }
127   
128    /**
129    * Gets the link to the source of this response.
130    *
131    * @return a String
132    */
 
133  46 toggle public String getSourceLink() {
134  46 return getUrl();
135    }
136   
137    /**
138    * Sets the url (permalink) of the blog entry for this trackback.
139    *
140    * @param url the url as a String
141    */
 
142  158 toggle public void setUrl(String url) {
143  158 this.url = url;
144    }
145   
146    /**
147    * Gets the name of the blog for this trackback.
148    *
149    * @return return the name as a String
150    */
 
151  86 toggle public String getBlogName() {
152  86 return blogName;
153    }
154   
155    /**
156    * Gets the name of the source of this response.
157    *
158    * @return a String
159    */
 
160  46 toggle public String getSourceName() {
161  46 return getBlogName();
162    }
163   
164    /**
165    * Sets the name of the blog for this trackback.
166    *
167    * @param blogName the name as a String
168    */
 
169  162 toggle public void setBlogName(String blogName) {
170  162 if (blogName != null) {
171  160 this.blogName = blogName;
172    } else {
173  2 this.blogName = "";
174    }
175    }
176   
177    /**
178    * Gets the permalink for this TrackBack.
179    *
180    * @return a URL as a String
181    */
 
182  2 toggle public String getPermalink() {
183  2 if (blogEntry != null) {
184  2 return blogEntry.getLocalPermalink() + "#trackback" + getId();
185    } else {
186  0 return "";
187    }
188    }
189   
190    /**
191    * Creates and returns a copy of this object.
192    *
193    * @return a clone of this instance.
194    * @see Cloneable
195    */
 
196  10 toggle public Object clone() {
197  10 TrackBack trackBack = new TrackBack(title, excerpt, url, blogName, ipAddress, date, getState(), blogEntry);
198  10 return trackBack;
199    }
200   
201    /**
202    * Sets the state of this TrackBack.
203    */
 
204  222 toggle void setState(State state) {
205  222 State previousState = getState();
206  222 super.setState(state);
207   
208  222 if (areEventsEnabled()) {
209  10 if (isApproved() && previousState != State.APPROVED) {
210  2 blogEntry.addEvent(new TrackBackEvent(this, TrackBackEvent.TRACKBACK_APPROVED));
211  8 } else if (isRejected() && previousState != State.REJECTED) {
212  2 blogEntry.addEvent(new TrackBackEvent(this, TrackBackEvent.TRACKBACK_REJECTED));
213    }
214    }
215    }
216   
217    }