KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > description > Transformer


1 package org.objectweb.kilim.description;
2
3 import org.objectweb.kilim.KilimException;
4
5 /**
6  * @author horn
7  */

8 public class Transformer extends BasicNamedElementImpl {
9     private BasicElement action;
10     
11     /**
12      * A public constructor to transformers.
13      * @param aName : the name associated to the transformer
14      * @param aStatus : the status of the transformer. It should be one of KILIM.PUBLIC, KILIM.PROTECTED, KILIM.PRIVATE.
15      * @param isP : is true if the transformer can be used a a provider.
16      * @param aTemplate : the template in which the transformer has been declared.
17      * @throws KilimException : generated if aName or aTemplate is null, if aStatus has an illegal value.
18      */

19     public Transformer(String JavaDoc aName, int aStatus, boolean isP, TemplateDescription aTemplate) throws KilimException {
20         super(aName, aStatus, isP, true, aTemplate);
21         action = new NullElement(aName, aStatus, isP, true, aTemplate);
22     }
23     
24     /**
25      * A public constructor to transformers (that cannot be used as a provider). It is strictly equivalent to (aName, aStatus, false, true, aTemplate, aTemplate);
26      * @param aName : the name associated to the transformer
27      * @param aStatus : the status of the transformer. It should be one of KILIM.PUBLIC, KILIM.PROTECTED, KILIM.PRIVATE.
28      * @param aTemplate : the template in which the transformer has been declared.
29      * @throws KilimException : generated if aName or aTemplate is null, if aStatus has an illegal value.
30      */

31     public Transformer(String JavaDoc aName, int aStatus, TemplateDescription aTemplate) throws KilimException {
32         super(aName, aStatus, false, true, aTemplate);
33     }
34         
35     /**
36      * @see org.objectweb.kilim.description.BasicElement#getKind()
37      */

38     public int getKind() {
39         return KILIM.TRANSFORMER;
40     }
41
42     /**
43      * sets the action (i.e. the effective mechanism represented by the transformer).
44      * @param aAction : the action to be performed by the transformer.
45      * @throws KilimException : generated if aAction is null or if aAction has not been created as an element able to perform action.
46      */

47     public void setAction(BasicElement aAction) throws KilimException {
48         if (aAction != null && !aAction.performsAction()) {
49             throw new KilimException("illegal attempt to set a non transformer inline to the transformer " + getLocalName() + " in template " + getContainingTemplate().getName());
50         }
51         action = aAction;
52     }
53     
54     /**
55      * returns the action (i.e. the effective mechanism represented by the transformer).
56      * @return InlinedElement. The action associated to the transformer.
57      * @throws KilimException : it is never generated.
58      */

59     public BasicElement getAction() throws KilimException {
60         return action;
61     }
62     
63     /**
64      * @see org.objectweb.kilim.description.TemplateElement#setLocalName(String)
65      */

66     public void setLocalName(String JavaDoc aName) throws KilimException {
67         String JavaDoc oName = getLocalName();
68         super.setLocalName(aName);
69         TemplateDescription template = getContainingTemplate();
70         if (template != null) {
71             template.removeLocalTransformer(oName);
72             template.addLocalTransformer(this);
73         }
74     }
75         
76     /**
77      * @see org.objectweb.kilim.description.TemplateElement#setStatus(int)
78      */

79     public void setStatus(int aStatus) throws KilimException {
80         super.setStatus(aStatus);
81         TemplateDescription template = getContainingTemplate();
82         if (template != null) {
83             template.removeLocalTransformer(getLocalName());
84             template.addLocalTransformer(this);
85         }
86     }
87 }
88
Popular Tags