|
From: <jom...@us...> - 2008-06-09 15:05:49
|
Revision: 1328
http://jason.svn.sourceforge.net/jason/?rev=1328&view=rev
Author: jomifred
Date: 2008-06-09 08:05:42 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
add a new method to create source annotations
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestIF.java
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/bb/BeliefBase.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestIF.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestIF.java 2008-06-08 10:46:16 UTC (rev 1327)
+++ trunk/applications/as-unit-test/src/jason/tests/TestIF.java 2008-06-09 15:05:42 UTC (rev 1328)
@@ -18,12 +18,12 @@
ag.parseAScode(
"b(3). " +
"+!test1 <- a1; "+
- " .if( b(X), {jason.asunit.print(X); b1}, {jason.asunit.print(no)}); "+
+ " if( b(X), {jason.asunit.print(X); b1}, {jason.asunit.print(no)}); "+
" a2. "+
"+!test2 <- -b(_); !test1. "+
- "+!test3 <- .if( b(X), { Y = X*10; Z = 10 }, { Y = 60; Z=20 }); jason.asunit.print(Y,\" \",Z). "+
+ "+!test3 <- if( b(X), { Y = X*10; Z = 10 }, { Y = 60; Z=20 }); jason.asunit.print(Y,\" \",Z). "+
"+!test4 <- -b(_); !test3. "
);
}
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-06-08 10:46:16 UTC (rev 1327)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-06-09 15:05:42 UTC (rev 1328)
@@ -53,7 +53,7 @@
*/
public class OrgAgent extends AgArch {
- private static final Term managerSource = DefaultTerm.parse("source(orgManager)");
+ private static final Term managerSource = Pred.createSource("orgManager");
private static final Atom rootAtom = new Atom("root");
private Logger logger = Logger.getLogger(OrgAgent.class.getName());
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-06-08 10:46:16 UTC (rev 1327)
+++ trunk/src/jason/asSyntax/Pred.java 2008-06-09 15:05:42 UTC (rev 1328)
@@ -308,23 +308,29 @@
* Adds a source annotation like "source(<i>agName</i>)".
*/
public void addSource(Structure agName) {
- if (agName != null) {
- Structure ts = new Structure("source", 1);
- ts.addTerm(agName);
- addAnnot(ts);
- }
+ if (agName != null)
+ addAnnot(createSource(agName));
}
/** deletes "source(<i>agName</i>)" */
public boolean delSource(Structure agName) {
- if (annots != null) {
- Structure ts = new Structure("source");
- ts.addTerm(agName);
- return annots.remove(ts);
- }
- return false;
+ if (annots != null)
+ return annots.remove(createSource(agName));
+ else
+ return false;
}
+ public static Term createSource(String source) {
+ Structure s = new Structure("source",1);
+ s.addTerm(new Atom(source));
+ return s;
+ }
+ public static Term createSource(Structure source) {
+ Structure s = new Structure("source",1);
+ s.addTerm(source);
+ return s;
+ }
+
/**
* returns the sources of this Pred as a new list. e.g.: from annots
* [source(a), source(b)], it returns [a,b]
Modified: trunk/src/jason/bb/BeliefBase.java
===================================================================
--- trunk/src/jason/bb/BeliefBase.java 2008-06-08 10:46:16 UTC (rev 1327)
+++ trunk/src/jason/bb/BeliefBase.java 2008-06-09 15:05:42 UTC (rev 1328)
@@ -25,8 +25,8 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.Literal;
+import jason.asSyntax.Pred;
import jason.asSyntax.PredicateIndicator;
import jason.asSyntax.Term;
@@ -42,9 +42,9 @@
*/
public interface BeliefBase extends Iterable<Literal>, Cloneable {
- public static final Term TPercept = DefaultTerm.parse("source(percept)");
- public static final Term TSelf = DefaultTerm.parse("source(self)");
-
+ public static final Term TPercept = Pred.createSource("percept");
+ public static final Term TSelf = Pred.createSource("self");
+
/**
* Called before the MAS execution with the agent that uses this
* BB and the args informed in .mas2j project.<br>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|