1 18 19 20 package org.apache.struts.tiles.xmlDefinition; 21 22 import java.util.HashMap ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 26 import org.apache.struts.tiles.NoSuchDefinitionException; 27 28 31 public class XmlDefinitionsSet 32 { 33 34 protected Map definitions; 35 36 39 public XmlDefinitionsSet() 40 { 41 definitions = new HashMap (); 42 } 43 44 48 public void putDefinition(XmlDefinition definition) 49 { 50 definitions.put( definition.getName(), definition ); 51 } 52 53 57 public XmlDefinition getDefinition(String name) 58 { 59 return (XmlDefinition)definitions.get( name ); 60 } 61 62 65 public Map getDefinitions() 66 { 67 return definitions; 68 } 69 70 73 public void resolveInheritances() throws NoSuchDefinitionException 74 { 75 Iterator i = definitions.values().iterator(); 77 while( i.hasNext() ) 78 { 79 XmlDefinition definition = (XmlDefinition)i.next(); 80 definition.resolveInheritance( this ); 81 } } 83 84 90 public void extend( XmlDefinitionsSet child ) 91 { 92 if(child==null) 93 return; 94 Iterator i = child.getDefinitions().values().iterator(); 95 while( i.hasNext() ) 96 { 97 XmlDefinition childInstance = (XmlDefinition)i.next(); 98 XmlDefinition parentInstance = getDefinition(childInstance.getName() ); 99 if( parentInstance != null ) 100 { 101 parentInstance.overload( childInstance ); 102 } 103 else 104 putDefinition( childInstance ); 105 } } 107 110 public String toString() 111 { 112 return "definitions=" + definitions.toString() ; 113 } 114 115 } 116 | Popular Tags |