View Javadoc

1   /*
2    * Copyright 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.commons.betwixt.digester;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  /***
22   * <code>XMLSingleMappingFileBeanInfoDigester</code> is a digester of XML files
23   * containing XMLBeanInfo definitions for a JavaBeans.
24   *
25   * @since 0.7
26   * @author Brian Pugh
27   */
28  public class MultiMappingBeanInfoDigester extends XMLBeanInfoDigester {
29      /*** <code>XMLBeanInfo</code>'s indexed by <code>Class</code> */
30      private Map beanInfoMap = new HashMap();
31      
32      // Implementation methods
33      //-------------------------------------------------------------------------
34      /***
35       * Reset configure for new digestion.
36       */
37      protected void configure() {
38          if (!configured) {
39              configured = true;
40              
41  	        // add the various rules
42  	        addRule("betwixt-config", new ConfigRule());
43  	        addRule("betwixt-config/class", new ClassRule());
44  	        addRule("*/element", new ElementRule());
45  	        addRule("*/attribute", new AttributeRule());
46  	        addRule("*/hide", new HideRule());
47  	        addRule("*/addDefaults", new AddDefaultsRule());
48  	    }
49          
50  	    // now initialize
51  	    //setAttributesForPrimitives(true);
52  	    getProcessedPropertyNameSet().clear();
53  	    getXMLIntrospector().getRegistry().flush();
54      }
55      
56      /***
57       * Map containing <code>XMLBeanInfo</code> classes.
58       * Keys are the <code>Class</code> and values are the <code>XMLBeanInfo</code> objects.
59       *
60       * @return map of XMLBeanInfos
61       */
62      public Map getBeanInfoMap() {
63          return beanInfoMap;
64      }
65      
66      /***
67       * Set the Map containing <code>XMLBeanInfo</code> classes.
68       * @param beanInfoMap map to set.
69       */
70      public void setBeanInfoMap(Map beanInfoMap) {
71          this.beanInfoMap = beanInfoMap;
72      }
73  
74  }