/**
  * Returns the value to which var is bound in this answer
  *
  * @param var a variable for which this answer provides a binding.
  * @return the value to which var is bound.
  */
 @Override
 public Object getBinding(CycVariable var) throws CycConnectionException {
   final String command =
       SubLAPIHelper.makeSubLStmt(
           "open-cyc-get-binding-for-variable", var, getId().cycListApiValue());
   return getCycAccess().converse().converseObject(command);
 }
Example #2
0
 /* (non-Javadoc)
  * @see com.cyc.kb.Relation#getArityMax()
  */
 @Override
 public Integer getArityMax() {
   try {
     Context ctx = Constants.uvMt();
     String command =
         SubLAPIHelper.makeSubLStmt(
             WITH_MT,
             ctx.getCore(),
             SubLAPIHelper.makeNestedSubLStmt("max-arity", this.getCore()));
     Object object = getAccess().converse().converseObject(command);
     if (object == null || object.equals(CycObjectFactory.nil)) {
       throw new IllegalArgumentException("No known max-arity for " + this);
     } else {
       return (Integer) object;
     }
   } catch (CycConnectionException e) {
     throw new KBApiRuntimeException(e.getMessage(), e);
   }
 }
 @Override
 public synchronized Map<CycVariable, Object> getBindings() throws CycConnectionException {
   if (bindings == null) {
     bindings = new Bindings();
     final String command =
         SubLAPIHelper.makeSubLStmt(
             "open-cyc-get-answer-bindings", (CycList) (getId().cycListApiValue()));
     final CycObject result = getCycAccess().converse().converseCycObject(command);
     if (result instanceof CycArrayList) {
       bindings.populateFromCycList((CycArrayList) result);
     }
   }
   return Collections.unmodifiableMap(bindings);
 }
 /**
  * Return the sources to which this answer is attributed.
  *
  * @return the sources to which this answer is attributed.
  */
 @Override
 public Collection<InformationSource> getSources(
     InformationSource.CitationGenerator citationGenerator) throws CycConnectionException {
   final String command =
       SubLAPIHelper.makeSubLStmt(
           "inference-answer-sources-from-signature", getId().cycListApiValue());
   final Set<InformationSource> sources = new HashSet<InformationSource>();
   final CycAccess cycAccess = getCycAccess();
   for (final Object sourceObj : cycAccess.converse().converseList(command)) {
     if (sourceObj instanceof DenotationalTerm) {
       sources.add(
           new InformationSourceImpl((DenotationalTerm) sourceObj, citationGenerator, cycAccess));
     }
   }
   return sources;
 }