本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}