1. package org.apache.commons.betwixt.registry;
  2. /*
  3. * Copyright 2001-2004 The Apache Software Foundation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import java.util.HashMap;
  18. import java.util.Map;
  19. import org.apache.commons.betwixt.XMLBeanInfo;
  20. /** The default caching implementation.
  21. * A hashmap is used.
  22. *
  23. * @author <a href="mailto:rdonkin@apache.org">Robert Burrell Donkin</a>
  24. * @version $Id: DefaultXMLBeanInfoRegistry.java,v 1.6 2004/02/28 13:38:33 yoavs Exp $
  25. */
  26. public class DefaultXMLBeanInfoRegistry implements XMLBeanInfoRegistry {
  27. /** Used to associated <code>XMLBeanInfo</code>'s to classes */
  28. private Map xmlBeanInfos = new HashMap();
  29. /**
  30. * Get <code>XMLBeanInfo</code> from cache.
  31. *
  32. * @param forThisClass the class for which to find a <code>XMLBeanInfo</code>
  33. * @return cached <code>XMLBeanInfo</code> associated with given class
  34. * or <code>null</code> if no <code>XMLBeanInfo</code> has been associated
  35. */
  36. public XMLBeanInfo get(Class forThisClass) {
  37. return (XMLBeanInfo) xmlBeanInfos.get(forThisClass);
  38. }
  39. /**
  40. * Put into cache
  41. *
  42. * @param forThisClass the class to cache the <code>XMLBeanInfo</code> for
  43. * @param beanInfo the <code>XMLBeanInfo</code> to cache
  44. */
  45. public void put(Class forThisClass, XMLBeanInfo beanInfo) {
  46. xmlBeanInfos.put(forThisClass, beanInfo);
  47. }
  48. /**
  49. * Flush existing cached <code>XMLBeanInfo</code>'s.
  50. */
  51. public void flush() {
  52. xmlBeanInfos.clear();
  53. }
  54. }