1 18 19 package org.objectweb.jac.ide; 20 21 import org.objectweb.jac.core.rtti.ClassItem; 22 import org.objectweb.jac.core.rtti.FieldItem; 23 import org.objectweb.jac.core.rtti.MethodItem; 24 25 import java.util.List ; 26 import java.util.Vector ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 34 public class ConfigItem { 35 36 private AspectConfiguration aspectConfiguration; 37 38 39 private MethodItem method; 40 41 42 private ModelElement modelElement; 43 44 45 private List param = new Vector (); 46 47 50 public ConfigItem() { 51 } 52 53 public AspectConfiguration getAspectConfiguration() { 54 return aspectConfiguration; 55 } 56 57 public ModelElement getModelElement() { 58 return modelElement; 59 } 60 61 public List getParam() { 62 return param; 63 } 64 65 public MethodItem getMethod() { 66 return method; 67 } 68 69 72 public void setAspectConfiguration(AspectConfiguration aspectConfiguration) { 73 this.aspectConfiguration = aspectConfiguration; 74 } 75 public void addParam(String param) { 76 this.param.add(param); 77 } 78 79 public void removeParam(String param) { 80 this.param.remove(param); 81 } 82 83 public void setModelElement(ModelElement modelElement) { 84 this.modelElement = modelElement; 85 } 86 87 public void setMethod(MethodItem newMethod) { 88 this.method = newMethod; 89 } 90 91 public String toString() { 92 return "ConfigItem "+modelElement+" "+method+" "+aspectConfiguration; 93 } 94 95 98 public static Collection getAvailableAspects(ConfigItem item) { 99 ModelElement element = item.getModelElement(); 100 Vector configs = new Vector (); 101 if (element instanceof Class ) { 102 Iterator i = ((Class )element).getProject().getApplications().iterator(); 103 while (i.hasNext()) { 104 Application app = (Application)i.next(); 105 configs.addAll(app.getAspectConfigurations()); 106 } 107 } 108 return configs; 109 } 110 111 116 public final static Collection getValidMethods(ConfigItem item) throws Exception { 117 Vector list = new Vector (); 118 AspectConfiguration aspect = item.getAspectConfiguration(); 119 ModelElement element = item.getModelElement(); 121 if ((aspect==null)||(element==null)) { 122 return list; 123 } 124 125 Iterator iteMethods = aspect.getConfigurationMethods().iterator(); 127 while(iteMethods.hasNext()) { 128 MethodItem method = (MethodItem)iteMethods.next(); 129 java.lang.Class param; 131 if (method.getParameterCount()==0) { 133 param = Project.class; 134 }else{ 135 param = method.getParameterTypes()[0]; 136 } 137 138 if ((param==ClassItem.class)&&(element.getClass()==Class .class)) { 140 list.add(method); 141 continue; 142 } 143 if ((param==FieldItem.class)&&(element.getClass()==Field.class)) { 145 list.add(method); 146 continue; 147 } 148 if ((param==MethodItem.class)&&(element.getClass()==Method.class)) { 150 list.add(method); 151 continue; 152 } 153 if (element.getClass()==Project.class) { 155 list.add(method); 156 } 157 } 160 return list; 161 } 162 } 163 | Popular Tags |