KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > registry > DefaultXMLBeanInfoRegistry


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

18
19 import java.util.HashMap JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.apache.commons.betwixt.XMLBeanInfo;
23
24 /** The default caching implementation.
25   * A hashmap is used.
26   *
27   * @author <a HREF="mailto:rdonkin@apache.org">Robert Burrell Donkin</a>
28   * @version $Id: DefaultXMLBeanInfoRegistry.java,v 1.6 2004/02/28 13:38:33 yoavs Exp $
29   */

30 public class DefaultXMLBeanInfoRegistry implements XMLBeanInfoRegistry {
31
32     /** Used to associated <code>XMLBeanInfo</code>'s to classes */
33     private Map JavaDoc xmlBeanInfos = new HashMap JavaDoc();
34     
35     /**
36       * Get <code>XMLBeanInfo</code> from cache.
37       *
38       * @param forThisClass the class for which to find a <code>XMLBeanInfo</code>
39       * @return cached <code>XMLBeanInfo</code> associated with given class
40       * or <code>null</code> if no <code>XMLBeanInfo</code> has been associated
41       */

42     public XMLBeanInfo get(Class JavaDoc forThisClass) {
43         return (XMLBeanInfo) xmlBeanInfos.get(forThisClass);
44     }
45     
46     /**
47       * Put into cache
48       *
49       * @param forThisClass the class to cache the <code>XMLBeanInfo</code> for
50       * @param beanInfo the <code>XMLBeanInfo</code> to cache
51       */

52     public void put(Class JavaDoc forThisClass, XMLBeanInfo beanInfo) {
53         xmlBeanInfos.put(forThisClass, beanInfo);
54     }
55     
56     /**
57       * Flush existing cached <code>XMLBeanInfo</code>'s.
58       */

59     public void flush() {
60         xmlBeanInfos.clear();
61     }
62 }
63
Popular Tags