1 package org.objectweb.kilim.description; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 import java.util.Iterator ; 6 7 import org.objectweb.kilim.KilimException; 8 9 12 13 public abstract class Trigger extends TemplateElementImpl { 14 15 public static final String [] EVENT_TYPE_NAME = { "Unbind" , "Bind"}; 16 17 18 public static final int BIND = 1; 19 20 public static final int UNBIND = 2; 21 22 private String sourceName; 23 private int kind; 24 private List transformers; 25 26 protected Trigger(String aName, int aKind) { 27 sourceName = aName; 28 kind = aKind; 29 } 30 31 35 public int getEventKind() { 36 return kind; 37 } 38 39 42 public String getSourceName() { 43 return sourceName; 44 } 45 46 49 public void setSourceName(String aName) { 50 sourceName = aName; 51 } 52 53 56 public void addTransformer(BasicElement aTransformer) throws KilimException { 57 if (aTransformer == null) { 58 throw new KilimException("illegal null value for transformer when added to a trigger in template " + getContainingTemplate().getName()); 59 } 60 61 if (!aTransformer.performsAction()) { 62 } 64 65 String name = null; 66 67 if (transformers == null) { 68 transformers = new ArrayList (); 69 } 70 71 if (transformers.contains(aTransformer)) { 72 throw new KilimException("attempt to add an already defined transformer in a trigger in template " + getContainingTemplate().getName()); 73 } 74 transformers.add(aTransformer); 75 } 76 77 80 public void removeTransformer(BasicElement aTransformer) throws KilimException { 81 if (aTransformer == null) { 82 throw new KilimException("illegal null value for transformer when removed to a trigger in template " + getContainingTemplate().getName()); 83 } 84 85 if (!aTransformer.performsAction()) { 86 throw new KilimException("attempt to remove a non transformer from a trigger in template " + getContainingTemplate().getName()); 87 } 88 89 if (transformers == null) { 90 throw new KilimException("attempt to remove a transformer from an empty trigger in template " + getContainingTemplate().getName()); 91 } 92 93 transformers.remove(aTransformer); 94 } 95 96 99 public Iterator getTransformers() { 100 if (transformers == null) { 101 return KILIM.EMPTY_ITERATOR; 102 } 103 return transformers.iterator(); 104 } 105 } | Popular Tags |