KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.kilim.description;
2
3 import org.objectweb.kilim.KilimException;
4
5 /**
6  * @author horn
7  *
8  * To change this generated comment edit the template variable "typecomment":
9  * Window>Preferences>Java>Templates.
10  * To enable and disable the creation of type comments go to
11  * Window>Preferences>Java>Code Generation.
12  */

13 public abstract class TpAccessor extends InlinedElement {
14     protected BasicElement support;
15     protected String JavaDoc fieldName;
16     protected boolean isStatic;
17
18     /**
19      * The public constructor for TpAccessor.
20      * @param aSupport : the object the accessor should be applied to.
21      * @param aField : the name of the field to be accessed
22      * @param jStatic : true if the accessor is static.
23      * @param isP : true if the accessor is a getter.
24      * @param isT : true if the accessor is a setter.
25      * @param aTemplate : the template in which the accessor is defined.
26      * @throws KilimException : generated if aTemplate is null.
27      */

28     protected TpAccessor(BasicElement aSupport, String JavaDoc aField, boolean jStatic, boolean isP, boolean isT, TemplateDescription aTemplate) throws KilimException {
29         super(isP, isT, aTemplate);
30         support = aSupport;
31         fieldName = aField;
32         isStatic = jStatic;
33     }
34     
35     /**
36      * Method isStatic.
37      * @return boolean
38      */

39     public boolean isStatic() {
40         return isStatic;
41     }
42     
43     /**
44      * @see org.objectweb.kilim.description.libs.FieldAction#isStatic(boolean)
45      */

46     public void isStatic(boolean jStatic) {
47         isStatic = jStatic;
48     }
49     
50     /**
51      * @see org.objectweb.kilim.description.libs.FieldAction#getSupport()
52      */

53     public BasicElement getSupport() {
54         return support;
55     }
56     
57     /**
58      * sets the support i.e. te object the accessor will be applied to.
59      * @param aElement : the element that is the support of the accessor.
60      * @throws KilimException : generated if aElement is null or does not provide a value.
61      */

62     public void setSupport(BasicElement aElement) throws KilimException {
63         if (aElement == null) {
64             throw new KilimException("attempt to set a null support to a field transformer in template " + getContainingTemplate().getName());
65         }
66         
67         if (!aElement.providesValue()) {
68             throw new KilimException("attempt use a non provider to set the support of an accessor in template " + getContainingTemplate().getName());
69         }
70         support = aElement;
71     }
72     
73     /**
74      * returns the name of the filed to be accessed.
75      * @return String
76      */

77     public String JavaDoc getFieldName() {
78         return fieldName;
79     }
80     
81     /**
82      * sets the name of the field to be accessed.
83      * @param aFieldName : the name of the field.
84      * @throws KilimException : generated if aFieldName is null.
85      */

86     public void setFieldName(String JavaDoc aFieldName) throws KilimException {
87         if (fieldName == null) {
88             throw new KilimException("attempt to set a null name to a field of a transformer in template " + getContainingTemplate().getName());
89         }
90         fieldName = aFieldName;
91     }
92 }
Popular Tags