当前位置: 首页>>代码示例>>Java>>正文


Java Literal.hasAnnot方法代码示例

本文整理汇总了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;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:35,代码来源:DefaultBeliefBase.java

示例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;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:16,代码来源:DefaultBeliefBase.java

示例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();
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:36,代码来源:JDBCPersistentBB.java


注:本文中的jason.asSyntax.Literal.hasAnnot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。