public void setOnlyKeyType(Class<? extends Object> keyType) { for (NodeTuple nodes : value) { nodes.getKeyNode().setType(keyType); } }
@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 + ")>"; }
public void setTypes(Class<? extends Object> keyType, Class<? extends Object> valueType) { for (NodeTuple nodes : value) { nodes.getValueNode().setType(valueType); nodes.getKeyNode().setType(keyType); } }
@Override protected Construct getConstructor(Node node) { if (node instanceof MappingNode) { MappingNode mnode = (MappingNode) node; List<NodeTuple> list = mnode.getValue(); if (list.size() == 1) { NodeTuple tuple = list.get(0); Node key = tuple.getKeyNode(); if (key instanceof ScalarNode) { ScalarNode scalar = (ScalarNode) key; if (GUESS_COMPACT.matcher(scalar.getValue()).matches()) { return getCompactConstruct(); } } } } else if (node instanceof ScalarNode) { ScalarNode scalar = (ScalarNode) node; if (GUESS_COMPACT.matcher(scalar.getValue()).matches()) { return getCompactConstruct(); } } return super.getConstructor(node); }
int i = 0; for (NodeTuple tuple : nodeValue) { Node keyNode = tuple.getKeyNode(); if (!keyNode.getTag().equals(Tag.MERGE)) { Object key = constructObject(keyNode); throw new ConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e); if (!isAllowDuplicateKeys()) { throw new DuplicateKeyException(node.getStartMark(), key, tuple.getKeyNode().getStartMark());
protected void constructSet2ndStep(MappingNode node, Set<Object> set) { List<NodeTuple> nodeValue = node.getValue(); for (NodeTuple tuple : nodeValue) { Node keyNode = tuple.getKeyNode(); Object key = constructObject(keyNode); if (key != null) { try { key.hashCode();// check circular dependencies } catch (Exception e) { throw new ConstructorException("while constructing a Set", node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e); } } if (keyNode.isTwoStepsConstruction()) { /* * if keyObject is created it 2 steps we should postpone putting * it into the set because it may have different hash after * initialization compared to clean just created one. And set of * course does not observe value hashCode changes. */ sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key)); } else { set.add(key); } } }
public Object construct(Node node) { ScalarNode tmpNode; if (node instanceof MappingNode) { // Compact Object Notation may contain only one entry MappingNode mnode = (MappingNode) node; NodeTuple nodeTuple = mnode.getValue().iterator().next(); node.setTwoStepsConstruction(true); tmpNode = (ScalarNode) nodeTuple.getKeyNode(); // return constructScalar((ScalarNode) keyNode); } else { tmpNode = (ScalarNode) node; } CompactData data = getCompactData(tmpNode.getValue()); if (data == null) { // TODO: Should we throw an exception here ? return constructScalar(tmpNode); } return constructCompactFormat(tmpNode, data); } }
for (Object member : set) { NodeTuple tuple = iter.next(); Node keyNode = tuple.getKeyNode(); if (t.equals(member.getClass())) { if (keyNode.getNodeId() == NodeId.mapping) { MappingNode mnode = (MappingNode) node; for (NodeTuple tuple : mnode.getValue()) { resetTag(keyType, tuple.getKeyNode()); resetTag(valueType, tuple.getValueNode());
public static NodeTuple get(NodeTuple nodeTuple) { Node keyNode = nodeTuple.getKeyNode(); Node valueNode = nodeTuple.getValueNode(); return new NodeTuple(KeyScalarNode.get(keyNode), valueNode); }
continue; if (!((ScalarNode) tuple.getKeyNode()).isPlain()) { bestStyle = FlowStyle.BLOCK;
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) { List<NodeTuple> nodeValue = node.getValue(); for (NodeTuple tuple : nodeValue) { Node keyNode = tuple.getKeyNode(); Node valueNode = tuple.getValueNode(); Object key = constructObject(keyNode); throw new ConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
List<NodeTuple> map = mnode.getValue(); for (NodeTuple object : map) { Node key = object.getKeyNode(); Node value = object.getValueNode(); anchorNode(key);
while (iter.hasNext()) { final NodeTuple nodeTuple = iter.next(); final Node keyNode = nodeTuple.getKeyNode(); final Node valueNode = nodeTuple.getValueNode(); if (keyNode.getTag().equals(Tag.MERGE)) {
mnode.getStartMark()); Node keyNode = mnode.getValue().get(0).getKeyNode(); Node valueNode = mnode.getValue().get(0).getValueNode(); Object key = constructObject(keyNode);
mnode.getStartMark()); Node keyNode = mnode.getValue().get(0).getKeyNode(); Node valueNode = mnode.getValue().get(0).getValueNode(); Object key = constructObject(keyNode);
for (NodeTuple tuple : nodeValue) { ScalarNode keyNode; if (tuple.getKeyNode() instanceof ScalarNode) { keyNode = (ScalarNode) tuple.getKeyNode(); } else { throw new YAMLException( "Keys must be scalars but found: " + tuple.getKeyNode());
List<NodeTuple> map = mnode.getValue(); for (NodeTuple row : map) { Node key = row.getKeyNode(); Node value = row.getValueNode(); serializeNode(key, mnode);
/** * Dirty hack - remove 'id' if it is present. * * @param node - the node to remove the coordinate from * @return removed coordinate if it was removed */ private String removeId(MappingNode node) { NodeTuple id = null; String scalar = null; for (NodeTuple tuple : node.getValue()) { ScalarNode keyNode = (ScalarNode) tuple.getKeyNode(); String key = keyNode.getValue(); if ("id".equals(key)) { id = tuple; ScalarNode valueNode = (ScalarNode) tuple.getValueNode(); scalar = valueNode.getValue(); } } if (id != null) { node.getValue().remove(id); } return scalar; } }
Node keyNode = valueNode.getKeyNode(); Node childValueNode = valueNode.getValueNode(); if (keyNode instanceof ScalarNode && "configuration".equals(((ScalarNode) keyNode).getValue())) {
private String getTemplateName(Node templateReferenceNode) { Node templateNameNode = templateReferenceNode; if (templateReferenceNode.getNodeId() == mapping) { templateNameNode = ((MappingNode) templateReferenceNode).getValue().get(0).getKeyNode(); } return ((ScalarNode) templateNameNode).getValue(); }