Clover icon

Google Sitemap Module 2.4.3

  1. Project Clover database Thu May 11 2017 16:52:32 CEST
  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
280
176
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 54 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-2017 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    import javax.xml.bind.annotation.XmlType;
47   
48    /**
49    * Simple POJO containing relevant informations for the display.
50    * This bean is used as well for the XML and configuration rendering.
51    */
52    @XmlRootElement(name="url")
53    @XmlType(propOrder = {"loc", "lastmod", "changefreq", "priority"})
 
54    public class SiteMapEntry implements Comparable<SiteMapEntry>{
55   
56    public final static String PRIORITY_NAME = "priority";
57    public final static String CHANGE_FREQ_NAME = "changefreq";
58    public final static String SITE_ALERT_NAME = "styleAlert";
59    public final static String PATH_NAME = "path";
60    public final static String PAGE_NAME = "pageName";
61    public final static String FROM_NAME = "from";
62    public final static String TO_NAME = "to";
63   
64    // Used to display xml siteMaps Infos
65    private String loc;
66    private String lastmod;
67    private String changefreq;
68    private Double priority;
69    private boolean hide;
70    private boolean hideChildren;
71   
72    // Used to display edit Infos
73    private int level;
74    private String path;
75    private boolean styleAlert;
76    private String pageName;
77    private String from;
78    private String to;
79   
 
80  3 toggle public SiteMapEntry() {
81    }
82   
 
83  108 toggle public SiteMapEntry(GoogleSiteMapConfiguration configuration, String loc, Node page, int rootLevel, String changefreq, Double priority) throws RepositoryException {
84  108 this.loc = loc;
85  108 this.lastmod = configuration.getFastDateFormat().format(NodeTypes.LastModified.getLastModified(page));
86  108 this.path = page.getPath();
87  108 this.level = page.getDepth() - rootLevel;
88  108 this.changefreq = SiteMapNodeTypes.GoogleSiteMap.getChangeFreq(page) != null ? SiteMapNodeTypes.GoogleSiteMap.getChangeFreq(page) : changefreq;
89  108 this.priority = SiteMapNodeTypes.GoogleSiteMap.getPriority(page) != null ? SiteMapNodeTypes.GoogleSiteMap.getPriority(page) : priority;
90  108 this.hide = SiteMapNodeTypes.GoogleSiteMap.isHide(page);
91  108 this.hideChildren = SiteMapNodeTypes.GoogleSiteMap.isHideChildren(page);
92    }
93   
94   
95    /**
96    * Getter and Setter Section.
97    */
 
98    toggle @XmlElement
99    public String getLoc() {
100    return loc;
101    }
102   
 
103    toggle public void setLoc(String loc) {
104    this.loc = loc;
105    }
106   
 
107    toggle @XmlElement
108    public String getLastmod() {
109    return lastmod;
110    }
111   
112   
 
113    toggle public void setLastmod(String lastmod) {
114    this.lastmod = lastmod;
115    }
116   
 
117    toggle @XmlElement
118    public String getChangefreq() {
119    return changefreq;
120    }
121   
122   
 
123    toggle public void setChangefreq(String changefreq) {
124    this.changefreq = changefreq;
125    }
126   
 
127    toggle @XmlElement
128    public Double getPriority() {
129    return priority;
130    }
131   
132   
 
133    toggle public void setPriority(Double priority) {
134    this.priority = priority;
135    }
136   
 
137    toggle @XmlTransient
138    public int getLevel() {
139    return level;
140    }
141   
142   
 
143    toggle public void setLevel(int level) {
144    this.level = level;
145    }
146   
 
147    toggle @XmlTransient
148    public String getPath() {
149    return path;
150    }
151   
152   
 
153    toggle public void setPath(String path) {
154    this.path = path;
155    }
156   
 
157    toggle @XmlTransient
158    public boolean isStyleAlert() {
159    return styleAlert;
160    }
161   
162   
 
163    toggle public void setStyleAlert(boolean styleAlert) {
164    this.styleAlert = styleAlert;
165    }
166   
167   
 
168    toggle @XmlTransient
169    public String getPageName() {
170    return pageName;
171    }
172   
 
173    toggle public void setPageName(String pageName) {
174    this.pageName = pageName;
175    }
176   
 
177    toggle @XmlTransient
178    public String getFrom() {
179    return from;
180    }
181   
182   
 
183    toggle public void setFrom(String from) {
184    this.from = from;
185    }
186   
 
187    toggle @XmlTransient
188    public String getTo() {
189    return to;
190    }
191   
192   
 
193    toggle public void setTo(String to) {
194    this.to = to;
195    }
196   
 
197    toggle @XmlTransient
198    public boolean isHide() {
199    return hide;
200    }
201   
 
202    toggle public void setHide(boolean hide) {
203    this.hide = hide;
204    }
205   
 
206    toggle @XmlTransient
207    public boolean isHideChildren() {
208    return hideChildren;
209    }
210   
 
211    toggle public void setHideChildren(boolean hideChildren) {
212    this.hideChildren = hideChildren;
213    }
214   
 
215  80 toggle public String toStringDisplay(){
216  80 StringBuffer sb = new StringBuffer();
217  80 sb.append("loc :"+loc);
218  80 sb.append("lastmod :"+lastmod);
219  80 sb.append("changefreq :"+changefreq);
220  80 sb.append("priority :"+priority);
221  80 return sb.toString();
222    }
223   
 
224  48 toggle public String toStringSite(){
225  48 StringBuffer sb = new StringBuffer();
226  48 sb.append("path :"+path);
227  48 sb.append("pageName :" + pageName);
228  48 return sb.toString();
229    }
230   
 
231  0 toggle public String toStringVirtualUri(){
232  0 StringBuffer sb = new StringBuffer();
233  0 sb.append("path :"+path);
234  0 sb.append("from :"+from);
235  0 sb.append("to :"+to);
236  0 return sb.toString();
237    }
238   
239    /**
240    * Implementation for the Comparable Interface.
241    */
 
242  12 toggle @Override
243    public int compareTo(SiteMapEntry obj) {
244  12 if(obj == null) {
245  0 return -1;
246    }
247   
248  12 if (obj==this) {
249  0 return 0;
250    }
251   
252  12 return (obj).getLoc().compareTo(this.getLoc());
253   
254    }
255    /**
256    * Used for to check the unicity in the set.
257    */
 
258  10 toggle @Override
259    public boolean equals(Object obj) {
260    // Check if this is the same object
261  10 if (obj==this) {
262  9 return true;
263    }
264   
265    // Check Class Type
266  1 if (obj instanceof SiteMapEntry) {
267  1 return ((SiteMapEntry)obj).getLoc().equals(this.getLoc());
268    }
269   
270  0 return false;
271    }
272   
 
273  254 toggle @Override
274    public int hashCode() {
275  254 int hash = 15;
276  254 hash = hash * getLoc().hashCode();
277  254 return hash;
278    }
279   
280    }