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


Java Term类代码示例

本文整理汇总了Java中gnu.prolog.term.Term的典型用法代码示例。如果您正苦于以下问题:Java Term类的具体用法?Java Term怎么用?Java Term使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Term类属于gnu.prolog.term包,在下文中一共展示了Term类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    RuleEvent re = getRuleEvent(args[0]);
    if (!(re instanceof BasicEvent)) {
        PrologException.domainError(RULEEVENT_ATOM, args[0]);
    }
    BasicEvent spo = (BasicEvent) re;
    if (!(args[1] instanceof JavaObjectTerm)) {
        PrologException.instantiationError();
    }
    Object arg1 = ((JavaObjectTerm) args[1]).value;
    Object arg1Transposed = null;
    if (arg1 instanceof Node) {
        arg1Transposed = spo.getAnchorMap().getNode((RuleNode) arg1);
    } else if (arg1 instanceof Edge) {
        arg1Transposed = spo.getAnchorMap().getEdge((RuleEdge) arg1);
    } else {
        PrologException.domainError(AtomTerm.get("node_edge"), args[1]);
    }
    if (arg1Transposed == null) {
        return FAIL;
    }
    Term res = new JavaObjectTerm(arg1Transposed);
    return interpreter.unify(args[2], res);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:Predicate_ruleevent_transpose.java

