本文整理汇总了Java中jason.asSyntax.Literal.getTerm方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.getTerm方法的具体用法?Java Literal.getTerm怎么用?Java Literal.getTerm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSyntax.Literal
的用法示例。
在下文中一共展示了Literal.getTerm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeVarsAnnon
import jason.asSyntax.Literal; //导入方法依赖的package包/类
public void makeVarsAnnon(Literal l, Unifier un) {
try {
for (int i=0; i<l.getArity(); i++) {
Term t = l.getTerm(i);
if (t.isString()) {
StringTerm st = (StringTerm)t;
Matcher matcher = regex.matcher(st.getString());
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String sVar = matcher.group();
sVar = sVar.substring(2, sVar.length() - 1);
Term v = ASSyntax.parseTerm(sVar);
if (v.isVar()) {
VarTerm to = ((Structure)l).varToReplace(v, un);
matcher.appendReplacement(sb, "#{"+to.toString()+"}");
}
}
matcher.appendTail(sb);
l.setTerm(i, new StringTermImpl(sb.toString()));
}
}
} catch (ParseException pe) {
pe.printStackTrace();
}
}
示例2: fixAgInIAandFunctions
import jason.asSyntax.Literal; //导入方法依赖的package包/类
private void fixAgInIAandFunctions(Agent a, Literal l) throws Exception {
// if l is internal action/function
if (l instanceof InternalActionLiteral) {
((InternalActionLiteral)l).setIA(null); // reset the IA in the literal, the IA there will be updated next getIA call
}
if (l instanceof ArithFunctionTerm) {
((ArithFunctionTerm)l).setAgent(a);
}
if (l instanceof Rule) {
LogicalFormula f = ((Rule)l).getBody();
if (f instanceof Literal) {
fixAgInIAandFunctions(a, (Literal)f);
}
}
for (int i=0; i<l.getArity(); i++) {
if (l.getTerm(i) instanceof Literal)
fixAgInIAandFunctions(a, (Literal)l.getTerm(i));
}
}
示例3: getWhere
import jason.asSyntax.Literal; //导入方法依赖的package包/类
/** returns the where clausule for a select for literal l */
protected String getWhere(Literal l) throws SQLException {
ResultSetMetaData meta = belsDB.get(l.getPredicateIndicator());
StringBuilder q = new StringBuilder(" where ");
String and = "";
// for all ground terms of l
for (int i = 0; i < l.getArity(); i++) {
Term t = l.getTerm(i);
if (t.isGround()) {
q.append(and);
String ts;
if (t.isString()) {
ts = "'" + ((StringTerm) t).getString() + "'";
} else if (t.isNumeric()) {
ts = t.toString();
} else {
ts = "'" + t.toString() + "'";
}
q.append(meta.getColumnName(i + 1) + " = " + ts);
and = " and ";
}
}
if (isCreatedByJason(l.getPredicateIndicator())) {
q.append(and + COL_NEG + " = " + l.negated());
}
//System.out.println(q.toString());
if (and.length() > 0) // add nothing in the clausule
return q.toString();
else
return "";
}
示例4: getInsert
import jason.asSyntax.Literal; //导入方法依赖的package包/类
/** returns the SQL command to insert l into the DB */
protected String getInsert(Literal l) throws Exception {
StringBuilder q = new StringBuilder("insert into ");
ResultSetMetaData meta = belsDB.get(l.getPredicateIndicator());
q.append(meta.getTableName(1));
q.append(" values(");
// values
for (int i = 0; i < l.getArity(); i++) {
Term t = l.getTerm(i);
if (t.isString()) {
q.append("'" + ((StringTerm) t).getString() + "'");
} else {
Timestamp timestamp = structure2timestamp(t);
if (timestamp != null) {
q.append("TIMESTAMP '" + structure2timestamp(t) + "'");
} else {
q.append("'" + t.toString() + "'");
}
}
if (i < meta.getColumnCount() - 1) {
q.append(",");
}
}
if (isCreatedByJason(l.getPredicateIndicator())) {
q.append(l.negated() + ",");
if (l.hasAnnot()) {
q.append("\'" + l.getAnnots() + "\'");
} else {
q.append("\'[]\'");
}
}
q.append(")");
return q.toString();
}