KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > solution > SimpleParameterProvider


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jun 22, 2005
14  * @author James Dixon
15  *
16  */

17
18 package org.pentaho.core.solution;
19
20 import java.util.*;
21
22 public class SimpleParameterProvider extends BaseParameterProvider implements IParameterProvider {
23
24     private Map parameters;
25
26     public SimpleParameterProvider() {
27         parameters = new HashMap();
28     }
29
30     protected String JavaDoc getValue(String JavaDoc name) {
31         Object JavaDoc obj = parameters.get(name);
32         return (obj == null) ? null: String.valueOf( obj );
33     }
34
35     public Object JavaDoc getParameter(String JavaDoc name) {
36         return parameters.get(name);
37     }
38
39     public SimpleParameterProvider(Map parameters) {
40             if( parameters == null ) {
41                     parameters = new HashMap();
42                 } else {
43             this.parameters = parameters;
44          }
45     }
46
47     public void setParameter(String JavaDoc name, String JavaDoc value) {
48         parameters.put(name, value);
49     }
50
51     public void setParameter(String JavaDoc name, long value) {
52         parameters.put(name, new Long JavaDoc(value));
53     }
54
55     public void setParameter(String JavaDoc name, Date value) {
56         parameters.put(name, value);
57     }
58
59     public void setParameter(String JavaDoc name, Object JavaDoc value) {
60         parameters.put(name, value);
61     }
62
63     public void setParameters(Map newParameters) {
64             if( newParameters != null ) {
65                 parameters.putAll(newParameters);
66             }
67     }
68
69     /*
70      * (non-Javadoc)
71      *
72      * @see org.pentaho.newcode.IParameterProvider#getParameterNames()
73      */

74     public Iterator getParameterNames() {
75         // TODO turn the key set iterator into an enumeration
76
return parameters.keySet().iterator();
77     }
78
79 }
80
Popular Tags