1 5 package xdoclet.modules.jsf; 6 7 import java.util.*; 8 9 import xjavadoc.*; 10 11 import xdoclet.*; 12 13 18 public class NavigationTagsHandler extends XDocletTagSupport 19 { 20 21 private JsfNavigationRule currentRule = null; 22 private String fromViewId = null; 23 private HashMap rules = new HashMap(); 24 25 30 public void forAllRules(String template) throws XDocletException 31 { 32 Collection viewRules = (Collection) rules.get(fromViewId); 33 34 for (Iterator itr = viewRules.iterator(); itr.hasNext(); ) { 35 currentRule = (JsfNavigationRule) itr.next(); 36 generate(template); 37 } 38 } 39 40 44 public String fromView() 45 { 46 return this.fromViewId; 47 } 48 49 53 public String toView() 54 { 55 return this.currentRule.getToView(); 56 } 57 58 62 public String outcome() 63 { 64 return this.currentRule.getOutcome(); 65 } 66 67 68 73 public void forAllViews(String template) throws XDocletException 74 { 75 Collection classes = getXJavaDoc().getSourceClasses(); 76 77 for (Iterator i = classes.iterator(); i.hasNext(); ) { 78 XClass clazz = (XClass) i.next(); 79 80 setCurrentClass(clazz); 81 if (DocletSupport.isDocletGenerated(getCurrentClass())) { 82 continue; 83 } 84 if (hasRule(getCurrentClass())) { 85 for (Iterator it = getCurrentClass().getDoc().getTags("jsf.navigation").iterator(); it.hasNext(); ) { 86 XTag tag = (XTag) it.next(); 87 String fromView = tag.getAttributeValue("from"); 88 String toView = tag.getAttributeValue("to"); 89 String result = tag.getAttributeValue("result"); 90 JsfNavigationRule rule = new JsfNavigationRule(fromView, result, toView); 91 Collection r = (Collection) rules.get(fromView); 92 93 if (r == null) { 94 r = new ArrayList(); 95 } 96 r.add(rule); 97 rules.put(fromView, r); 98 } 99 } 100 } 101 for (Iterator it = rules.keySet().iterator(); it.hasNext(); ) { 102 fromViewId = it.next().toString(); 103 generate(template); 104 } 105 } 106 107 private boolean hasRule(XClass clazz) 108 { 109 return clazz.getDoc().hasTag("jsf.navigation", false); 110 } 111 112 115 private class JsfNavigationRule 116 { 117 118 private String fromView = null; 119 private String outcome = null; 120 private String toView = null; 121 122 public JsfNavigationRule(String fromView, String outcome, String toView) 123 { 124 this.fromView = fromView; 125 this.outcome = outcome; 126 this.toView = toView; 127 } 128 129 public String getFromView() 130 { 131 return fromView; 132 } 133 134 public String getOutcome() 135 { 136 return outcome; 137 } 138 139 public String getToView() 140 { 141 return toView; 142 } 143 144 } 145 } 146 | Popular Tags |