View Javadoc

1   /***
2    * ***************************************************************
3    * JADE - Java Agent DEvelopment Framework is a framework to develop
4    * multi-agent systems in compliance with the FIPA specifications.
5    * Copyright (C) 2000 CSELT S.p.A.
6    * 
7    * GNU Lesser General Public License
8    * 
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation,
12   * version 2.1 of the License.
13   * 
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the
21   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22   * Boston, MA  02111-1307, USA.
23   * **************************************************************
24   */
25  package JADE_SL.abs;
26  
27  import JADE_SL.schema.*;
28  
29  /***
30   * @author Federico Bergenti - Universita` di Parma
31   */
32  public class AbsVariable extends AbsObjectImpl implements AbsTerm {
33  
34      /***
35       * Construct an Abstract descriptor to hold a variable
36       */
37      public AbsVariable() {
38          super(VariableSchema.BASE_NAME);
39      }
40  
41      /***
42       * Construct an AbsVariable with the given name and value type 
43       * @param name The name of the variable.
44       * @param valueType The type of values that can be assigned to 
45       * this variable.
46       *
47       */
48      public AbsVariable(String name, String valueType) {
49          super(VariableSchema.BASE_NAME);
50  
51          setName(name);
52          setType(valueType);
53      }
54  
55      /***
56       * Sets the name of this variable.
57       * @param name The new name of this variable.
58       */
59      public void setName(String name) {
60          set(VariableSchema.NAME, AbsPrimitive.wrap(name));
61      } 
62  
63      /***
64       * Sets the value type of this variable.
65       * @param valueType The type of values that can be assigned to 
66       * this variable.
67       */
68      public void setType(String valueType) {
69          set(VariableSchema.VALUE_TYPE, AbsPrimitive.wrap(valueType));
70      } 
71  
72      /***
73       * Gets the name of this variable.
74       * @return The name of this variable.
75       */
76      public String getName() {
77          AbsPrimitive abs = (AbsPrimitive) getAbsObject(VariableSchema.NAME);
78          if (abs != null) {
79          	return abs.getString();
80          }
81          else {
82          	return null;
83          }
84      } 
85  
86      /***
87       * Gets the value type of this variable.
88       * @return The type of values that can be assigned to 
89       * this variable.
90       */
91      public String getType() {
92          AbsPrimitive abs = (AbsPrimitive) getAbsObject(VariableSchema.VALUE_TYPE);
93          if (abs != null) {
94          	return abs.getString();
95          }
96          else {
97          	return null;
98          }
99      } 
100 
101     /***
102      * Redefine the <code>isGrounded()</code> method in order to 
103      * always return <code>false</code>. 
104      */
105     public boolean isGrounded() {
106 			return false;
107     } 
108 
109 }
110