/** * Returns a header for the given term. * * @param term * The term we are requesting a header for. * @return The constructed header. */ private static byte getHeader(final ATerm term) { return (byte) term.getType(); }
protected boolean match(final ATerm pattern, final List<Object> list) { if (pattern.getType() == PLACEHOLDER) { final ATerm type = ((ATermPlaceholder) pattern).getPlaceholder(); if (type.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) type; final AFun afun = appl.getAFun(); if (afun.getName().equals("term") && afun.getArity() == 0 && !afun.isQuoted()) { list.add(this); return true; } } } return false; }
if (_currentTerm.getType() == ATerm.LIST)
private static boolean isListPlaceHolder(final ATerm pattern) { if (pattern.getType() == ATerm.PLACEHOLDER) { final ATerm type = ((ATermPlaceholder) pattern).getPlaceholder(); if (type.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) type; final AFun afun = appl.getAFun(); if (afun.getName().equals("list") && afun.getArity() == 0 && !afun.isQuoted()) return true; } } return false; }
/** * Links the given term with it's parent. * * @param aTerm * The term that needs to be linked. */ private void linkTerm(final ATerm aTerm) { ATerm term = aTerm; while (_stackPosition != 0) { final ATermConstruct parent = _stack[--_stackPosition]; final ATerm[] subTerms = parent.subTerms; if (subTerms != null && subTerms.length > parent.subTermIndex) { subTerms[parent.subTermIndex++] = term; if (parent.subTerms.length != parent.subTermIndex) return; } else throw new OpenError("Encountered a term that didn't fit anywhere. Type: " + term.getType()); term = buildTerm(parent); _sharedTerms[parent.termIndex] = term; } if (_stackPosition == 0) _isDone = true; }
final static public ATermAppl makeAllValues(final ATerm r, final ATerm c) { final ATerm arg1; if (r.getType() == ATerm.LIST) { final ATermList list = (ATermList) r; arg1 = list.getLength() == 1 ? list.getFirst() : r; } else arg1 = r; return factory.makeAppl(ALLFUN, arg1, c); }
final static public ATermAppl makeAllValues(final ATerm r, final ATerm c) { final ATerm arg1; if (r.getType() == ATerm.LIST) { final ATermList list = (ATermList) r; arg1 = list.getLength() == 1 ? list.getFirst() : r; } else arg1 = r; return factory.makeAppl(ALLFUN, arg1, c); }
@Override public boolean match(final ATerm pattern, final List<Object> list) { if (pattern.getType() == ATerm.PLACEHOLDER) { final ATerm t = ((ATermPlaceholder) pattern).getPlaceholder(); if (t.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) t; final AFun afun = appl.getAFun(); if (afun.getName().equals("placeholder") && afun.getArity() == 0 && !afun.isQuoted()) { list.add(t); return true; } } } return super.match(pattern, list); }
@Override protected boolean match(final ATerm pattern, final List<Object> list) { if (equals(pattern)) return true; if (pattern.getType() == ATerm.PLACEHOLDER) { final ATerm type = ((ATermPlaceholder) pattern).getPlaceholder(); if (type.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) type; final AFun afun = appl.getAFun(); if (afun.getName().equals("real") && afun.getArity() == 0 && !afun.isQuoted()) { list.add(new Double(_value)); return true; } } } return super.match(pattern, list); }
@Override protected boolean match(final ATerm pattern, final List<Object> list) { if (equals(pattern)) return true; if (pattern.getType() == ATerm.PLACEHOLDER) { final ATerm type = ((ATermPlaceholder) pattern).getPlaceholder(); if (type.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) type; final AFun afun = appl.getAFun(); if (afun.getName().equals("int") && afun.getArity() == 0 && !afun.isQuoted()) { list.add(new Integer(_value)); return true; } } } return super.match(pattern, list); }
@Override protected boolean match(final ATerm pattern, final List<Object> list) { if (equals(pattern)) return true; if (pattern.getType() == ATerm.PLACEHOLDER) { final ATerm type = ((ATermPlaceholder) pattern).getPlaceholder(); if (type.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) type; final AFun afun = appl.getAFun(); if (afun.getName().equals("long") && afun.getArity() == 0 && !afun.isQuoted()) { list.add(new Long(_value)); return true; } } } return super.match(pattern, list); }
@Override protected boolean match(final ATerm pattern, final List<Object> list) { if (equals(pattern)) return true; if (pattern.getType() == ATerm.PLACEHOLDER) { final ATerm type = ((ATermPlaceholder) pattern).getPlaceholder(); if (type.getType() == ATerm.APPL) { final ATermAppl appl = (ATermAppl) type; final AFun afun = appl.getAFun(); if (afun.getName().equals("blob") && afun.getArity() == 0 && !afun.isQuoted()) { list.add(_data); return true; } } } return super.match(pattern, list); }
default boolean addSubRole(final ATerm sub, final ATerm sup, final DependencySet ds) { final Role roleSup = getRole(sup); final Role roleSub = getRole(sub); if (roleSup == null) return false; else if (sub.getType() == ATerm.LIST) roleSup.addSubRoleChain((ATermList) sub, ds); else if (roleSub == null) return false; else { roleSup.addSubRole(roleSub, ds); roleSub.addSuperRole(roleSup, ds); } // TODO Need to figure out what to do about about role lists // explanationTable.add(ATermUtils.makeSub(sub, sup), ds); return true; }
private static Bool checkAllValuesClash(final KnowledgeBase kb, final ATermAppl av, final CachedNode root, final CachedNode otherRoot) { ATerm r = av.getArgument(0); if (r.getType() == ATerm.LIST) r = ((ATermList) r).getFirst(); final Role role = kb.getRole(r); if (null == role) // FIXME : null is unexpected. return Bool.UNKNOWN; if (!role.hasComplexSubRole()) { if (otherRoot.hasRNeighbor(role)) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + role + " _neighbor"); return Bool.UNKNOWN; } } else { final TransitionGraph<Role> tg = role.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (otherRoot.hasRNeighbor(t.getName())) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + t.getName() + " _neighbor"); return Bool.UNKNOWN; } } return null; }
private static Bool checkAllValuesClash(final KnowledgeBase kb, final ATermAppl av, final CachedNode root, final CachedNode otherRoot) { ATerm r = av.getArgument(0); if (r.getType() == ATerm.LIST) r = ((ATermList) r).getFirst(); final Role role = kb.getRole(r); if (null == role) // FIXME : null is unexpected. return Bool.UNKNOWN; if (!role.hasComplexSubRole()) { if (otherRoot.hasRNeighbor(role)) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + role + " _neighbor"); return Bool.UNKNOWN; } } else { final TransitionGraph<Role> tg = role.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (otherRoot.hasRNeighbor(t.getName())) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + t.getName() + " _neighbor"); return Bool.UNKNOWN; } } return null; }
default boolean addSubRole(final ATerm sub, final ATerm sup, final DependencySet ds) { final Role roleSup = getRole(sup); final Role roleSub = getRole(sub); if (roleSup == null) return false; else if (sub.getType() == ATerm.LIST) roleSup.addSubRoleChain((ATermList) sub, ds); else if (roleSub == null) return false; else { roleSup.addSubRole(roleSub, ds); roleSub.addSuperRole(roleSup, ds); } // TODO Need to figure out what to do about about role lists // explanationTable.add(ATermUtils.makeSub(sub, sup), ds); return true; }
if (term.getType() != ATerm.LIST) next = term.getChildAt(++current.subTermIndex); else