@Override public String toString() { String values; StringBuilder buf = new StringBuilder(); for (NodeTuple node : getValue()) { buf.append("{ key="); buf.append(node.getKeyNode()); buf.append("; value="); if (node.getValueNode() instanceof CollectionNode) { // to avoid overflow in case of recursive structures buf.append(System.identityHashCode(node.getValueNode())); } else { buf.append(node.toString()); } buf.append(" }"); } values = buf.toString(); return "<" + this.getClass().getName() + " (tag=" + getTag() + ", values=" + values + ")>"; }
@Override public String toString() { String values; StringBuilder buf = new StringBuilder(); for (NodeTuple node : getValue()) { buf.append("{ key="); buf.append(node.getKeyNode()); buf.append("; value="); if (node.getValueNode() instanceof CollectionNode) { // to avoid overflow in case of recursive structures buf.append(System.identityHashCode(node.getValueNode())); } else { buf.append(node.toString()); } buf.append(" }"); } values = buf.toString(); return "<" + this.getClass().getName() + " (tag=" + getTag() + ", values=" + values + ")>"; }
@Override public String toString() { String values; StringBuilder buf = new StringBuilder(); for (NodeTuple node : getValue()) { buf.append("{ key="); buf.append(node.getKeyNode()); buf.append("; value="); if (node.getValueNode() instanceof CollectionNode) { // to avoid overflow in case of recursive structures buf.append(System.identityHashCode(node.getValueNode())); } else { buf.append(node.toString()); } buf.append(" }"); } values = buf.toString(); return "<" + this.getClass().getName() + " (tag=" + getTag() + ", values=" + values + ")>"; }
@Override public String toString() { String values; StringBuilder buf = new StringBuilder(); for (NodeTuple node : getValue()) { buf.append("{ key="); buf.append(node.getKeyNode()); buf.append("; value="); if (node.getValueNode() instanceof CollectionNode) { // to avoid overflow in case of recursive structures buf.append(System.identityHashCode(node.getValueNode())); } else { buf.append(node.toString()); } buf.append(" }"); } values = buf.toString(); return "<" + this.getClass().getName() + " (tag=" + getTag() + ", values=" + values + ")>"; }
private void applyTraitsToActions(SequenceNode traits, Map<String, Node> actionNodes, String actionName) { for (Node ref : traits.getValue()) { if (actionName == null) { for (Map.Entry<String, Node> actionEntry : actionNodes.entrySet()) { currentAction = actionEntry.getKey(); MappingNode templateNode = cloneTemplate(ref, TemplateType.TRAIT); if (templateNode != null) { mergeNodes(actionEntry.getValue(), templateNode, new MergeContext(Action.class, templateNode.getTag())); } } } else { currentAction = actionName; MappingNode templateNode = cloneTemplate(ref, TemplateType.TRAIT); if (templateNode != null) { mergeNodes(actionNodes.get(actionName), templateNode, new MergeContext(Action.class, templateNode.getTag())); } } } }
mergeNodes(resourceNode, clone, new MergeContext(Resource.class, clone.getTag()));
private void applyTraitsToActions(SequenceNode traits, Map<String, Node> actionNodes, String actionName) { for (Node ref : traits.getValue()) { if (actionName == null) { for (Map.Entry<String, Node> actionEntry : actionNodes.entrySet()) { currentAction = actionEntry.getKey(); MappingNode templateNode = cloneTemplate(ref, TemplateType.TRAIT); if (templateNode != null) { mergeNodes(actionEntry.getValue(), templateNode, new MergeContext(Action.class, templateNode.getTag())); } } } else { currentAction = actionName; MappingNode templateNode = cloneTemplate(ref, TemplateType.TRAIT); if (templateNode != null) { mergeNodes(actionNodes.get(actionName), templateNode, new MergeContext(Action.class, templateNode.getTag())); } } } }
mergeNodes(resourceNode, clone, new MergeContext(Resource.class, clone.getTag()));
public Map<Object, Object> customConstructMapping(MappingNode mnode) { Map<Object, Object> values = new HashMap<Object, Object>(); Map<String, Integer> center = new HashMap<String, Integer>(); List<NodeTuple> tuples = mnode.getValue(); for (NodeTuple tuple : tuples) { ScalarNode knode = (ScalarNode) tuple.getKeyNode(); String key = knode.getValue(); Node vnode = tuple.getValueNode(); if (vnode instanceof MappingNode) { MappingNode nvnode = (MappingNode) vnode; if ("!point".equals(nvnode.getTag().getValue())) { List<NodeTuple> vtuples = nvnode.getValue(); for (NodeTuple vtuple : vtuples) { ScalarNode vknode = (ScalarNode) vtuple.getKeyNode(); ScalarNode vvnode = (ScalarNode) vtuple.getValueNode(); Integer val = Integer.parseInt(vvnode.getValue()); center.put(vknode.getValue(), val); } values.put(key, center); } } else if (vnode instanceof ScalarNode) { Integer val = Integer.parseInt(((ScalarNode) vnode).getValue()); values.put(key, val); } } return values; }
private MappingNode cloneMappingNode(MappingNode node, Map<String, String> parameters) { List<NodeTuple> tuples = new ArrayList<NodeTuple>(); for (NodeTuple tuple : node.getValue()) { if (tuple.getKeyNode().getNodeId() != scalar) { addError(NON_SCALAR_KEY_MESSAGE, tuple.getKeyNode()); break; } Node key = cloneScalarNode((ScalarNode) tuple.getKeyNode(), parameters); Node value = cloneNode(tuple.getValueNode(), parameters); tuples.add(new NodeTuple(key, value)); } return new MappingNode(node.getTag(), tuples, node.getFlowStyle()); }
private MappingNode cloneMappingNode(MappingNode node, Map<String, String> parameters) { List<NodeTuple> tuples = new ArrayList<NodeTuple>(); for (NodeTuple tuple : node.getValue()) { if (tuple.getKeyNode().getNodeId() != scalar) { addError(NON_SCALAR_KEY_MESSAGE, tuple.getKeyNode()); break; } Node key = cloneScalarNode((ScalarNode) tuple.getKeyNode(), parameters); Node value = cloneNode(tuple.getValueNode(), parameters); tuples.add(new NodeTuple(key, value)); } return new MappingNode(node.getTag(), tuples, node.getFlowStyle()); }