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.onto.basic;
26
27 import JADE_SL.*;
28 import JADE_SL.abs.*;
29 import JADE_SL.onto.*;
30 import zeus.concepts.FIPA_AID_Address;
31
32 public class Action implements AgentAction, Introspectable {
33 private FIPA_AID_Address actor;
34 private Concept action;
35
36 public Action() {
37 actor = null;
38 action = null;
39 }
40
41 public Action(FIPA_AID_Address id, Concept a) {
42 setActor(id);
43 setAction(a);
44 }
45
46 public FIPA_AID_Address getActor() {
47 return actor;
48 }
49
50 public void setActor(FIPA_AID_Address id) {
51 actor = id;
52 }
53
54 public Concept getAction() {
55 return action;
56 }
57
58 public void setAction(Concept a) {
59 action = a;
60 }
61
62 public void externalise(AbsObject abs, Ontology onto) throws OntologyException {
63 try {
64 AbsAgentAction absAction = (AbsAgentAction) abs;
65 absAction.set(BasicOntology.ACTION_ACTOR, (AbsTerm) onto.fromObject(getActor()));
66 absAction.set(BasicOntology.ACTION_ACTION, (AbsTerm) onto.fromObject(getAction()));
67 }
68 catch (ClassCastException cce) {
69 throw new OntologyException("Error externalising Action");
70 }
71 }
72
73 public void internalise(AbsObject abs, Ontology onto) throws UngroundedException, OntologyException {
74 try {
75 AbsAgentAction absAction = (AbsAgentAction) abs;
76 setActor((FIPA_AID_Address) onto.toObject(absAction.getAbsObject(BasicOntology.ACTION_ACTOR)));
77 setAction((Concept) onto.toObject(absAction.getAbsObject(BasicOntology.ACTION_ACTION)));
78 }
79 catch (ClassCastException cce) {
80 throw new OntologyException("Error internalising Action");
81 }
82 }
83 }