KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > flow > java > VarMapHandler


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
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 package org.apache.cocoon.components.flow.java;
17
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.commons.jxpath.DynamicPropertyHandler;
24
25 /**
26  * JXPath handler for VarMap.
27  *
28  * @author <a HREF="mailto:stephan@apache.org">Stephan Michels</a>
29  * @version CVS $Id: VarMapHandler.java 30932 2004-07-29 17:35:38Z vgritsenko $
30  */

31 public class VarMapHandler implements DynamicPropertyHandler {
32
33     public String JavaDoc[] getPropertyNames(Object JavaDoc object){
34
35         Map JavaDoc map = ((VarMap)object).getMap();
36         ArrayList JavaDoc list = new ArrayList JavaDoc();
37         for(Iterator JavaDoc i=map.keySet().iterator(); i.hasNext();)
38             list.add(i.next());
39         String JavaDoc[] array = new String JavaDoc[list.size()];
40         list.toArray(array);
41         return array;
42     }
43
44     public Object JavaDoc getProperty(Object JavaDoc object, String JavaDoc property){
45
46         Map JavaDoc map = ((VarMap)object).getMap();
47         return map.get(property);
48     }
49
50     public void setProperty(Object JavaDoc object, String JavaDoc property, Object JavaDoc value){
51
52         Map JavaDoc map = ((VarMap)object).getMap();
53         map.put(property, value);
54     }
55 }
56
Popular Tags