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


Java Literal.getTerm方法代码示例

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

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

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

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


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