1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.googlesitemap.bean;
35
36
37 import javax.xml.bind.annotation.XmlElement;
38 import javax.xml.bind.annotation.XmlRootElement;
39 import javax.xml.bind.annotation.XmlTransient;
40
41
42
43
44
45 @XmlRootElement(name="url")
46 public class SiteMapEntry implements Comparable<SiteMapEntry>{
47
48
49 private String loc;
50 private String lastmod;
51 private String changefreq;
52 private String priority;
53
54
55 private int level;
56 private String path;
57 private boolean styleAlert;
58 private String pageName;
59 private String from;
60 private String to;
61
62 public SiteMapEntry() {
63 }
64
65
66
67
68 public SiteMapEntry(String loc, String lastmod, String changefreq, String priority, int level) {
69 this.loc = loc;
70 this.lastmod = lastmod;
71 this.changefreq = changefreq;
72 this.priority = priority;
73 this.level = level;
74 }
75
76
77
78
79 @XmlTransient
80 public String getTab() {
81 String res = " ";
82 for(int i=1;i<level;i++) {
83 res += " ";
84 }
85 return res;
86 }
87
88
89
90
91
92 @XmlElement
93 public String getLoc() {
94 return loc;
95 }
96
97 public void setLoc(String loc) {
98 this.loc = loc;
99 }
100
101 @XmlElement
102 public String getLastmod() {
103 return lastmod;
104 }
105
106
107 public void setLastmod(String lastmod) {
108 this.lastmod = lastmod;
109 }
110
111 @XmlElement
112 public String getChangefreq() {
113 return changefreq;
114 }
115
116
117 public void setChangefreq(String changefreq) {
118 this.changefreq = changefreq;
119 }
120
121 @XmlElement
122 public String getPriority() {
123 return priority;
124 }
125
126
127 public void setPriority(String priority) {
128 this.priority = priority;
129 }
130
131 @XmlTransient
132 public int getLevel() {
133 return level;
134 }
135
136
137 public void setLevel(int level) {
138 this.level = level;
139 }
140
141 @XmlTransient
142 public String getPath() {
143 return path;
144 }
145
146
147 public void setPath(String path) {
148 this.path = path;
149 }
150
151 @XmlTransient
152 public boolean isStyleAlert() {
153 return styleAlert;
154 }
155
156
157 public void setStyleAlert(boolean styleAlert) {
158 this.styleAlert = styleAlert;
159 }
160
161
162 @XmlTransient
163 public String getPageName() {
164 return pageName;
165 }
166
167
168 public void setPageName(String pageName) {
169 this.pageName = pageName;
170 }
171
172 @XmlTransient
173 public String getFrom() {
174 return from;
175 }
176
177
178 public void setFrom(String from) {
179 this.from = from;
180 }
181
182
183 public String getTo() {
184 return to;
185 }
186
187
188 public void setTo(String to) {
189 this.to = to;
190 }
191
192 public String toStringDisplay(){
193 StringBuffer sb = new StringBuffer();
194 sb.append("loc :"+loc);
195 sb.append("lastmod :"+lastmod);
196 sb.append("changefreq :"+changefreq);
197 sb.append("priority :"+priority);
198 return sb.toString();
199 }
200
201 public String toStringSite(){
202 StringBuffer sb = new StringBuffer();
203 sb.append("path :"+path);
204 sb.append("pageName :"+pageName);
205 return sb.toString();
206 }
207
208 public String toStringVirtualUri(){
209 StringBuffer sb = new StringBuffer();
210 sb.append("path :"+path);
211 sb.append("from :"+from);
212 sb.append("to :"+to);
213 return sb.toString();
214 }
215
216
217
218
219 @Override
220 public int compareTo(SiteMapEntry obj) {
221 if(obj == null) {
222 return -1;
223 }
224
225 if (obj==this) {
226 return 0;
227 }
228
229 return (obj).getLoc().compareTo(this.getLoc());
230
231 }
232
233
234
235 @Override
236 public boolean equals(Object obj) {
237
238 if (obj==this) {
239 return true;
240 }
241
242
243 if (obj instanceof SiteMapEntry) {
244 return ((SiteMapEntry)obj).getLoc().equals(this.getLoc());
245 }
246
247 return false;
248 }
249
250 @Override
251 public int hashCode() {
252 int hash = 15;
253 hash = hash * getLoc().hashCode();
254 return hash;
255 }
256
257 }