1 |
| package photospace.meta; |
2 |
| |
3 |
| import java.util.*; |
4 |
| import org.apache.commons.lang.builder.*; |
5 |
| import org.apache.commons.logging.*; |
6 |
| import photospace.space.*; |
7 |
| |
8 |
| public class Meta |
9 |
| implements java.io.Serializable, Cloneable |
10 |
| { |
11 |
| private static final Log log = LogFactory.getLog(Meta.class); |
12 |
| |
13 |
| public static final String PHOTO = "photo"; |
14 |
| public static final String MOVIE = "movie"; |
15 |
| public static final String AUDIO = "audio"; |
16 |
| public static final String SEARCH = "search"; |
17 |
| public static final String FOLDER = "folder"; |
18 |
| public static final String UNKNOWN = "unknown"; |
19 |
| |
20 |
| |
21 |
| private String path; |
22 |
| private String name; |
23 |
| |
24 |
| |
25 |
| private Date created; |
26 |
| private Position position = new Position(); |
27 |
| private String title; |
28 |
| private String description; |
29 |
| private String[] labels = new String[0]; |
30 |
| private Double rating; |
31 |
| private Integer ratingCount; |
32 |
| private Integer viewCount; |
33 |
| |
34 |
| |
35 |
| private Date updated; |
36 |
| |
37 |
| private String creator; |
38 |
| private CollectionMeta parent = null; |
39 |
| |
40 |
98
| public String getParentPath()
|
41 |
| { |
42 |
0
| if (path == null) return null;
|
43 |
10
| if ("/".equals(path)) return null;
|
44 |
88
| return path.substring(0, path.lastIndexOf("/") + 1);
|
45 |
| } |
46 |
| |
47 |
394
| public String getPath()
|
48 |
| { |
49 |
394
| return path;
|
50 |
| } |
51 |
| |
52 |
135
| public void setPath(String path)
|
53 |
| { |
54 |
135
| this.path = path;
|
55 |
| } |
56 |
| |
57 |
130
| public Date getCreated()
|
58 |
| { |
59 |
130
| return created;
|
60 |
| } |
61 |
| |
62 |
70
| public void setCreated(Date created)
|
63 |
| { |
64 |
70
| this.created = created;
|
65 |
| } |
66 |
| |
67 |
216
| public Position getPosition()
|
68 |
| { |
69 |
216
| return position;
|
70 |
| } |
71 |
| |
72 |
0
| public void setPosition(Position position)
|
73 |
| { |
74 |
0
| this.position = position;
|
75 |
| } |
76 |
| |
77 |
15
| public boolean getHasPosition()
|
78 |
| { |
79 |
15
| return getPosition().hasData();
|
80 |
| } |
81 |
| |
82 |
91
| public String getName()
|
83 |
| { |
84 |
91
| return name;
|
85 |
| } |
86 |
| |
87 |
48
| public void setName(String name)
|
88 |
| { |
89 |
48
| this.name = name;
|
90 |
| } |
91 |
| |
92 |
123
| public String getTitle()
|
93 |
| { |
94 |
123
| return title;
|
95 |
| } |
96 |
| |
97 |
57
| public void setTitle(String title)
|
98 |
| { |
99 |
57
| this.title = title;
|
100 |
| } |
101 |
| |
102 |
0
| public String getLabel()
|
103 |
| { |
104 |
0
| if (title != null && !"".equals(title)) return title;
|
105 |
0
| return name;
|
106 |
| } |
107 |
| |
108 |
120
| public String getDescription()
|
109 |
| { |
110 |
120
| return description;
|
111 |
| } |
112 |
| |
113 |
62
| public void setDescription(String description)
|
114 |
| { |
115 |
62
| this.description = description;
|
116 |
| } |
117 |
| |
118 |
217
| public String[] getLabels()
|
119 |
| { |
120 |
217
| return labels;
|
121 |
| } |
122 |
| |
123 |
42
| public void setLabels(String[] labels)
|
124 |
| { |
125 |
42
| this.labels = labels;
|
126 |
| } |
127 |
| |
128 |
56
| public Double getRating()
|
129 |
| { |
130 |
56
| return rating;
|
131 |
| } |
132 |
| |
133 |
0
| public void setRating(Double rating)
|
134 |
| { |
135 |
0
| this.rating = rating;
|
136 |
| } |
137 |
| |
138 |
73
| public Date getUpdated()
|
139 |
| { |
140 |
73
| return updated;
|
141 |
| } |
142 |
| |
143 |
29
| public void setUpdated(Date updated)
|
144 |
| { |
145 |
29
| this.updated = updated;
|
146 |
| } |
147 |
| |
148 |
58
| public Integer getRatingCount()
|
149 |
| { |
150 |
58
| return ratingCount;
|
151 |
| } |
152 |
| |
153 |
4
| public void setRatingCount(Integer ratingCount)
|
154 |
| { |
155 |
4
| this.ratingCount = ratingCount;
|
156 |
| } |
157 |
| |
158 |
64
| public Integer getViewCount()
|
159 |
| { |
160 |
64
| return viewCount;
|
161 |
| } |
162 |
| |
163 |
18
| public void setViewCount(Integer viewCount)
|
164 |
| { |
165 |
18
| this.viewCount = viewCount;
|
166 |
| } |
167 |
| |
168 |
42
| public boolean equals(Object o)
|
169 |
| { |
170 |
0
| if (! (o instanceof Meta)) return false;
|
171 |
42
| Meta meta = (Meta) o;
|
172 |
| |
173 |
42
| return new EqualsBuilder()
|
174 |
| .append(getPath(), meta.getPath()) |
175 |
| .isEquals(); |
176 |
| } |
177 |
| |
178 |
43
| public int hashCode()
|
179 |
| { |
180 |
43
| return new HashCodeBuilder()
|
181 |
| .append(getPath()) |
182 |
| .toHashCode(); |
183 |
| } |
184 |
| |
185 |
0
| public Object clone() throws CloneNotSupportedException
|
186 |
| { |
187 |
0
| Meta meta = (Meta) super.clone();
|
188 |
0
| if (getPosition() != null) meta.setPosition((Position) getPosition().clone());
|
189 |
0
| if (meta instanceof FolderMeta) ((FolderMeta) meta).clearFiles();
|
190 |
0
| return meta;
|
191 |
| } |
192 |
| |
193 |
| |
194 |
4
| public String toString()
|
195 |
| { |
196 |
4
| StringBuffer buf = new StringBuffer("Meta[");
|
197 |
4
| buf.append(this.getClass().getName())
|
198 |
| .append(", " + getPath()) |
199 |
| .append(", " + getCreated()) |
200 |
4
| .append(getHasPosition() ? ", has position" : ", has no position")
|
201 |
| .append("]"); |
202 |
4
| return buf.toString();
|
203 |
| } |
204 |
| |
205 |
105
| public String getCreator()
|
206 |
| { |
207 |
105
| return creator;
|
208 |
| } |
209 |
| |
210 |
1
| public void setCreator(String creator)
|
211 |
| { |
212 |
1
| this.creator = creator;
|
213 |
| } |
214 |
| |
215 |
53
| public CollectionMeta getParent()
|
216 |
| { |
217 |
53
| return parent;
|
218 |
| } |
219 |
| |
220 |
6
| public void setParent(CollectionMeta parent)
|
221 |
| { |
222 |
6
| this.parent = parent;
|
223 |
| } |
224 |
| } |