1 package org.exoplatform.wiki.service;
2
3 import org.exoplatform.services.jcr.util.Text;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 public class WikiPageParams {
8
9 public static final String WIKI_HOME = "WikiHome";
10
11 private String type;
12
13 private String owner;
14
15 private String pageName;
16
17 private String attachmentName;
18
19 private Map<String, String[]> parameters = new HashMap<String, String[]>();
20
21 public WikiPageParams() {
22 }
23
24 public WikiPageParams(String type, String owner, String pageName) {
25 this.type = type;
26 this.owner = (owner==null)?owner:Text.unescapeIllegalJcrChars(owner);
27 this.pageName = pageName;
28 }
29
30
31
32
33
34
35
36 public WikiPageParams(String type, String owner, String pageName, String attachmentName) {
37 super();
38 this.type = type;
39 this.owner = (owner==null)?owner:Text.unescapeIllegalJcrChars(owner);
40 this.pageName = pageName;
41 this.attachmentName = attachmentName;
42 }
43
44 public void setType(String type) {
45 this.type = type;
46 }
47
48 public String getType() {
49 return type;
50 }
51
52 public void setOwner(String owner) {
53 this.owner = (owner==null)?owner:Text.unescapeIllegalJcrChars(owner);
54 }
55
56 public String getOwner() {
57 return owner;
58 }
59
60 public void setPageName(String pageName) {
61 this.pageName = pageName;
62 }
63
64 public String getPageName() {
65 return pageName;
66 }
67
68 public String getAttachmentName() {
69 return attachmentName;
70 }
71
72 public void setAttachmentName(String attachmentName) {
73 this.attachmentName = attachmentName;
74 }
75
76 public void setParameter(String key, String[] values) {
77 parameters.put(key, values);
78 }
79
80 public String getParameter(String name) {
81 String[] values = parameters.get(name);
82 return (values == null) ? null : values[0];
83 }
84
85 public Map<String, String[]> getParameters() {
86 return parameters;
87 }
88
89 public void setParameters(Map<String, String[]> parameters) {
90 this.parameters = parameters;
91 }
92
93
94
95
96 @Override
97 public int hashCode() {
98 final int prime = 31;
99 int result = 1;
100 result = prime * result + ((attachmentName == null) ? 0 : attachmentName.hashCode());
101 result = prime * result + ((owner == null) ? 0 : owner.hashCode());
102 result = prime * result + ((pageName == null) ? 0 : pageName.hashCode());
103 result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
104 result = prime * result + ((type == null) ? 0 : type.hashCode());
105 return result;
106 }
107
108
109
110
111 @Override
112 public boolean equals(Object obj) {
113 if (this == obj)
114 return true;
115 if (obj == null)
116 return false;
117 if (getClass() != obj.getClass())
118 return false;
119 WikiPageParams other = (WikiPageParams) obj;
120 if (attachmentName == null) {
121 if (other.attachmentName != null)
122 return false;
123 } else if (!attachmentName.equals(other.attachmentName))
124 return false;
125 if (owner == null) {
126 if (other.owner != null)
127 return false;
128 } else if (!owner.equals(other.owner))
129 return false;
130 if (pageName == null) {
131 if (other.pageName != null)
132 return false;
133 } else if (!pageName.equals(other.pageName))
134 return false;
135 if (parameters == null) {
136 if (other.parameters != null)
137 return false;
138 } else if (!parameters.equals(other.parameters))
139 return false;
140 if (type == null) {
141 if (other.type != null)
142 return false;
143 } else if (!type.equals(other.type))
144 return false;
145 return true;
146 }
147
148 }