1 23 24 package org.objectweb.fractal.julia; 25 26 import org.objectweb.fractal.api.Component; 27 import org.objectweb.fractal.api.Interface; 28 import org.objectweb.fractal.api.Type; 29 30 33 34 public abstract class BasicComponentInterface implements ComponentInterface { 35 36 39 40 protected Component owner; 41 42 45 46 protected String name; 47 48 51 52 protected Type type; 53 54 59 60 protected int flags; 61 62 66 71 72 public BasicComponentInterface () { 73 } 74 75 86 87 public BasicComponentInterface ( 88 final Component owner, 89 final String name, 90 final Type type, 91 final boolean isInternal, 92 final Object impl) 93 { 94 boolean hasInterceptor = impl instanceof Interceptor; 95 this.owner = owner == null ? (Component)this : owner; 96 this.name = name; 97 this.type = type; 98 this.flags = (isInternal ? 0x01 : 0x00) | (hasInterceptor ? 0x02 : 0x00); 99 this.setFcItfImpl(impl); 100 } 101 102 106 public Component getFcItfOwner () { 107 return owner; 108 } 109 110 public String getFcItfName () { 111 return name; 112 } 113 114 public Type getFcItfType () { 115 return type; 116 } 117 118 public boolean isFcInternalItf () { 119 return (flags & 0x01) != 0; 120 } 121 122 126 public void setFcItfName (final String name) { 127 this.name = name; 128 } 129 130 public boolean hasFcInterceptor () { 131 return (flags & 0x02) != 0; 132 } 133 134 138 143 144 public int hashCode () { 145 return System.identityHashCode(getFcItfOwner()) * getFcItfName().hashCode(); 146 } 147 148 156 157 public boolean equals (final Object o) { 158 if (o == this) { 159 return true; 160 } 161 if (o instanceof Interface) { 162 Interface itf = (Interface)o; 163 return 164 getFcItfOwner() == itf.getFcItfOwner() && getFcItfName().equals(itf.getFcItfName()) && 166 isFcInternalItf() == itf.isFcInternalItf(); 167 } 168 return false; 169 } 170 171 public Object clone () { 172 BasicComponentInterface clone; 175 try { 176 clone = (BasicComponentInterface)getClass().newInstance(); 177 } catch (Exception e) { 178 throw new Error ("Internal error"); } 180 clone.owner = this.owner; 181 clone.name = name; 182 clone.type = type; 183 clone.flags = flags; 184 Object impl = getFcItfImpl(); 185 if (hasFcInterceptor()) { 186 impl = ((Interceptor)impl).clone(); 187 } 188 clone.setFcItfImpl(impl); 189 return clone; 190 } 191 } 192 | Popular Tags |