1 26 27 package org.objectweb.openccm.ast.utils.lib; 28 29 import org.objectweb.openccm.ast.api.DeclarationKind; 31 import org.objectweb.openccm.ast.api.Declaration; 32 import org.objectweb.openccm.ast.api.ComponentDecl; 33 import org.objectweb.openccm.ast.api.HomeExecutorDecl; 34 import org.objectweb.openccm.ast.api.ExecutorDecl; 35 import org.objectweb.openccm.ast.api.SegmentDecl; 36 import org.objectweb.openccm.ast.api.InterfacePortDecl; 37 import org.objectweb.openccm.ast.api.EventPortDecl; 38 import java.util.List ; 39 import java.util.ArrayList ; 40 41 48 49 public class ExecutorInfo 50 implements org.objectweb.openccm.ast.utils.api.ExecutorInfo 51 { 52 58 59 private ExecutorDecl exec_; 60 61 62 private ComponentDecl comp_; 63 64 70 75 public ExecutorInfo(ExecutorDecl exec) 76 { 77 HomeExecutorDecl home_exec = null; 78 79 exec_ = exec; 81 82 home_exec = (HomeExecutorDecl) exec.getParent(); 84 comp_ = home_exec.getHomeType().getManagedComponent(); 85 } 86 87 93 96 protected void 97 removeSegmentFacets( SegmentDecl seg, 98 List implemented_facets ) 99 { 100 ComponentDecl current = null; 101 String [] facets = null; 102 String [] sinks = null; 103 104 facets = seg.getFacetList().getStrings(); 107 for (int i=0; i<facets.length; i++) 108 { 109 InterfacePortDecl itf_port = null; 110 111 current = comp_; 112 while ((itf_port == null) && (current != null)) 113 { 114 itf_port = (InterfacePortDecl) current.lookup(facets[i]); 115 current = current.getBaseComponent(); 117 } 118 implemented_facets.remove(itf_port); 119 } 120 121 sinks = seg.getSinkList().getStrings(); 124 for (int i=0; i<sinks.length; i++) 125 { 126 EventPortDecl event_port = null; 127 128 current = comp_; 129 while ((event_port == null) && (current != null)) 130 { 131 event_port = (EventPortDecl) current.lookup(sinks[i]); 132 current = current.getBaseComponent(); 134 } 135 implemented_facets.remove(event_port); 136 } 137 } 138 139 145 151 public Declaration[] 152 getMainSegmentFacets() 153 { 154 Declaration[] decls = null; 155 List implemented_facets = new ArrayList (); 156 157 decls = comp_.getContents( false, 159 DeclarationKind.dk_provides 160 + DeclarationKind.dk_consumes ); 161 for (int i=0; i<decls.length; i++) 162 { 163 implemented_facets.add( decls[i] ); 164 } 165 166 decls = exec_.getContents(true, DeclarationKind.dk_segment); 168 for (int i=0; i<decls.length; i++) 169 { 170 removeSegmentFacets( (SegmentDecl) decls[i], 171 implemented_facets ); 172 } 173 174 return (Declaration[]) implemented_facets.toArray(new Declaration[0]); 175 } 176 177 183 } 184 | Popular Tags |