Skip to content

Commit

Permalink
trying solve [#3]
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsonLazarin committed Mar 15, 2024
1 parent f278ae6 commit 554f4aa
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/main/java/group/chon/agent/mailer/core/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jason.asSyntax.ASSyntax;
import jason.asSyntax.Plan;
import jason.asSyntax.Term;
import jason.asSyntax.parser.ParseException;
import org.jsoup.*;
import org.jsoup.nodes.*;

Expand All @@ -22,18 +23,32 @@ public class Util {

private Term term;

private void setKqmlMessage(String kqmlMessage) throws Exception {
private boolean setKqmlMessage(String kqmlMessage) {
if(getKqmlILF().equals("tellHow")){
Plan p = null;
if(kqmlMessage.startsWith("\"") && kqmlMessage.endsWith("\"")){
p = ASSyntax.parsePlan(kqmlMessage.substring(1,kqmlMessage.length()-1));
}else{
p = ASSyntax.parsePlan(kqmlMessage);
try{
if(kqmlMessage.startsWith("\"") && kqmlMessage.endsWith("\"")){
p = ASSyntax.parsePlan(kqmlMessage.substring(1,kqmlMessage.length()-1));
}else{
p = ASSyntax.parsePlan(kqmlMessage);
}
this.kqmlMessage = "\""+p.toString()+"\"";
return true;
}catch (Exception ep){
System.out.println(ep.getMessage());
this.kqmlMessage = null;
return false;
}
this.kqmlMessage = "\""+p.toString()+"\"";
}else{
Term t = ASSyntax.parseTerm(kqmlMessage);
this.kqmlMessage = t.toString();
try{
Term t = ASSyntax.parseTerm(kqmlMessage);
this.kqmlMessage = t.toString();
return true;
}catch (Exception ep){
System.out.println(ep.getMessage());
this.kqmlMessage = null;
return false;
}
}
}

Expand Down Expand Up @@ -76,13 +91,7 @@ public Boolean isValidTerm(Object content){
if(message == null){
return false;
}else{
try{
setKqmlMessage(message);
return true;
}catch (Exception ex){
ex.printStackTrace();
return false;
}
return setKqmlMessage(message);
}
}

Expand Down

0 comments on commit 554f4aa

Please sign in to comment.