Clover Coverage Report - Google Sitemap Module 2.2
Coverage timestamp: Fri Jul 11 2014 19:21:34 CEST
../../../../../img/srcFileCovDistChart8.png 33% of files have more coverage
60   278   38   1.88
12   174   0.63   32
32     1.19  
1    
 
  SiteMapEntry       Line # 52 60 0% 38 24 76.9% 0.7692308
 
No Tests
 
1    /**
2    * This file Copyright (c) 2012 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.module.googlesitemap.bean;
35   
36   
37    import info.magnolia.jcr.util.NodeTypes;
38    import info.magnolia.module.googlesitemap.GoogleSiteMapConfiguration;
39    import info.magnolia.module.googlesitemap.SiteMapNodeTypes;
40   
41    import javax.jcr.Node;
42    import javax.jcr.RepositoryException;
43    import javax.xml.bind.annotation.XmlElement;
44    import javax.xml.bind.annotation.XmlRootElement;
45    import javax.xml.bind.annotation.XmlTransient;
46   
47    /**
48    * Simple POJO containing relevant informations for the display.
49    * This bean is used as well for the XML and configuration rendering.
50    */
51    @XmlRootElement(name="url")
 
52    public class SiteMapEntry implements Comparable<SiteMapEntry>{
53   
54    public final static String PRIORITY_NAME = "priority";
55    public final static String CHANGE_FREQ_NAME = "changefreq";
56    public final static String SITE_ALERT_NAME = "styleAlert";
57    public final static String PATH_NAME = "path";
58    public final static String PAGE_NAME = "pageName";
59    public final static String FROM_NAME = "from";
60    public final static String TO_NAME = "to";
61   
62    // Used to display xml siteMaps Infos
63    private String loc;
64    private String lastmod;
65    private String changefreq;
66    private Double priority;
67    private boolean hide;
68    private boolean hideChildren;
69   
70    // Used to display edit Infos
71    private int level;
72    private String path;
73    private boolean styleAlert;
74    private String pageName;
75    private String from;
76    private String to;
77   
 
78  3 toggle public SiteMapEntry() {
79    }
80   
 
81  108 toggle public SiteMapEntry(GoogleSiteMapConfiguration configuration, String loc, Node page, int rootLevel, String changefreq, Double priority) throws RepositoryException {
82  108 this.loc = loc;
83  108 this.lastmod = configuration.getFastDateFormat().format(NodeTypes.LastModified.getLastModified(page));
84  108 this.path = page.getPath();
85  108 this.level = page.getDepth() - rootLevel;
86  108 this.changefreq = SiteMapNodeTypes.GoogleSiteMap.getChangeFreq(page) != null ? SiteMapNodeTypes.GoogleSiteMap.getChangeFreq(page) : changefreq;
87  108 this.priority = SiteMapNodeTypes.GoogleSiteMap.getPriority(page) != null ? SiteMapNodeTypes.GoogleSiteMap.getPriority(page) : priority;
88  108 this.hide = SiteMapNodeTypes.GoogleSiteMap.isHide(page);
89  108 this.hideChildren = SiteMapNodeTypes.GoogleSiteMap.isHideChildren(page);
90    }
91   
92   
93    /**
94    * Getter and Setter Section.
95    */
 
96  319 toggle @XmlElement
97    public String getLoc() {
98  319 return loc;
99    }
100   
 
101  0 toggle public void setLoc(String loc) {
102  0 this.loc = loc;
103    }
104   
 
105  32 toggle @XmlElement
106    public String getLastmod() {
107  32 return lastmod;
108    }
109   
110   
 
111  0 toggle public void setLastmod(String lastmod) {
112  0 this.lastmod = lastmod;
113    }
114   
 
115  36 toggle @XmlElement
116    public String getChangefreq() {
117  36 return changefreq;
118    }
119   
120   
 
121  3 toggle public void setChangefreq(String changefreq) {
122  3 this.changefreq = changefreq;
123    }
124   
 
125  37 toggle @XmlElement
126    public Double getPriority() {
127  37 return priority;
128    }
129   
130   
 
131  3 toggle public void setPriority(Double priority) {
132  3 this.priority = priority;
133    }
134   
 
135  79 toggle @XmlTransient
136    public int getLevel() {
137  79 return level;
138    }
139   
140   
 
141  0 toggle public void setLevel(int level) {
142  0 this.level = level;
143    }
144   
 
145  34 toggle @XmlTransient
146    public String getPath() {
147  34 return path;
148    }
149   
150   
 
151  1 toggle public void setPath(String path) {
152  1 this.path = path;
153    }
154   
 
155  7 toggle @XmlTransient
156    public boolean isStyleAlert() {
157  7 return styleAlert;
158    }
159   
160   
 
161  48 toggle public void setStyleAlert(boolean styleAlert) {
162  48 this.styleAlert = styleAlert;
163    }
164   
165   
 
166  0 toggle @XmlTransient
167    public String getPageName() {
168  0 return pageName;
169    }
170   
 
171  48 toggle public void setPageName(String pageName) {
172  48 this.pageName = pageName;
173    }
174   
 
175  0 toggle @XmlTransient
176    public String getFrom() {
177  0 return from;
178    }
179   
180   
 
181  6 toggle public void setFrom(String from) {
182  6 this.from = from;
183    }
184   
 
185  0 toggle @XmlTransient
186    public String getTo() {
187  0 return to;
188    }
189   
190   
 
191  6 toggle public void setTo(String to) {
192  6 this.to = to;
193    }
194   
 
195  4 toggle @XmlTransient
196    public boolean isHide() {
197  4 return hide;
198    }
199   
 
200  3 toggle public void setHide(boolean hide) {
201  3 this.hide = hide;
202    }
203   
 
204  4 toggle @XmlTransient
205    public boolean isHideChildren() {
206  4 return hideChildren;
207    }
208   
 
209  1 toggle public void setHideChildren(boolean hideChildren) {
210  1 this.hideChildren = hideChildren;
211    }
212   
 
213  80 toggle public String toStringDisplay(){
214  80 StringBuffer sb = new StringBuffer();
215  80 sb.append("loc :"+loc);
216  80 sb.append("lastmod :"+lastmod);
217  80 sb.append("changefreq :"+changefreq);
218  80 sb.append("priority :"+priority);
219  80 return sb.toString();
220    }
221   
 
222  48 toggle public String toStringSite(){
223  48 StringBuffer sb = new StringBuffer();
224  48 sb.append("path :"+path);
225  48 sb.append("pageName :" + pageName);
226  48 return sb.toString();
227    }
228   
 
229  0 toggle public String toStringVirtualUri(){
230  0 StringBuffer sb = new StringBuffer();
231  0 sb.append("path :"+path);
232  0 sb.append("from :"+from);
233  0 sb.append("to :"+to);
234  0 return sb.toString();
235    }
236   
237    /**
238    * Implementation for the Comparable Interface.
239    */
 
240  10 toggle @Override
241    public int compareTo(SiteMapEntry obj) {
242  10 if(obj == null) {
243  0 return -1;
244    }
245   
246  10 if (obj==this) {
247  0 return 0;
248    }
249   
250  10 return (obj).getLoc().compareTo(this.getLoc());
251   
252    }
253    /**
254    * Used for to check the unicity in the set.
255    */
 
256  13 toggle @Override
257    public boolean equals(Object obj) {
258    // Check if this is the same object
259  13 if (obj==this) {
260  12 return true;
261    }
262   
263    // Check Class Type
264  1 if (obj instanceof SiteMapEntry) {
265  1 return ((SiteMapEntry)obj).getLoc().equals(this.getLoc());
266    }
267   
268  0 return false;
269    }
270   
 
271  254 toggle @Override
272    public int hashCode() {
273  254 int hash = 15;
274  254 hash = hash * getLoc().hashCode();
275  254 return hash;
276    }
277   
278    }