1 2 package SOFA.SOFAnode.Made.CDL; 3 4 5 public class DetectedConnector { 6 public java.util.ArrayList cRoles; public java.util.ArrayList sRoles; 8 public String [] operations; 9 public int bindMode; 10 11 public String using; 12 13 public DetectedConnector(CompBindOper cR, CompBindOper sR, int bindMode, String using) { 14 this.using=using; 15 cRoles = new java.util.ArrayList (); 16 sRoles = new java.util.ArrayList (); 17 cRoles.add(cR); 18 sRoles.add(sR); 19 this.bindMode = bindMode; 20 } 21 22 private boolean isBothZeroOrIsBothNonZero(int a, int b) { 23 if (a==0 && b==0) 24 return true; 25 if (a!=0 && b!=0) 26 return true; 27 return false; 28 } 29 30 public boolean containsSameSRole(CompBindOper sR) { 31 for (int i=0;i<sRoles.size();i++) { 32 CompBindOper sRole = (CompBindOper) sRoles.get(i); 33 if (sRole.kind == sR.kind) { 34 CompBindType t1, t2; 35 36 if (sRole.kind == CompBindOper.b_sub) { 37 sRole.subs.toFirst(); sR.subs.toFirst(); 38 t1 = (CompBindType) sRole.subs.aktual(); 39 t2 = (CompBindType) sR.subs.aktual(); 40 if (t1.name.compareTo(t2.name)!=0) { 41 continue; 42 } 43 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) { 44 continue; 45 } 46 } 47 48 sRole.elements.toFirst(); sR.elements.toFirst(); 49 t1 = (CompBindType) sRole.elements.aktual(); 50 t2 = (CompBindType) sR.elements.aktual(); 51 if (t1.name.compareTo(t2.name)!=0) { 52 continue; 53 } 54 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) { 55 continue; 56 } 57 return true; 58 } else { 59 continue; 60 } 61 } return false; 63 } 64 65 public boolean containsSameCRole(CompBindOper cR) { 66 for (int i=0;i<cRoles.size();i++) { 67 CompBindOper cRole = (CompBindOper) cRoles.get(i); 68 if (cRole.kind == cR.kind) { 69 CompBindType t1, t2; 70 71 if (cRole.kind == CompBindOper.b_sub) { 72 cRole.subs.toFirst(); cR.subs.toFirst(); 73 t1 = (CompBindType) cRole.subs.aktual(); 74 t2 = (CompBindType) cR.subs.aktual(); 75 if (t1.name.compareTo(t2.name)!=0) { 76 continue; 77 } 78 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) { 79 continue; 80 } 81 } 82 83 cRole.elements.toFirst(); cR.elements.toFirst(); 84 t1 = (CompBindType) cRole.elements.aktual(); 85 t2 = (CompBindType) cR.elements.aktual(); 86 if (t1.name.compareTo(t2.name)!=0) { 87 continue; 88 } 89 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) { 90 continue; 91 } 92 return true; 93 } else { 94 continue; 95 } 96 } return false; 98 } 99 100 public int indexOfSRole(CompBindOper sR) { 101 for (int i=0;i<sRoles.size();i++) { 102 CompBindOper sRole = (CompBindOper) sRoles.get(i); 103 if (sRole.kind == sR.kind) { 104 CompBindType t1, t2; 105 if (sRole.kind == CompBindOper.b_sub) { 106 sRole.subs.toFirst(); sR.subs.toFirst(); 107 t1 = (CompBindType) sRole.subs.aktual(); 108 t2 = (CompBindType) sR.subs.aktual(); 109 if (t1.name.compareTo(t2.name)!=0) 110 continue; 111 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) 112 continue; 113 } 114 sRole.elements.toFirst(); sR.elements.toFirst(); 115 t1 = (CompBindType) sRole.elements.aktual(); 116 t2 = (CompBindType) sR.elements.aktual(); 117 if (t1.name.compareTo(t2.name)!=0) 118 continue; 119 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) 120 continue; 121 return i; 122 } else { 123 continue; 124 } 125 } return -1; 127 } 128 129 public int indexOfCRole(CompBindOper cR) { 130 for (int i=0;i<cRoles.size();i++) { 131 CompBindOper cRole = (CompBindOper) cRoles.get(i); 132 if (cRole.kind == cR.kind) { 133 CompBindType t1, t2; 134 if (cRole.kind == CompBindOper.b_sub) { 135 cRole.subs.toFirst(); cR.subs.toFirst(); 136 t1 = (CompBindType) cRole.subs.aktual(); 137 t2 = (CompBindType) cR.subs.aktual(); 138 if (t1.name.compareTo(t2.name)!=0) 139 continue; 140 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) 141 continue; 142 } 143 cRole.elements.toFirst(); cR.elements.toFirst(); 144 t1 = (CompBindType) cRole.elements.aktual(); 145 t2 = (CompBindType) cR.elements.aktual(); 146 if (t1.name.compareTo(t2.name)!=0) 147 continue; 148 if (!isBothZeroOrIsBothNonZero(t1.exprs.size(), t2.exprs.size())) 149 continue; 150 return i; 151 } else { 152 continue; 153 } 154 } return -1; 156 } 157 158 public void addSRole(CompBindOper sR) { 159 sRoles.add(sR); 160 } 161 162 public void addCRole(CompBindOper cR) { 163 cRoles.add(cR); 164 } 165 } 166 | Popular Tags |