本文整理汇总了Java中jason.asSyntax.Literal.hasAnnot方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.hasAnnot方法的具体用法?Java Literal.hasAnnot怎么用?Java Literal.hasAnnot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jason.asSyntax.Literal
的用法示例。
在下文中一共展示了Literal.hasAnnot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import jason.asSyntax.Literal; //导入方法依赖的package包/类
protected boolean add(Literal l, boolean addInEnd) {
if (!l.canBeAddedInBB()) {
logger.log(Level.SEVERE, "Error: '"+l+"' can not be added in the belief base.");
return false;
}
Literal bl = contains(l);
if (bl != null && !bl.isRule()) {
// add only annots
if (bl.importAnnots(l)) {
// check if it needs to be added in the percepts list
// (note that l contains only the annots imported)
if (l.hasAnnot(TPercept)) {
percepts.add(bl);
}
return true;
}
} else {
// new bel
l = l.copy(); // we need to clone l for the consequent event to not have a ref to this bel (which may change before the event is processed); see bug from Viviana Marcardi
BelEntry entry = provideBelEntry(l);
entry.add(l, addInEnd);
// add it in the percepts list
if (l.hasAnnot(TPercept)) {
percepts.add(l);
}
size++;
return true;
}
return false;
}
示例2: remove
import jason.asSyntax.Literal; //导入方法依赖的package包/类
@Override
public boolean remove(Literal l) {
Literal bl = contains(l);
if (bl != null) {
if (l.hasSubsetAnnot(bl)) { // e.g. removing b[a] or b[a,d] from BB b[a,b,c]
// second case fails
if (l.hasAnnot(TPercept)) {
percepts.remove(bl);
}
boolean result = bl.delAnnots(l.getAnnots()); // note that l annots can be empty, in this case, nothing is deleted!
return removeFromEntry(bl) || result;
}
}
return false;
}
示例3: 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();
}