1 /**
2 This file is part of GoldenGate Project (named also GoldenGate or GG).
3
4 Copyright 2009, Frederic Bregier, and individual contributors by the @author
5 tags. See the COPYRIGHT.txt in the distribution for a full listing of
6 individual contributors.
7
8 All GoldenGate Project is free software: you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as published
10 by the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 GoldenGate is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GoldenGate . If not, see <http://www.gnu.org/licenses/>.
20 */
21 package goldengate.common.file.filesystembased;
22
23 import goldengate.common.file.OptsMLSxInterface;
24
25 /**
26 * Class that implements Opts command for MLSx operations. (-1) means not
27 * supported, 0 supported but not active, 1 supported and active
28 *
29 * @author Frederic Bregier
30 *
31 */
32 public class FilesystemBasedOptsMLSxImpl implements OptsMLSxInterface {
33 /**
34 * Size option
35 */
36 private byte optsSize = -1;
37
38 /**
39 * Modify option
40 */
41 private byte optsModify = -1;
42
43 /**
44 * Type option
45 */
46 private byte optsType = -1;
47
48 /**
49 * Perm option
50 */
51 private byte optsPerm = -1;
52
53 /**
54 * Create option
55 */
56 private byte optsCreate = -1;
57
58 /**
59 * Unique option
60 */
61 private byte optsUnique = -1;
62
63 /**
64 * Lang option
65 */
66 private byte optsLang = -1;
67
68 /**
69 * Media-Type option
70 */
71 private byte optsMediaType = -1;
72
73 /**
74 * Charset option
75 */
76 private byte optsCharset = -1;
77
78 /**
79 * Default empty constructor: no support at all of MLSx function
80 */
81 public FilesystemBasedOptsMLSxImpl() {
82 }
83
84 /**
85 * (-1) means not supported, 0 supported but not active, 1 supported and
86 * active
87 *
88 * @param optsSize
89 * @param optsModify
90 * @param optsType
91 * @param optsPerm
92 * @param optsCreate
93 * @param optsUnique
94 * @param optsLang
95 * @param optsMediaType
96 * @param optsCharset
97 */
98 public FilesystemBasedOptsMLSxImpl(byte optsSize, byte optsModify,
99 byte optsType, byte optsPerm, byte optsCreate, byte optsUnique,
100 byte optsLang, byte optsMediaType, byte optsCharset) {
101 this.optsSize = optsSize;
102 this.optsModify = optsModify;
103 this.optsType = optsType;
104 this.optsPerm = optsPerm;
105 this.optsCreate = optsCreate;
106 this.optsUnique = optsUnique;
107 this.optsLang = optsLang;
108 this.optsMediaType = optsMediaType;
109 this.optsCharset = optsCharset;
110 }
111
112 /**
113 * @return the optsCharset
114 */
115 public byte getOptsCharset() {
116 return optsCharset;
117 }
118
119 /**
120 * @param optsCharset
121 * the optsCharset to set
122 */
123 public void setOptsCharset(byte optsCharset) {
124 this.optsCharset = optsCharset;
125 }
126
127 /**
128 * @return the optsCreate
129 */
130 public byte getOptsCreate() {
131 return optsCreate;
132 }
133
134 /**
135 * @param optsCreate
136 * the optsCreate to set
137 */
138 public void setOptsCreate(byte optsCreate) {
139 this.optsCreate = optsCreate;
140 }
141
142 /**
143 * @return the optsLang
144 */
145 public byte getOptsLang() {
146 return optsLang;
147 }
148
149 /**
150 * @param optsLang
151 * the optsLang to set
152 */
153 public void setOptsLang(byte optsLang) {
154 this.optsLang = optsLang;
155 }
156
157 /**
158 * @return the optsMediaType
159 */
160 public byte getOptsMediaType() {
161 return optsMediaType;
162 }
163
164 /**
165 * @param optsMediaType
166 * the optsMediaType to set
167 */
168 public void setOptsMediaType(byte optsMediaType) {
169 this.optsMediaType = optsMediaType;
170 }
171
172 /**
173 * @return the optsModify
174 */
175 public byte getOptsModify() {
176 return optsModify;
177 }
178
179 /**
180 * @param optsModify
181 * the optsModify to set
182 */
183 public void setOptsModify(byte optsModify) {
184 this.optsModify = optsModify;
185 }
186
187 /**
188 * @return the optsPerm
189 */
190 public byte getOptsPerm() {
191 return optsPerm;
192 }
193
194 /**
195 * @param optsPerm
196 * the optsPerm to set
197 */
198 public void setOptsPerm(byte optsPerm) {
199 this.optsPerm = optsPerm;
200 }
201
202 /**
203 * @return the optsSize
204 */
205 public byte getOptsSize() {
206 return optsSize;
207 }
208
209 /**
210 * @param optsSize
211 * the optsSize to set
212 */
213 public void setOptsSize(byte optsSize) {
214 this.optsSize = optsSize;
215 }
216
217 /**
218 * @return the optsType
219 */
220 public byte getOptsType() {
221 return optsType;
222 }
223
224 /**
225 * @param optsType
226 * the optsType to set
227 */
228 public void setOptsType(byte optsType) {
229 this.optsType = optsType;
230 }
231
232 /**
233 * @return the optsUnique
234 */
235 public byte getOptsUnique() {
236 return optsUnique;
237 }
238
239 /**
240 * @param optsUnique
241 * the optsUnique to set
242 */
243 public void setOptsUnique(byte optsUnique) {
244 this.optsUnique = optsUnique;
245 }
246
247 /**
248 *
249 * @return the String associated to the feature for MLSx
250 */
251 public String getFeat() {
252 StringBuilder builder = new StringBuilder();
253 builder.append(' ');
254 if (optsSize >= 0) {
255 builder.append("Size");
256 if (optsSize > 0) {
257 builder.append("*;");
258 } else {
259 builder.append(';');
260 }
261 }
262 if (optsModify >= 0) {
263 builder.append("Modify");
264 if (optsModify > 0) {
265 builder.append("*;");
266 } else {
267 builder.append(';');
268 }
269 }
270 if (optsType >= 0) {
271 builder.append("Type");
272 if (optsType > 0) {
273 builder.append("*;");
274 } else {
275 builder.append(';');
276 }
277 }
278 if (optsPerm >= 0) {
279 builder.append("Perm");
280 if (optsPerm > 0) {
281 builder.append("*;");
282 } else {
283 builder.append(';');
284 }
285 }
286 if (optsCreate >= 0) {
287 builder.append("Create");
288 if (optsCreate > 0) {
289 builder.append("*;");
290 } else {
291 builder.append(';');
292 }
293 }
294 if (optsUnique >= 0) {
295 builder.append("Unique");
296 if (optsUnique > 0) {
297 builder.append("*;");
298 } else {
299 builder.append(';');
300 }
301 }
302 if (optsLang >= 0) {
303 builder.append("Lang");
304 if (optsLang > 0) {
305 builder.append("*;");
306 } else {
307 builder.append(';');
308 }
309 }
310 if (optsMediaType >= 0) {
311 builder.append("Media-Type");
312 if (optsMediaType > 0) {
313 builder.append("*;");
314 } else {
315 builder.append(';');
316 }
317 }
318 if (optsCharset >= 0) {
319 builder.append("Charset");
320 if (optsCharset > 0) {
321 builder.append("*;");
322 } else {
323 builder.append(';');
324 }
325 }
326 builder.append("UNIX.mode;");
327 return builder.toString();
328 }
329 }