1 5 6 package org.infohazard.maverick.flow; 7 8 import java.util.Map ; 9 import java.util.HashMap ; 10 import java.util.List ; 11 import java.util.ArrayList ; 12 import java.util.Iterator ; 13 14 17 class ViewRegistryShunted extends ViewRegistry 18 { 19 22 static class ModeData 23 { 24 public String mode; 25 public View view; 26 27 public ModeData(String mode, View v) 28 { 29 this.mode = mode; 30 this.view = v; 31 } 32 } 33 34 37 protected Map globalModeLists = new HashMap (); 38 39 41 protected ShuntFactory shuntFact; 42 43 45 public ViewRegistryShunted(MasterFactory masterFact, ShuntFactory shuntFact) 46 { 47 super(masterFact); 48 49 this.shuntFact = shuntFact; 50 } 51 52 54 protected void defineGlobalView(String id, String mode, View v) throws ConfigException 55 { 56 List modesForId = (List )this.globalModeLists.get(id); 57 if (modesForId == null) 58 { 59 modesForId = new ArrayList (); 60 this.globalModeLists.put(id, modesForId); 61 } 62 63 modesForId.add(new ModeData(mode, v)); 64 } 65 66 68 protected void addView(Map target, String viewName, String ref) throws ConfigException 69 { 70 List modesForId = (List )this.globalModeLists.get(ref); 71 if (modesForId == null) 72 throw new ConfigException("Unknown global view \"" + ref + "\" was referenced."); 73 74 Iterator it = modesForId.iterator(); 75 while (it.hasNext()) 76 { 77 ModeData data = (ModeData)it.next(); 78 79 this.addView(target, viewName, data.mode, data.view); 80 } 81 } 82 83 85 protected void addView(Map target, String viewName, String mode, View v) throws ConfigException 86 { 87 ViewShunted shunted = (ViewShunted)target.get(viewName); 88 if (shunted == null) 89 { 90 shunted = new ViewShunted(this.shuntFact.createShunt()); 91 target.put(viewName, shunted); 92 } 93 94 shunted.defineMode(mode, v); 95 } 96 } | Popular Tags |