28 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
33 List<String> memKeys =
new ArrayList<String>(memoryMap.keySet());
34 Collections.sort(memKeys);
35 memKeys.remove(MemKeys.LOCAL);
36 memKeys.add(MemKeys.LOCAL);
39 Color GRAY_COLOR =
new Color(100,100,100);
42 for (String memKey : memKeys) {
44 MemoryAPI memory = memoryMap.get(memKey);
46 List<String> keys =
new ArrayList<String>(memory.getKeys());
47 Collections.sort(keys);
49 List<Color> highlightColors =
new ArrayList<Color>();
50 List<String> highlightList =
new ArrayList<String>();
51 for (String key : keys) {
52 Object value = memory.get(key);
54 String varName =
"$" + memKey +
".";
55 if (memKey.equals(MemKeys.LOCAL)) {
58 if (key.startsWith(
"$")) {
59 varName += key.substring(1);
66 if (varName.length() > 35) {
67 varName = varName.substring(0, 35) +
"...";
70 highlightColors.add(HIGHLIGHT_COLOR);
71 highlightList.add(varName);
74 if (value instanceof Boolean || value instanceof String || value instanceof Float || value instanceof Integer || value instanceof Long) {
75 text +=
" = " + value.toString();
76 }
else if (value !=
null) {
77 text +=
" = " + value.getClass().getSimpleName() +
"@" + value.hashCode();
79 text +=
" = " +
"null";
81 float expire = memory.getExpire(key);
83 String eText =
"(e=" + (float)((
int)(
expire * 10)/10f) +
")";
87 highlightColors.add(GRAY_COLOR);
88 highlightList.add(eText);
95 dialog.getTextPanel().addParagraph(text);
96 dialog.getTextPanel().setHighlightColorsInLastPara(highlightColors.toArray(
new Color[0]));
97 dialog.getTextPanel().highlightInLastPara(highlightList.toArray(
new String [0]));
101 System.out.println(text);