1
2
3
4
5
6
7
8 package com.buckosoft.PicMan.domain;
9
10 import java.io.Serializable;
11 import java.util.Comparator;
12 import java.util.Date;
13
14 public class Set implements Serializable, Comparator<Set> {
15 private static final long serialVersionUID = 1L;
16
17 public final static String FUNC_NAME_DATE = "[date]";
18 public final static int FUNC_SID_DATE = -2;
19 public final static String FUNC_NAME_ROOT = "[root]";
20 public final static int FUNC_SID_ROOT = -3;
21
22
23 private int sid;
24 private String name;
25 private String description;
26 private boolean active = true;
27 private boolean metaSet = false;
28 private boolean microSet = false;
29 private boolean nanoSet = false;
30 private Date editDate = new Date();
31
32
33
34 public Set() {
35 }
36
37
38
39
40
41 public Set(int sid, String name) {
42 this.sid = sid;
43 this.name = name;
44 }
45
46
47
48
49 public Set clone() {
50 Set set = new Set();
51 set.setSid(this.getSid());
52 set.setName(this.getName());
53 set.setDescription(this.getDescription());
54 set.setActive(this.isActive());
55 set.setMetaSet(this.isMetaSet());
56 set.setMicroSet(this.isMicroSet());
57 set.setNanoSet(this.isNanoSet());
58 set.editDate.setTime(this.editDate.getTime());
59 return(set);
60 }
61
62
63
64
65
66 public int compare(Set set0, Set set1) {
67 if (!set1.name.equals(set0.name))
68 return(set1.name.compareTo(set0.name));
69 if (!set1.description.equals(set0.description))
70 return(set1.description.compareTo(set0.description));
71 if (set0.sid != set1.sid)
72 return(set1.sid - set0.sid);
73 if (set0.active != set1.active)
74 return(set1.active ? 1 : -1);
75 if (set0.metaSet != set1.metaSet)
76 return(set1.metaSet ? 1 : -1);
77 if (set0.microSet != set1.microSet)
78 return(set1.microSet ? 1 : -1);
79 if (set0.nanoSet != set1.nanoSet)
80 return(set1.nanoSet ? 1 : -1);
81 if (set0.editDate.getTime() != set1.editDate.getTime())
82 return((int)(set1.editDate.getTime() - set0.editDate.getTime()));
83 return 0;
84 }
85
86
87
88
89
90 public int getSid() {
91 return sid;
92 }
93
94
95
96 public void setSid(int sid) {
97 this.sid = sid;
98 }
99 public void setName(String name) { this.name = name; }
100 public String getName() { return(name); }
101
102
103
104
105 public void setDescription(String description) {
106 this.description = description;
107 }
108
109 public String getDescription() { return(description); }
110
111
112
113 public boolean isActive() {
114 return active;
115 }
116
117
118
119 public void setActive(boolean active) {
120 this.active = active;
121 }
122
123
124
125 public boolean isMetaSet() {
126 return metaSet;
127 }
128
129
130
131 public void setMetaSet(boolean metaSet) {
132 this.metaSet = metaSet;
133 }
134
135
136
137 public boolean isMicroSet() {
138 return microSet;
139 }
140
141
142
143 public void setMicroSet(boolean microSet) {
144 this.microSet = microSet;
145 }
146
147
148
149
150 public boolean isNanoSet() {
151 return nanoSet;
152 }
153
154
155
156 public void setNanoSet(boolean nanoSet) {
157 this.nanoSet = nanoSet;
158 }
159
160 public boolean isFuncSet() {
161 return(this.sid < -1);
162 }
163
164
165
166
167 public Date getEditDate() {
168 return editDate;
169 }
170
171
172
173
174 public void setEditDate(Date editDate) {
175 this.editDate = editDate;
176 }
177
178
179
180 public void setEditDateNow() {
181 this.editDate = new Date();
182 }
183 }