/** Pass a string to kdb for evaluation. */ public void evaluate(SimpleEvaluationObject obj, String code) { try { kdbProcess.getErrorHandler().reset(obj); kdbProcess.getOutputHandler().reset(obj); Object result = kdbClient.execute(code); obj.finished(convert(result)); } catch (Exception e) { obj.error(e); } kdbProcess.getErrorHandler().reset(null); kdbProcess.getOutputHandler().reset(null); }
/** Autocomplete a kdb expression. */ public List<String> autocomplete(String code, int caretPosition) { if (code.isEmpty()) return null; // Go back build the longest name string we can. int s = caretPosition - 1; while ((s >= 0) && isQName(code.charAt(s))) { --s; } try { return Arrays.asList( (String[]) kdbClient.execute(".bk.ac[\"" + code.substring(s + 1, caretPosition) + "\"]")); } catch (Exception ex) { return null; } }