KickJava   Java API By Example, From Geeks To Geeks.

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


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

8 public class Provider extends BasicNamedElementImpl {
9     private BasicElement source;
10
11     /**
12      * a public constructor for providers.
13      * @param aName : the local name of the provider
14      * @param aStatus : the status of the provider. It should be one of KILIM.PRIVATE, KILIM.PROTECTED, KILIM.PUBLIC.
15      * @param isT : is true if the provider can also be used as a transformer.
16      * @param aTemplate : the template in which the provider is defined
17      * @throws KilimException : generated if aName or aTemplate is null or if the value for aStatus is invalid.
18      */

19     public Provider(String JavaDoc 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     /**
25      * a public constructor for providers. The constructor equivalent to this(aName, aStatus, false, aTemplate);
26      * @param aName : the local name of the provider
27      * @param aStatus : the status of the provider. It should be one of KILIM.PRIVATE, KILIM.PROTECTED, KILIM.PUBLIC.
28      * @param aTemplate : the template in which the provider is defined
29      * @throws KilimException : generated if aName or aTemplate is null or if the value for aStatus is invalid.
30      */

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

38     public int getKind() {
39         return KILIM.PROVIDER;
40     }
41
42     /**
43      * sets the source of the provider.
44      * @param aSource : the element providing the value.
45      * @throws KilimException : generated when the element provided as an argument does not provide a value.
46      */

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     /**
55      * returns the source.
56      * @return InlinedElement
57      * @throws KilimException :
58      */

59     public BasicElement getSource() throws KilimException {
60         return source;
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.removeLocalProvider(oName);
72             template.addLocalProvider(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.removeLocalProvider(getLocalName());
84             template.addLocalProvider(this);
85         }
86     }
87 }
Popular Tags