public static void main(String[] args) throws Exception { TrivialDialogueKB kb = new TrivialDialogueKB(); DialogueOperatorEffect f3 = parse("assert(or(a,b))"); kb.store(f3, ACCESSTYPE.AUTO_OVERWRITEAUTO, false); // f3=createAssertion(DialogueKBFormula.parse("and(a,b")); // DialogueOperatorEffect f3 = parse("++q"); System.out.println(f3.toString(false)); System.out.println(f3.extractAllNamesUsed()); }
public int compareUsingStrings(DialogueOperatorEffect o) { return toString().compareTo((o != null) ? o.toString() : null); }
public String toString(boolean shortForm, String effectXmlName) { String ret = ""; if (shortForm) { if (isAssertion()) ret += XMLConstants.AssignmentID + "(" + left + "," + right + ")"; else if (isAssignment()) ret += XMLConstants.AssignmentID + "(" + left + "," + getAssignedExpression() + ")"; else if (isGoalAchievement()) ret += XMLConstants.GOALID + ": " + goalName + ((left != null) ? " " + XMLConstants.VALUEID + ": " + left : ""); else if (isImplication()) ret += XMLConstants.implyID + "(" + left + "," + value + "," + implyElse + ")"; else if (isSwapOut()) ret += XMLConstants.SWAPOUTID; else if (isInterrupt()) ret += XMLConstants.INTERRUPTID; else if (isSend()) ret += XMLConstants.SENDID + "(" + eventName + ")"; else if (isAssignmentList()) { boolean first = true; for (DialogueOperatorEffect e : getAssignmentList()) { ret += ((!first) ? "," : XMLConstants.AssignmentLISTID + "(") + e.toString(shortForm); first = false; } ret += ")"; } else ret += "unknown effect"; } else { ret = "<" + effectXmlName + " "; if (isAssertion()) ret += XMLConstants.EXPRID + "=\"" + XMLConstants.AssignmentID + "(" + left + "," + right + ")\""; else if (isAssignmentList()) { String list = ""; boolean first = true; for (DialogueOperatorEffect e : getAssignmentList()) { list += ((!first) ? "," : "") + e.toString(shortForm); first = false; } ret += XMLConstants.EXPRID + "=\"" + XMLConstants.AssignmentLISTID + "(" + list + ")\""; } else if (isAssignment()) { String ps = XMLConstants.VISIBLEID + "=\"" + !varPropertiesForAssignment.getProperty(PROPERTY.HIDDEN) + "\" " + XMLConstants.READONLYID + "=\"" + varPropertiesForAssignment.getProperty(PROPERTY.READONLY) + "\" " + XMLConstants.PERSISTENTID + "=\"" + varPropertiesForAssignment.getProperty(PROPERTY.PERSISTENT) + "\" "; ret += ps + XMLConstants.EXPRID + "=\"" + XMLConstants.AssignmentID + "(" + left + "," + getAssignedExpression() + ")\""; } else if (isGoalAchievement()) ret += XMLConstants.GOALID + "=\"" + goalName + "\"" + ((left != null) ? " " + XMLConstants.VALUEID + "=\"" + left + "\"" : ""); else if (isImplication()) ret += XMLConstants.EXPRID + "=\"" + XMLConstants.implyID + "(" + left + "," + value + "," + implyElse + ")\""; else if (isSwapOut()) ret = "<" + XMLConstants.SWAPOUTID; else if (isSend()) ret = "<" + XMLConstants.SENDID + " " + XMLConstants.IDID + "=\"" + eventName + "\""; else return super.toString(); ret += "/>"; } return ret; }