@Override CompoundSpiderDiagram createSD( Map<String, Entry<Object, CommonTree>> attributes, CommonTree mainNode) throws ReadingException { String operator = (String) attributes.remove(SDTextOperatorAttribute).getKey(); ArrayList<SpiderDiagram> operands = new ArrayList<>(); int i = 1; Entry<Object, CommonTree> curSD, lastSD = null; while ((curSD = attributes.remove(CompoundSpiderDiagram.SDTextArgAttribute + i++)) != null && curSD.getKey() instanceof SpiderDiagram) { operands.add((SpiderDiagram) curSD.getKey()); lastSD = curSD; } if (curSD != null) { throw new ReadingException( i18n("GERR_ILLEGAL_STATE"), (CommonTree) curSD.getValue().getChild(0)); } if (!attributes.isEmpty()) { throw new ReadingException( i18n("ERR_TRANSLATE_UNKNOWN_ATTRIBUTES", attributes.keySet()), (CommonTree) attributes.values().iterator().next().getValue().getChild(0)); } try { return SpiderDiagrams.createCompoundSD(operator, operands, false); } catch (Exception e) { throw new ReadingException( e.getLocalizedMessage(), lastSD == null ? mainNode : (CommonTree) lastSD.getValue().getChild(0)); } }
@Override public ArrayList<V> fromASTNode(CommonTree treeNode) throws ReadingException { if (treeNode.token != null && treeNode.token.getType() == headTokenType) { checkNode(treeNode); if (treeNode.getChildCount() < 1) { return null; } ArrayList<V> objs = new ArrayList<>(treeNode.getChildCount()); int i = 0; for (Object obj : treeNode.getChildren()) { objs.add(fromASTChildAt(i++, (CommonTree) obj)); } return objs; } throw new ReadingException( i18n("ERR_TRANSLATE_UNEXPECTED_ELEMENT", i18n(i18n("ERR_TRANSLATE_LIST_OR_SLIST"))), treeNode); }