View Javadoc
1   /*
2    * Copyright 2008 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package tools.gsf.facade;
18  
19  import COM.FutureTense.Interfaces.FTValList;
20  import com.fatwire.cs.core.db.Util;
21  
22  import java.util.Date;
23  
24  /**
25   * Base class for all ICS commands that accept an FTValList (like
26   * CatalogManager, runTag and CallElement)
27   * <p>
28   * Converts the different java types to the correct FTValList type
29   *
30   * @author Dolf.Dijkstra
31   */
32  
33  public class FTValListFacade {
34  
35      protected final FTValList list = new FTValList();
36  
37      public FTValListFacade() {
38          super();
39      }
40  
41      public final void set(final String key, final String value) {
42          if (value == null) {
43              list.remove(key);
44          } else {
45              list.setValString(key, value);
46          }
47      }
48  
49      public final void set(final String key, final boolean value) {
50          list.setValString(key, Boolean.toString(value));
51      }
52  
53      public final void set(final String key, final int value) {
54          list.setValInt(key, value);
55      }
56  
57      public final void set(final String key, final byte[] value) {
58          list.setValBLOB(key, value);
59      }
60  
61      public final void set(final String key, final long value) {
62  
63          list.setValString(key, Long.toString(value));
64      }
65  
66      public final void set(final String key, final Date value) {
67          if (value == null) {
68              list.remove(key);
69          } else {
70              list.setValString(key, Util.formatJdbcDate(value));
71          }
72      }
73  
74      protected final FTValList getList() {
75          return list;
76      }
77  
78  }