Clover icon

Google Sitemap Module 2.2.2

  1. Project Clover database Fri Dec 12 2014 14:58:23 CET
  2. Package info.magnolia.module.googlesitemap.bean

File SiteMapEntry.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
40% of files have more coverage

Code metrics

12
36
8
1
278
174
14
0.39
4.5
8
1.75
46.2% of code in this file is excluded from these metrics.

Classes

Class Line # Actions
SiteMapEntry 52 36 46.2% 14 12
0.7857142778.6%
 

Contributing tests

This file is covered by 21 tests. .

Source view

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    toggle @XmlElement
97    public String getLoc() {
98    return loc;
99    }
100   
 
101    toggle public void setLoc(String loc) {
102    this.loc = loc;
103    }
104   
 
105    toggle @XmlElement
106    public String getLastmod() {
107    return lastmod;
108    }
109   
110   
 
111    toggle public void setLastmod(String lastmod) {
112    this.lastmod = lastmod;
113    }
114   
 
115    toggle @XmlElement
116    public String getChangefreq() {
117    return changefreq;
118    }
119   
120   
 
121    toggle public void setChangefreq(String changefreq) {
122    this.changefreq = changefreq;
123    }
124   
 
125    toggle @XmlElement
126    public Double getPriority() {
127    return priority;
128    }
129   
130   
 
131    toggle public void setPriority(Double priority) {
132    this.priority = priority;
133    }
134   
 
135    toggle @XmlTransient
136    public int getLevel() {
137    return level;
138    }
139   
140   
 
141    toggle public void setLevel(int level) {
142    this.level = level;
143    }
144   
 
145    toggle @XmlTransient
146    public String getPath() {
147    return path;
148    }
149   
150   
 
151    toggle public void setPath(String path) {
152    this.path = path;
153    }
154   
 
155    toggle @XmlTransient
156    public boolean isStyleAlert() {
157    return styleAlert;
158    }
159   
160   
 
161    toggle public void setStyleAlert(boolean styleAlert) {
162    this.styleAlert = styleAlert;
163    }
164   
165   
 
166    toggle @XmlTransient
167    public String getPageName() {
168    return pageName;
169    }
170   
 
171    toggle public void setPageName(String pageName) {
172    this.pageName = pageName;
173    }
174   
 
175    toggle @XmlTransient
176    public String getFrom() {
177    return from;
178    }
179   
180   
 
181    toggle public void setFrom(String from) {
182    this.from = from;
183    }
184   
 
185    toggle @XmlTransient
186    public String getTo() {
187    return to;
188    }
189   
190   
 
191    toggle public void setTo(String to) {
192    this.to = to;
193    }
194   
 
195    toggle @XmlTransient
196    public boolean isHide() {
197    return hide;
198    }
199   
 
200    toggle public void setHide(boolean hide) {
201    this.hide = hide;
202    }
203   
 
204    toggle @XmlTransient
205    public boolean isHideChildren() {
206    return hideChildren;
207    }
208   
 
209    toggle public void setHideChildren(boolean hideChildren) {
210    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  236 toggle @Override
272    public int hashCode() {
273  236 int hash = 15;
274  236 hash = hash * getLoc().hashCode();
275  236 return hash;
276    }
277   
278    }