1 17 18 package com.finalist.jag.skelet; 19 20 21 import java.util.*; 22 23 24 31 public class SkeletDataObj extends ModuleData { 32 33 34 private JagSkeletConfig config = null; 35 36 37 44 public SkeletDataObj(String name) { 45 super(name, new ArrayList()); 46 } 47 48 49 56 public JagSkeletConfig getConfig() { 57 return (this.config); 58 } 59 60 61 68 public void setConfig(JagSkeletConfig config) { 69 this.config = config; 70 } 71 72 73 80 public void processReferences() throws JagSkeletException { 81 82 HashMap refNames = new HashMap(); 83 84 createRefMap(this, refNames); 85 replaceReferences(this, refNames); 86 } 87 88 89 99 protected void createRefMap(ModuleData root, HashMap refNames) 100 throws JagSkeletException { 101 102 Collection modules = (Collection) getValue(); 103 Iterator iterator = modules.iterator(); 104 105 while (iterator.hasNext()) { 106 SkeletModule module = (SkeletModule) iterator.next(); 107 108 if (!"".equals(module.getRefname()) && refNames.get(module.getRefname()) != null) { 109 throw new JagSkeletException( 110 "Found duplicate ref-name field : " 111 + module.getRefname()); 112 } 113 114 refNames.put(module.getRefname(), module); 115 } 116 } 117 118 119 127 protected void replaceReferences(ModuleData root, HashMap refNames) { 128 129 Collection modules = (Collection) getValue(); 130 Iterator iterator = modules.iterator(); 131 132 while (iterator.hasNext()) { 133 SkeletModule module = (SkeletModule) iterator.next(); 134 Collection refs = module.getRefs(); 135 Iterator iteratorRefs = refs.iterator(); 136 137 while (iteratorRefs.hasNext()) { 138 SkeletModule refModule = 139 (SkeletModule) refNames.get((String ) iteratorRefs.next()); 140 141 ((Collection) module.getValue()).add(refModule); 142 } 143 } 144 } 145 } | Popular Tags |