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 com.fatwire.gst.foundation.facade;
18  
19  import java.util.Date;
20  
21  import COM.FutureTense.Interfaces.FTValList;
22  
23  import com.fatwire.cs.core.db.Util;
24  
25  /**
26   * Base class for all ICS commands that accept an FTValList (like
27   * CatalogManager, runTag and CallElement)
28   * 
29   * Converts the different java types to the correct FTValList type
30   * 
31   * @author Dolf.Dijkstra
32   * 
33   */
34  
35  public class FTValListFacade {
36  
37      protected final FTValList list = new FTValList();
38  
39      public FTValListFacade() {
40          super();
41      }
42  
43      public final void set(final String key, final String value) {
44          if (value == null) {
45              list.remove(key);
46          } else {
47              list.setValString(key, value);
48          }
49      }
50  
51      public final void set(final String key, final boolean value) {
52          list.setValString(key, Boolean.toString(value));
53      }
54  
55      public final void set(final String key, final int value) {
56          list.setValInt(key, value);
57      }
58  
59      public final void set(final String key, final byte[] value) {
60          list.setValBLOB(key, value);
61      }
62  
63      public final void set(final String key, final long value) {
64  
65          list.setValString(key, Long.toString(value));
66      }
67  
68      public final void set(final String key, final Date value) {
69          if (value == null) {
70              list.remove(key);
71          } else {
72              list.setValString(key, Util.formatJdbcDate(value));
73          }
74      }
75  
76      protected final FTValList getList() {
77          return list;
78      }
79  
80  }