1 18 package org.objectweb.kilim.description; 19 20 import org.objectweb.kilim.KilimException; 21 22 25 public class Port extends BasicNamedElementImpl { 26 27 28 public static final Port THIS_PORT = new Port(); 29 30 private Arity arity; 31 private boolean isOffered; 32 33 42 public Port(String aName, Arity aArity, int aStatus, boolean isP, TemplateDescription aTemplate) throws KilimException { 43 super(aName, aStatus, true, false, aTemplate); 44 isOffered = isP; 45 arity = aArity; 46 } 47 48 private Port() { 49 super("THIS", KILIM.PUBLIC, true, false); 50 isOffered = true; 51 arity = Arity.REQUIRED; 52 } 53 54 58 public boolean isOffered() { 59 return isOffered; 60 } 61 62 65 public int getKind() { 66 return KILIM.PORT; 67 } 68 69 72 public void setLocalName(String aName) throws KilimException { 73 String oName = getLocalName(); 74 super.setLocalName(aName); 75 TemplateDescription template = getContainingTemplate(); 76 if (template != null) { 77 template.removeLocalPort(oName); 78 template.addLocalPort(this); 79 } 80 } 81 82 85 public void setStatus(int aStatus) throws KilimException { 86 super.setStatus(aStatus); 87 TemplateDescription template = getContainingTemplate(); 88 if (template != null) { 89 template.removeLocalPort(getLocalName()); 90 template.addLocalPort(this); 91 } 92 } 93 94 97 public boolean isOptional() { 98 return arity == Arity.OPTIONAL; 99 } 100 101 104 public boolean isUnary() { 105 return arity != Arity.COLLECTION; 106 } 107 108 112 public Arity getArity() { 113 return arity; 114 } 115 116 121 public void setArity(Arity anArity) throws KilimException { 122 if (anArity == null) { 123 throw new KilimException("attempt to set a null arity to port " + getLocalName() + " in template " + getContainingTemplate().getName()); 124 } 125 arity = anArity; 126 } 127 } | Popular Tags |