1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.macro.rss

File RssMacroParameters.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
16
13
1
190
81
14
0.88
1.23
13
1.08

Classes

Class Line # Actions
RssMacroParameters 36 16 0% 14 3
0.896551789.7%
 

Contributing tests

This file is covered by 8 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.macro.rss;
21   
22    import java.net.MalformedURLException;
23    import java.net.URL;
24   
25    import org.apache.commons.lang3.StringUtils;
26    import org.xwiki.properties.annotation.PropertyDescription;
27    import org.xwiki.properties.annotation.PropertyMandatory;
28    import org.xwiki.rendering.macro.parameter.MacroParameterException;
29   
30    /**
31    * Parameters for the {@link org.xwiki.rendering.internal.macro.rss.RssMacro} Macro.
32    *
33    * @version $Id: c807a5af3f2710e15a9364f87fc70360d043c77f $
34    * @since 1.8RC1
35    */
 
36    public class RssMacroParameters
37    {
38    /**
39    * The URL of the RSS feed.
40    */
41    private String feed;
42   
43    /**
44    * If "true" displays the content of each feed in addition to the feed item link.
45    */
46    private boolean content;
47   
48    /**
49    * The number of feed items to display.
50    */
51    private int count = 10;
52   
53    /**
54    * If "true" and if the feed has an image, display it.
55    */
56    private boolean image;
57   
58    /**
59    * The width of the enclosing box containing the RSS macro output.
60    */
61    private String width = StringUtils.EMPTY;
62   
63    /**
64    * @see #setDecoration(boolean)
65    */
66    private boolean decoration = true;
67   
68    /**
69    * The RSS feed URL.
70    */
71    private URL feedURL;
72   
73    /**
74    * @return the RSS feed URL.
75    */
 
76  25 toggle public String getFeed()
77    {
78  25 return feed;
79    }
80   
81    /**
82    * @param feed the RSS feed URL.
83    * @throws MacroParameterException if the feed URL is malformed.
84    */
 
85  13 toggle @PropertyMandatory
86    @PropertyDescription("URL of the RSS feed")
87    public void setFeed(String feed) throws MacroParameterException
88    {
89  13 this.feed = feed;
90  13 try {
91  13 this.feedURL = new java.net.URL(feed);
92    } catch (MalformedURLException ex) {
93  0 throw new MacroParameterException("Malformed feed URL", ex);
94    }
95    }
96   
97    /**
98    * @param image whether to display the feed's image.
99    */
 
100  4 toggle @PropertyDescription("If the feeds has an image associated, display it?")
101    public void setImage(boolean image)
102    {
103  4 this.image = image;
104    }
105   
106    /**
107    * @return whether to display the feed's image.
108    */
 
109  10 toggle public boolean isImage()
110    {
111  10 return image;
112    }
113   
114    /**
115    * @param width the width of the RSS box, that will dismiss potential CSS rules defining its default value.
116    */
 
117  0 toggle @PropertyDescription("The width, in px or %, of the box containing the RSS output (default is 30%)")
118    public void setWidth(String width)
119    {
120  0 this.width = width;
121    }
122   
123    /**
124    * @return the width of the RSS box, that will dismiss potential CSS rules defining its default value.
125    */
 
126  10 toggle public String getWidth()
127    {
128  10 return this.width;
129    }
130   
131    /**
132    * @param count the number of feed items to display.
133    */
 
134  6 toggle @PropertyDescription("The maximum number of feed items to display on the page.")
135    public void setCount(int count)
136    {
137  6 this.count = count;
138    }
139   
140    /**
141    * @return the number of feed items to display.
142    */
 
143  12 toggle public int getCount()
144    {
145  12 return count;
146    }
147   
148    /**
149    * @return the feed's URL
150    */
 
151  6 toggle public URL getFeedURL()
152    {
153  6 return feedURL;
154    }
155   
156    /**
157    * @param content if "true" displays the content of each feed in addition to the feed item link
158    */
 
159  6 toggle @PropertyDescription("Display content for feed entries")
160    public void setContent(boolean content)
161    {
162  6 this.content = content;
163    }
164   
165    /**
166    * @return true if the content of each feed should be displayed
167    */
 
168  16 toggle public boolean isContent()
169    {
170  16 return this.content;
171    }
172   
173    /**
174    * @param decoration if "true" displays UI decorations around feed and feed entries (RSS feed icon, feed items in
175    * boxes, etc).
176    */
 
177  2 toggle @PropertyDescription("Display UI decorations around feed and feed entries")
178    public void setDecoration(boolean decoration)
179    {
180  2 this.decoration = decoration;
181    }
182   
183    /**
184    * @return true if UI decorations should be displayed
185    */
 
186  12 toggle public boolean isDecoration()
187    {
188  12 return this.decoration;
189    }
190    }