1 18 package org.objectweb.kilim.description; 19 20 import org.objectweb.kilim.KilimException; 21 22 25 public abstract class BasicNamedElementImpl extends TemplateElementImpl implements BasicNamedElement { 26 private String localName; 27 private int status; 28 private boolean isProvider; 29 private boolean isTransformer; 30 31 41 protected BasicNamedElementImpl(String aName, int aStatus, boolean isP, boolean isT, TemplateDescription aTemplate) throws KilimException { 42 if (aName == null) { 43 if (aTemplate == null) { 44 throw new KilimException("attempt to create a named element with a null name in a null template "); 45 } else { 46 throw new KilimException("attempt to create a named element with a null name in template " + aTemplate.getName()); 47 } 48 } 49 if (aTemplate == null) { 50 throw new KilimException("attempt to create a named element " + aName + " in a null template"); 51 } 52 checkStatus(aStatus); 53 localName = aName; 54 status = aStatus; 55 isProvider = isP; 56 isTransformer = isT; 57 setContainingTemplate(aTemplate); 58 } 59 60 67 68 protected BasicNamedElementImpl(String aName, int aStatus, boolean isP, boolean isT) { 69 localName = aName; 70 status = aStatus; 71 isProvider = isP; 72 isTransformer = isT; 73 } 74 75 78 public String getLocalName() { 79 return localName; 80 } 81 82 85 86 public void setLocalName(String aName) throws KilimException { 87 if (aName == null) { 88 if (getContainingTemplate() == null) { 89 throw new KilimException("attempt to set a null name to element " + localName + " in a null template "); 90 } else { 91 throw new KilimException("attempt to set a null name to element " + localName + " in template " + getContainingTemplate().getName()); } 92 } 93 localName = aName; 94 } 95 96 99 public int getStatus() { 100 return status; 101 } 102 103 106 public void setStatus(int aStatus) throws KilimException { 107 checkStatus(aStatus); 108 status = aStatus; 109 } 110 111 114 public boolean providesValue() { 115 return isProvider; 116 } 117 118 121 public boolean performsAction() { 122 return isTransformer; 123 } 124 125 128 public boolean isEventSource() { 129 return false; 130 } 131 132 135 public void setContainingTemplate(TemplateDescription aTemplate) throws KilimException { 136 if (aTemplate == null) { 137 throw new KilimException("attempt to set a null template to element " + localName + " in template " + getContainingTemplate().getName()); 138 } 139 super.setContainingTemplate(aTemplate); 140 } 141 142 145 public String toString() { 146 return getLocalName() + "in template " + getContainingTemplate(); 147 } 148 149 private void checkStatus(int aStatus) throws KilimException { 150 if (aStatus < 1 || aStatus > 3) { 151 throw new KilimException("illegal value " + aStatus + " for element " + localName); 152 } 153 } 154 } | Popular Tags |