1 package org.objectweb.kilim.description; 2 3 import org.objectweb.kilim.KilimException; 4 5 8 public class Provider extends BasicNamedElementImpl { 9 private BasicElement source; 10 11 19 public Provider(String aName, int aStatus, boolean isT, TemplateDescription aTemplate) throws KilimException { 20 super(aName, aStatus, true, isT, aTemplate); 21 source = new NullElement(aName, aStatus, true, isT, aTemplate); 22 } 23 24 31 public Provider(String aName, int aStatus, TemplateDescription aTemplate) throws KilimException { 32 super(aName, aStatus, true, false, aTemplate); 33 } 34 35 38 public int getKind() { 39 return KILIM.PROVIDER; 40 } 41 42 47 public void setSource(BasicElement aSource) throws KilimException { 48 if (aSource != null && !aSource.providesValue()) { 49 throw new KilimException("illegal attempt to set a non provider inline to the provider " + getLocalName()); 50 } 51 source = aSource; 52 } 53 54 59 public BasicElement getSource() throws KilimException { 60 return source; 61 } 62 63 66 public void setLocalName(String aName) throws KilimException { 67 String oName = getLocalName(); 68 super.setLocalName(aName); 69 TemplateDescription template = getContainingTemplate(); 70 if (template != null) { 71 template.removeLocalProvider(oName); 72 template.addLocalProvider(this); 73 } 74 } 75 76 79 public void setStatus(int aStatus) throws KilimException { 80 super.setStatus(aStatus); 81 TemplateDescription template = getContainingTemplate(); 82 if (template != null) { 83 template.removeLocalProvider(getLocalName()); 84 template.addLocalProvider(this); 85 } 86 } 87 } | Popular Tags |