KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > controller > model > DynamicModel


1 /**
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6
7        http://www.apache.org/licenses/LICENSE-2.0
8
9   * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */

15
16 package com.jdon.controller.model;
17
18 import java.util.*;
19
20 /**
21  * Dynamic Model
22  * this class can be used for DTO
23  *
24  *
25  * @author banq
26  */

27 public class DynamicModel extends Model {
28
29   private Map map = new HashMap();
30
31
32
33   public Object JavaDoc getValue(String JavaDoc key) {
34     return map.get(key);
35   }
36
37   public String JavaDoc getStringValue(String JavaDoc key) {
38     String JavaDoc value = (String JavaDoc)map.get(key);
39     if (value == null)
40       return "";
41     else
42       return value;
43   }
44
45
46   public void put(String JavaDoc key, String JavaDoc value) {
47     map.put(key, value);
48   }
49
50   public void put(String JavaDoc key, Object JavaDoc value) {
51     map.put(key, value);
52   }
53
54
55   public boolean isEmpty() {
56     return map.isEmpty();
57   }
58   
59   public String JavaDoc toString(){
60     StringBuffer JavaDoc bf = new StringBuffer JavaDoc();
61     Iterator iter = map.keySet().iterator();
62     while(iter.hasNext()){
63         Object JavaDoc o = iter.next();
64         bf.append(o.toString());
65     }
66     return bf.toString();
67   }
68
69 }
70
Popular Tags