View Javadoc
1   package org.bremersee.ldaptive.transcoder;
2   
3   import org.ldaptive.ad.transcode.DeltaTimeValueTranscoder;
4   import org.ldaptive.ad.transcode.FileTimeValueTranscoder;
5   import org.ldaptive.ad.transcode.UnicodePwdValueTranscoder;
6   import org.ldaptive.dn.DefaultAttributeValueEscaper;
7   import org.ldaptive.dn.DefaultRDnNormalizer;
8   import org.ldaptive.schema.transcode.AttributeTypeValueTranscoder;
9   import org.ldaptive.transcode.BigIntegerValueTranscoder;
10  import org.ldaptive.transcode.BooleanValueTranscoder;
11  import org.ldaptive.transcode.ByteArrayValueTranscoder;
12  import org.ldaptive.transcode.DoubleValueTranscoder;
13  import org.ldaptive.transcode.FloatValueTranscoder;
14  import org.ldaptive.transcode.GeneralizedTimeValueTranscoder;
15  import org.ldaptive.transcode.IntegerValueTranscoder;
16  import org.ldaptive.transcode.LongValueTranscoder;
17  import org.ldaptive.transcode.ShortValueTranscoder;
18  import org.ldaptive.transcode.StringValueTranscoder;
19  import org.ldaptive.transcode.UUIDValueTranscoder;
20  
21  /**
22   * The value transcoder factory.
23   */
24  public abstract class ValueTranscoderFactory {
25  
26    private static AttributeTypeValueTranscoder attributeTypeValueTranscoder;
27  
28    private static BigIntegerValueTranscoder bigIntegerValueTranscoder;
29  
30    private static BooleanValueTranscoder booleanValueTranscoder;
31  
32    private static BooleanValueTranscoder booleanPrimitiveValueTranscoder;
33  
34    private static ByteArrayValueTranscoder byteArrayValueTranscoder;
35  
36    private static DeltaTimeValueTranscoder deltaTimeValueTranscoder;
37  
38    private static DnValueTranscoder dnValueTranscoder;
39  
40    private static DnValueTranscoder dnValueTranscoderCaseSensitive;
41  
42    private static DoubleValueTranscoder doubleValueTranscoder;
43  
44    private static DoubleValueTranscoder doublePrimitiveValueTranscoder;
45  
46    private static FileTimeValueTranscoder fileTimeValueTranscoder;
47  
48    private static FileTimeToOffsetDateTimeValueTranscoder fileTimeToOffsetDateTimeValueTranscoder;
49  
50    private static FloatValueTranscoder floatValueTranscoder;
51  
52    private static FloatValueTranscoder floatPrimitiveValueTranscoder;
53  
54    private static GeneralizedTimeValueTranscoder generalizedTimeValueTranscoder;
55  
56    private static GeneralizedTimeToOffsetDateTimeValueTranscoder
57        generalizedTimeToOffsetDateTimeValueTranscoder;
58  
59    private static IntegerValueTranscoder integerValueTranscoder;
60  
61    private static IntegerValueTranscoder integerPrimitiveValueTranscoder;
62  
63    private static LongValueTranscoder longValueTranscoder;
64  
65    private static LongValueTranscoder longValuePrimitiveTranscoder;
66  
67    private static ShortValueTranscoder shortValueTranscoder;
68  
69    private static ShortValueTranscoder shortPrimitiveValueTranscoder;
70  
71    private static StringValueTranscoder stringValueTranscoder;
72  
73    private static UserAccountControlValueTranscoder userAccountControlValueTranscoder;
74  
75    private static UUIDValueTranscoder uuidValueTranscoder;
76  
77    private static UnicodePwdValueTranscoder unicodePwdValueTranscoder;
78  
79    /**
80     * Instantiates a new value transcoder factory.
81     */
82    private ValueTranscoderFactory() {
83      super();
84    }
85  
86    /**
87     * Gets attribute type value transcoder.
88     *
89     * @return the attribute type value transcoder
90     */
91    public static AttributeTypeValueTranscoder getAttributeTypeValueTranscoder() {
92      if (attributeTypeValueTranscoder == null) {
93        attributeTypeValueTranscoder = new AttributeTypeValueTranscoder();
94      }
95      return attributeTypeValueTranscoder;
96    }
97  
98    /**
99     * Gets big integer value transcoder.
100    *
101    * @return the big integer value transcoder
102    */
103   public static BigIntegerValueTranscoder getBigIntegerValueTranscoder() {
104     if (bigIntegerValueTranscoder == null) {
105       bigIntegerValueTranscoder = new BigIntegerValueTranscoder();
106     }
107     return bigIntegerValueTranscoder;
108   }
109 
110   /**
111    * Gets boolean value transcoder.
112    *
113    * @return the boolean value transcoder
114    */
115   public static BooleanValueTranscoder getBooleanValueTranscoder() {
116     if (booleanValueTranscoder == null) {
117       booleanValueTranscoder = new BooleanValueTranscoder(false);
118     }
119     return booleanValueTranscoder;
120   }
121 
122   /**
123    * Gets boolean primitive value transcoder.
124    *
125    * @return the boolean primitive value transcoder
126    */
127   public static BooleanValueTranscoder getBooleanPrimitiveValueTranscoder() {
128     if (booleanPrimitiveValueTranscoder == null) {
129       booleanPrimitiveValueTranscoder = new BooleanValueTranscoder(true);
130     }
131     return booleanPrimitiveValueTranscoder;
132   }
133 
134   /**
135    * Gets byte array value transcoder.
136    *
137    * @return the byte array value transcoder
138    */
139   public static ByteArrayValueTranscoder getByteArrayValueTranscoder() {
140     if (byteArrayValueTranscoder == null) {
141       byteArrayValueTranscoder = new ByteArrayValueTranscoder();
142     }
143     return byteArrayValueTranscoder;
144   }
145 
146   /**
147    * Gets delta time value transcoder.
148    *
149    * @return the delta time value transcoder
150    */
151   public static DeltaTimeValueTranscoder getDeltaTimeValueTranscoder() {
152     if (deltaTimeValueTranscoder == null) {
153       deltaTimeValueTranscoder = new DeltaTimeValueTranscoder();
154     }
155     return deltaTimeValueTranscoder;
156   }
157 
158   /**
159    * Gets dn value transcoder.
160    *
161    * @return the dn value transcoder
162    */
163   public static DnValueTranscoder getDnValueTranscoder() {
164     if (dnValueTranscoder == null) {
165       dnValueTranscoder = new DnValueTranscoder();
166     }
167     return dnValueTranscoder;
168   }
169 
170   /**
171    * Gets dn value transcoder case sensitive.
172    *
173    * @return the dn value transcoder case-sensitive
174    */
175   public static DnValueTranscoder getDnValueTranscoderCaseSensitive() {
176     if (dnValueTranscoderCaseSensitive == null) {
177       dnValueTranscoderCaseSensitive = new DnValueTranscoder(
178           new DefaultRDnNormalizer(
179               new DefaultAttributeValueEscaper(),
180               name -> name,
181               value -> value));
182     }
183     return dnValueTranscoderCaseSensitive;
184   }
185 
186   /**
187    * Gets double value transcoder.
188    *
189    * @return the double value transcoder
190    */
191   public static DoubleValueTranscoder getDoubleValueTranscoder() {
192     if (doubleValueTranscoder == null) {
193       doubleValueTranscoder = new DoubleValueTranscoder(false);
194     }
195     return doubleValueTranscoder;
196   }
197 
198   /**
199    * Gets double primitive value transcoder.
200    *
201    * @return the double primitive value transcoder
202    */
203   public static DoubleValueTranscoder getDoublePrimitiveValueTranscoder() {
204     if (doublePrimitiveValueTranscoder == null) {
205       doublePrimitiveValueTranscoder = new DoubleValueTranscoder(true);
206     }
207     return doublePrimitiveValueTranscoder;
208   }
209 
210   /**
211    * Gets file time value transcoder.
212    *
213    * @return the file time value transcoder
214    */
215   public static FileTimeValueTranscoder getFileTimeValueTranscoder() {
216     if (fileTimeValueTranscoder == null) {
217       fileTimeValueTranscoder = new FileTimeValueTranscoder();
218     }
219     return fileTimeValueTranscoder;
220   }
221 
222   /**
223    * Gets file time to offset date time value transcoder.
224    *
225    * @return the file time to offset date time value transcoder
226    */
227   public static FileTimeToOffsetDateTimeValueTranscoder
228   getFileTimeToOffsetDateTimeValueTranscoder() {
229     if (fileTimeToOffsetDateTimeValueTranscoder == null) {
230       fileTimeToOffsetDateTimeValueTranscoder = new FileTimeToOffsetDateTimeValueTranscoder();
231     }
232     return fileTimeToOffsetDateTimeValueTranscoder;
233   }
234 
235   /**
236    * Gets float value transcoder.
237    *
238    * @return the float value transcoder
239    */
240   public static FloatValueTranscoder getFloatValueTranscoder() {
241     if (floatValueTranscoder == null) {
242       floatValueTranscoder = new FloatValueTranscoder(false);
243     }
244     return floatValueTranscoder;
245   }
246 
247   /**
248    * Gets float primitive value transcoder.
249    *
250    * @return the float primitive value transcoder
251    */
252   public static FloatValueTranscoder getFloatPrimitiveValueTranscoder() {
253     if (floatPrimitiveValueTranscoder == null) {
254       floatPrimitiveValueTranscoder = new FloatValueTranscoder(true);
255     }
256     return floatPrimitiveValueTranscoder;
257   }
258 
259   /**
260    * Gets generalized time value transcoder.
261    *
262    * @return the generalized time value transcoder
263    */
264   public static GeneralizedTimeValueTranscoder getGeneralizedTimeValueTranscoder() {
265     if (generalizedTimeValueTranscoder == null) {
266       generalizedTimeValueTranscoder = new GeneralizedTimeValueTranscoder();
267     }
268     return generalizedTimeValueTranscoder;
269   }
270 
271   /**
272    * Gets generalized time to offset date time value transcoder.
273    *
274    * @return the generalized time to offset date time value transcoder
275    */
276   public static GeneralizedTimeToOffsetDateTimeValueTranscoder
277   getGeneralizedTimeToOffsetDateTimeValueTranscoder() {
278     if (generalizedTimeToOffsetDateTimeValueTranscoder == null) {
279       generalizedTimeToOffsetDateTimeValueTranscoder
280           = new GeneralizedTimeToOffsetDateTimeValueTranscoder();
281     }
282     return generalizedTimeToOffsetDateTimeValueTranscoder;
283   }
284 
285   /**
286    * Gets integer value transcoder.
287    *
288    * @return the integer value transcoder
289    */
290   public static IntegerValueTranscoder getIntegerValueTranscoder() {
291     if (integerValueTranscoder == null) {
292       integerValueTranscoder = new IntegerValueTranscoder(false);
293     }
294     return integerValueTranscoder;
295   }
296 
297   /**
298    * Gets integer primitive value transcoder.
299    *
300    * @return the integer primitive value transcoder
301    */
302   public static IntegerValueTranscoder getIntegerPrimitiveValueTranscoder() {
303     if (integerPrimitiveValueTranscoder == null) {
304       integerPrimitiveValueTranscoder = new IntegerValueTranscoder(true);
305     }
306     return integerPrimitiveValueTranscoder;
307   }
308 
309   /**
310    * Gets long value transcoder.
311    *
312    * @return the long value transcoder
313    */
314   public static LongValueTranscoder getLongValueTranscoder() {
315     if (longValueTranscoder == null) {
316       longValueTranscoder = new LongValueTranscoder(false);
317     }
318     return longValueTranscoder;
319   }
320 
321   /**
322    * Gets long primitive value transcoder.
323    *
324    * @return the long primitive value transcoder
325    */
326   public static LongValueTranscoder getLongPrimitiveValueTranscoder() {
327     if (longValuePrimitiveTranscoder == null) {
328       longValuePrimitiveTranscoder = new LongValueTranscoder(true);
329     }
330     return longValuePrimitiveTranscoder;
331   }
332 
333   /**
334    * Gets short value transcoder.
335    *
336    * @return the short value transcoder
337    */
338   public static ShortValueTranscoder getShortValueTranscoder() {
339     if (shortValueTranscoder == null) {
340       shortValueTranscoder = new ShortValueTranscoder(false);
341     }
342     return shortValueTranscoder;
343   }
344 
345   /**
346    * Gets short primitive value transcoder.
347    *
348    * @return the short primitive value transcoder
349    */
350   public static ShortValueTranscoder getShortPrimitiveValueTranscoder() {
351     if (shortPrimitiveValueTranscoder == null) {
352       shortPrimitiveValueTranscoder = new ShortValueTranscoder(true);
353     }
354     return shortPrimitiveValueTranscoder;
355   }
356 
357   /**
358    * Gets string value transcoder.
359    *
360    * @return the string value transcoder
361    */
362   public static StringValueTranscoder getStringValueTranscoder() {
363     if (stringValueTranscoder == null) {
364       stringValueTranscoder = new StringValueTranscoder();
365     }
366     return stringValueTranscoder;
367   }
368 
369   /**
370    * Gets user account control value transcoder.
371    *
372    * @return the user account control value transcoder
373    */
374   public static UserAccountControlValueTranscoder getUserAccountControlValueTranscoder() {
375     if (userAccountControlValueTranscoder == null) {
376       userAccountControlValueTranscoder = new UserAccountControlValueTranscoder();
377     }
378     return userAccountControlValueTranscoder;
379   }
380 
381   /**
382    * Gets uuid value transcoder.
383    *
384    * @return the uuid value transcoder
385    */
386   public static UUIDValueTranscoder getUuidValueTranscoder() {
387     if (uuidValueTranscoder == null) {
388       uuidValueTranscoder = new UUIDValueTranscoder();
389     }
390     return uuidValueTranscoder;
391   }
392 
393   /**
394    * Gets unicode pwd value transcoder.
395    *
396    * @return the unicode pwd value transcoder
397    */
398   public static UnicodePwdValueTranscoder getUnicodePwdValueTranscoder() {
399     if (unicodePwdValueTranscoder == null) {
400       unicodePwdValueTranscoder = new UnicodePwdValueTranscoder();
401     }
402     return unicodePwdValueTranscoder;
403   }
404 
405 }