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