node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e); if (prevIndex != null) { 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); } } }
if (!(subnode instanceof MappingNode)) { throw new ConstructorException("while constructing a mapping", node.getStartMark(), "expected a mapping for merging, but found " + subnode.getNodeId(), default: throw new ConstructorException("while constructing a mapping", node.getStartMark(), "expected a mapping or list of mappings for merging, but found " + valueNode.getNodeId(),
node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
"expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark());
node.getStartMark(), "expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark());
throw new ConstructorException( "Cannot create property=" + key + " for JavaBean=" + object, node.getStartMark(), e.getMessage(), valueNode.getStartMark(), e);
@Override public void onMappingNodeEnd(MappingNode mappingNode, TupleType tupleType) { if (tupleType == KEY) { throw new YAMLException(NON_SCALAR_KEY_MESSAGE + ": " + mappingNode.getStartMark()); } documentContext.pop(); }
@Override public void onMappingNodeEnd(MappingNode mappingNode, TupleType tupleType) { if (tupleType == KEY) { throw new YAMLException(NON_SCALAR_KEY_MESSAGE + ": " + mappingNode.getStartMark()); } documentContext.pop(); }
@Override public boolean onMappingNodeStart(MappingNode mappingNode, TupleType tupleType) { if (tupleType == KEY) { throw new YAMLException(NON_SCALAR_KEY_MESSAGE + ": " + mappingNode.getStartMark()); } NodeBuilder<?> currentBuilder = builderContext.peek(); Object parentObject = documentContext.peek(); Object object = ((TupleBuilder<?, MappingNode>) currentBuilder).buildValue(parentObject, mappingNode); documentContext.push(object); return true; }
@Override public boolean onMappingNodeStart(MappingNode mappingNode, TupleType tupleType) { if (tupleType == KEY) { throw new YAMLException(NON_SCALAR_KEY_MESSAGE + ": " + mappingNode.getStartMark()); } NodeBuilder<?> currentBuilder = builderContext.peek(); Object parentObject = documentContext.peek(); Object object = ((TupleBuilder<?, MappingNode>) currentBuilder).buildValue(parentObject, mappingNode); documentContext.push(object); return true; }
@Override protected Map<Object, Object> constructMapping(MappingNode node) { try { return super.constructMapping(node); } catch (IllegalStateException ex) { throw new ParserException("while parsing MappingNode", node.getStartMark(), ex.getMessage(), node.getEndMark()); } }
@Override protected Map<Object, Object> constructMapping(MappingNode node) { try { return super.constructMapping(node); } catch (IllegalStateException ex) { throw new ParserException("while parsing MappingNode", node.getStartMark(), ex.getMessage(), node.getEndMark()); } }
private void visitMappingNode(MappingNode mappingNode, TupleType tupleType) { if (checkLoop(mappingNode)) { nodeHandler.onCustomTagError(LOOP_TAG, mappingNode, "Circular reference detected"); return; } boolean keepOnVisiting = nodeHandler.onMappingNodeStart(mappingNode, tupleType); if (tupleType == VALUE && keepOnVisiting) { doVisitMappingNode(mappingNode); } nodeHandler.onMappingNodeEnd(mappingNode, tupleType); if (mappingNode.getStartMark() != null) { loopDetector.pop(); } }
private void visitMappingNode(MappingNode mappingNode, TupleType tupleType) { if (checkLoop(mappingNode)) { nodeHandler.onCustomTagError(LOOP_TAG, mappingNode, "Circular reference detected"); return; } boolean keepOnVisiting = nodeHandler.onMappingNodeStart(mappingNode, tupleType); if (tupleType == VALUE && keepOnVisiting) { doVisitMappingNode(mappingNode); } nodeHandler.onMappingNodeEnd(mappingNode, tupleType); if (mappingNode.getStartMark() != null) { loopDetector.pop(); } }
protected void constructSet2ndStep(MappingNode node, Set<Object> set) { List<NodeTuple> nodeValue = (List<NodeTuple>) 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); } } }
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); } } }
"expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark());
public Object construct(Node node) { // Note: we do not check for duplicate keys, because it's too // CPU-expensive. if (!(node instanceof SequenceNode)) { throw new ConstructorException("while constructing pairs", node.getStartMark(), "expected a sequence, but found " + node.getNodeId(), node.getStartMark()); } SequenceNode snode = (SequenceNode) node; List<Object[]> pairs = new ArrayList<Object[]>(snode.getValue().size()); for (Node subnode : snode.getValue()) { if (!(subnode instanceof MappingNode)) { throw new ConstructorException("while constructingpairs", node.getStartMark(), "expected a mapping of length 1, but found " + subnode.getNodeId(), subnode.getStartMark()); } MappingNode mnode = (MappingNode) subnode; if (mnode.getValue().size() != 1) { throw new ConstructorException("while constructing pairs", node.getStartMark(), "expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark()); } Node keyNode = mnode.getValue().get(0).getKeyNode(); Node valueNode = mnode.getValue().get(0).getValueNode(); Object key = constructObject(keyNode); Object value = constructObject(valueNode); pairs.add(new Object[] { key, value }); } return pairs; } }
public Object construct(Node node) { // Note: we do not check for duplicate keys, because it's too // CPU-expensive. if (!(node instanceof SequenceNode)) { throw new ConstructorException("while constructing pairs", node.getStartMark(), "expected a sequence, but found " + node.getNodeId(), node.getStartMark()); } SequenceNode snode = (SequenceNode) node; List<Object[]> pairs = new ArrayList<Object[]>(snode.getValue().size()); for (Node subnode : snode.getValue()) { if (!(subnode instanceof MappingNode)) { throw new ConstructorException("while constructingpairs", node.getStartMark(), "expected a mapping of length 1, but found " + subnode.getNodeId(), subnode.getStartMark()); } MappingNode mnode = (MappingNode) subnode; if (mnode.getValue().size() != 1) { throw new ConstructorException("while constructing pairs", node.getStartMark(), "expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark()); } Node keyNode = mnode.getValue().get(0).getKeyNode(); Node valueNode = mnode.getValue().get(0).getValueNode(); Object key = constructObject(keyNode); Object value = constructObject(valueNode); pairs.add(new Object[] { key, value }); } return pairs; } }