示例2: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    if (backtrackMode) {
        PrologCollectionIterator bi =
            (PrologCollectionIterator) interpreter.popBacktrackInfo();
        interpreter.undo(bi.getUndoPosition());
        return bi.nextSolution(interpreter);
    } else {
        if (!(interpreter.getEnvironment() instanceof GrooveEnvironment)) {
            GrooveEnvironment.invalidEnvironment();
        }
        GTS lts =
            ((GrooveEnvironment) interpreter.getEnvironment()).getGrooveState().getGts();
        if (lts == null) {
            return FAIL;
        }
        PrologCollectionIterator it =
            new PrologCollectionIterator(lts.getFinalStates(), args[0],
                interpreter.getUndoPosition());
        return it.nextSolution(interpreter);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:24,代码来源:Predicate_final_state.java

示例3: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    if (backtrackMode) {
        PrologCollectionIterator bi =
            (PrologCollectionIterator) interpreter.popBacktrackInfo();
        interpreter.undo(bi.getUndoPosition());
        return bi.nextSolution(interpreter);
    } else {
        GraphState graphState = getGraphState(args[0]);
        Collection<GraphState> nextStateSet = new ArrayList<>();
        for (GraphTransition trans : graphState.getTransitions()) {
            nextStateSet.add(trans.target());
        }
        PrologCollectionIterator it =
            new PrologCollectionIterator(nextStateSet, args[1],
                interpreter.getUndoPosition());
        return it.nextSolution(interpreter);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:21,代码来源:Predicate_state_next.java

示例4: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    if (backtrackMode) {
        PrologCollectionIterator bi =
            (PrologCollectionIterator) interpreter.popBacktrackInfo();
        interpreter.undo(bi.getUndoPosition());
        return bi.nextSolution(interpreter);
    } else {
        GraphState graphState = getGraphState(args[0]);
        PrologCollectionIterator it =
            new PrologCollectionIterator(graphState.getTransitions(),
                args[1], interpreter.getUndoPosition());
        return it.nextSolution(interpreter);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:Predicate_state_transition.java

示例5: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode, Term[] args)
    throws PrologException {

    if (!(interpreter.getEnvironment() instanceof GrooveEnvironment)) {
        GrooveEnvironment.invalidEnvironment();
    }

    TypeGraph typeGraph =
        ((GrooveEnvironment) interpreter.getEnvironment()).getGrooveState().getGraphGrammar().getTypeGraph();

    if (typeGraph == null) {
        return FAIL;
    }

    Term nodeTerm = new JavaObjectTerm(typeGraph);
    return interpreter.unify(args[0], nodeTerm);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:Predicate_composite_type_graph.java

示例6: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode, Term[] args)
    throws PrologException {
    if (!(interpreter.getEnvironment() instanceof GrooveEnvironment)) {
        GrooveEnvironment.invalidEnvironment();
    }

    Graph startGraph =
        ((GrooveEnvironment) interpreter.getEnvironment()).getGrooveState().getGraphGrammar().getStartGraph();

    if (startGraph == null) {
        return FAIL;
    }

    return interpreter.unify(args[0], new JavaObjectTerm(startGraph));
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:Predicate_start_graph.java

示例7: getGraph

import gnu.prolog.term.Term; //导入依赖的package包/类
/**
 * Get a graph from a term representing a graph
 * @param term      A term representing a graph
 * @return          A graph
 */
public static final Graph getGraph(Term term) throws PrologException {
    if (term instanceof JavaObjectTerm) {
        JavaObjectTerm jot = (JavaObjectTerm) term;
        if (jot.value instanceof GraphState) {
            return ((GraphState) jot.value).getGraph();
        }
        if (jot.value instanceof Graph) {
            return (Graph) jot.value;
        }
        PrologException.domainError(GraphPrologCode.GRAPH_ATOM, term);
    } else {
        PrologException.typeError(GraphPrologCode.GRAPH_ATOM, term);
    }
    return null;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:21,代码来源:GraphPrologCode.java

示例8: getHostGraph

import gnu.prolog.term.Term; //导入依赖的package包/类
/**
 * Get a host graph from a term representing a host graph
 * @param term      A term representing a host graph
 * @return          A host graph
 */
public static final HostGraph getHostGraph(Term term)
    throws PrologException {
    if (term instanceof JavaObjectTerm) {
        JavaObjectTerm jot = (JavaObjectTerm) term;
        if (jot.value instanceof GraphState) {
            return ((GraphState) jot.value).getGraph();
        }
        if (jot.value instanceof HostGraph) {
            return (HostGraph) jot.value;
        }
        PrologException.domainError(GraphPrologCode.GRAPH_ATOM, term);
    } else {
        PrologException.typeError(GraphPrologCode.GRAPH_ATOM, term);
    }
    return null;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:22,代码来源:GraphPrologCode.java

示例9: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode, Term[] args)
    throws PrologException {
    if (!(interpreter.getEnvironment() instanceof GrooveEnvironment)) {
        GrooveEnvironment.invalidEnvironment();
    }

    String startGraphName =
        ((GrooveEnvironment) interpreter.getEnvironment()).getGrooveState().getGraphGrammar().getStartGraph().getName();

    if (startGraphName == null) {
        return FAIL;
    }

    Term value = AtomTerm.get(startGraphName);
    return interpreter.unify(args[0], value);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:18,代码来源:Predicate_start_graph_name.java

示例10: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    if (args[0] instanceof JavaObjectTerm) {
        if (((JavaObjectTerm) args[0]).value instanceof ValueNode) {
            return SUCCESS_LAST;
        }
    }
    return FAIL;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:Predicate_is_valuenode.java

示例11: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    try {
        ValueNode node = getValueNode(args[0]);

        Term result;
        Algebra<?> alg = node.getAlgebra();
        Object value = alg.toJavaValue(node.getValue());
        switch (alg.getSort()) {
        case BOOL:
            result = new JavaObjectTerm(value);
            break;
        case INT:
            result = IntegerTerm.get((Integer) value);
            break;
        case REAL:
            result = new FloatTerm((Double) value);
            break;
        case STRING:
            result = AtomTerm.get((String) value);
            break;
        default:
            result = null;
            assert false;
        }
        return interpreter.unify(args[1], result);
    } catch (Exception e) {
        return FAIL;
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:32,代码来源:Predicate_convert_valuenode.java

示例12: getValueNode

import gnu.prolog.term.Term; //导入依赖的package包/类
/**
 * Gets a valuenode from a term
 * @param term      A term representing a valuenode
 * @return          A valuenode
 */
public static final ValueNode getValueNode(Term term)
    throws PrologException {
    if (term instanceof JavaObjectTerm) {
        JavaObjectTerm jot = (JavaObjectTerm) term;
        if (!(jot.value instanceof ValueNode)) {
            PrologException.domainError(VALUENODE_ATOM, term);
        }
        return (ValueNode) jot.value;
    } else {
        PrologException.typeError(VALUENODE_ATOM, term);
    }
    return null;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:AlgebraPrologCode.java

示例13: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    if (args[0] instanceof JavaObjectTerm) {
        if (((JavaObjectTerm) args[0]).value instanceof Rule) {
            return SUCCESS_LAST;
        }
    }
    return FAIL;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:Predicate_is_rule.java

示例14: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    Action rl = getRule(args[0]);
    Term res = IntegerTerm.get(rl.getPriority());
    return interpreter.unify(args[1], res);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:8,代码来源:Predicate_rule_priority.java

示例15: execute

import gnu.prolog.term.Term; //导入依赖的package包/类
@Override
public int execute(Interpreter interpreter, boolean backtrackMode,
        Term[] args) throws PrologException {
    Rule rl = getRule(args[0]);
    Term res = new JavaObjectTerm(rl.rhs());
    return interpreter.unify(args[1], res);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:8,代码来源:Predicate_rule_rhs.java


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