1 18 package org.objectweb.kilim.description; 19 import org.objectweb.kilim.KilimException; 20 21 24 public class Reference extends TemplateElementImpl implements BasicElement { 25 private String targetName; 26 private BasicNamedElement boundElement; 27 private boolean performsAction; 28 private boolean providesValue; 29 30 38 public Reference(String aTargetName, TemplateDescription aTemplate, boolean isP, boolean isT) throws KilimException { 39 if (aTemplate == null) { 40 throw new KilimException("null template when constructing a reference"); 41 } 42 if (aTargetName == null) { 43 throw new KilimException("null Name when constructing a reference in template " + aTemplate.getName()); 44 } 45 targetName = aTargetName; 46 providesValue = isP; 47 performsAction = isT; 48 setContainingTemplate(aTemplate); 49 } 50 51 55 public void setTargetName(String aName) { 56 if (aName == targetName) { 57 return; 58 } 59 targetName = aName; 60 boundElement = null; 61 } 62 63 67 public String getTargetName() { 68 return targetName; 69 } 70 71 74 public void setContainingTemplate(TemplateDescription aTemplate) throws KilimException { 75 if (aTemplate == null) { 76 throw new KilimException("attempt to set a null template to a reference to " + targetName + "in template " + getContainingTemplate()); 77 } 78 super.setContainingTemplate(aTemplate); 79 } 80 81 84 public String toString() { 85 if (targetName == null) { 86 return "[non initialized reference in template " + getContainingTemplate() + "]"; 87 } 88 return "[" + targetName + "]"; 89 } 90 91 94 public boolean isEventSource() { 95 return false; 96 } 97 98 101 public boolean providesValue() { 102 return providesValue; 103 } 104 105 108 public boolean performsAction() { 109 return performsAction; 110 } 111 112 115 public int getKind() { 116 return KILIM.REFERENCE; 117 } 118 } 119 | Popular Tags |