/** * Fail with a reminder to provide the seconds step for a recursive * structure * * @see org.yaml.snakeyaml.constructor.Construct#construct2ndStep(org.yaml.snakeyaml.nodes.Node, * java.lang.Object) */ public void construct2ndStep(Node node, Object data) { if (node.isTwoStepsConstruction()) { throw new IllegalStateException("Not Implemented in " + getClass().getName()); } else { throw new YAMLException("Unexpected recursive structure for Node: " + node); } } }
@Override public Object construct(Node node) { if (node.isTwoStepsConstruction()) { return (constructedObjects.containsKey(node) ? constructedObjects.get(node) : createDefaultSet(((MappingNode) node).getValue().size())); } else { return constructSet((MappingNode) node); } }
@Override @SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object data) { if (node.isTwoStepsConstruction()) { constructSequenceStep2((SequenceNode) node, (List<Object>) data); } else { throw new YAMLException("Unexpected recursive sequence structure. Node: " + node); } } }
@Override @SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (node.isTwoStepsConstruction()) { constructSet2ndStep((MappingNode) node, (Set<Object>) object); } else { throw new YAMLException("Unexpected recursive set structure. Node: " + node); } } }
@Override @SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (node.isTwoStepsConstruction()) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else { throw new YAMLException("Unexpected recursive mapping structure. Node: " + node); } } }
@Override public Object construct(Node node) { SequenceNode seqNode = (SequenceNode) node; if (node.isTwoStepsConstruction()) { return newList(seqNode); } else { return constructSequence(seqNode); } }
@Override public Object construct(Node node) { MappingNode mnode = (MappingNode) node; if (node.isTwoStepsConstruction()) { return createDefaultMap(mnode.getValue().size()); } else { return constructMapping(mnode); } }
protected Object constructObjectNoCheck(Node node) { if (recursiveObjects.contains(node)) { throw new ConstructorException(null, null, "found unconstructable recursive node", node.getStartMark()); } recursiveObjects.add(node); Construct constructor = getConstructor(node); Object data = (constructedObjects.containsKey(node)) ? constructedObjects.get(node) : constructor.construct(node); finalizeConstruction(node, data); constructedObjects.put(node, data); recursiveObjects.remove(node); if (node.isTwoStepsConstruction()) { constructor.construct2ndStep(node, data); } return data; }
@Override public Object construct(Node node) { if (node.isTwoStepsConstruction()) { throw new YAMLException("Unexpected referential mapping structure. Node: " + node); } Map<?, ?> raw = (Map<?, ?>) super.construct(node); if (raw.containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) { Map<String, Object> typed = new LinkedHashMap<String, Object>(raw.size()); for (Map.Entry<?, ?> entry : raw.entrySet()) { typed.put(entry.getKey().toString(), entry.getValue()); } try { return ConfigurationSerialization.deserializeObject(typed); } catch (IllegalArgumentException ex) { throw new YAMLException("Could not deserialize object", ex); } } return raw; }
MappingNode mnode = (MappingNode) node; if (Map.class.isAssignableFrom(node.getType())) { if (node.isTwoStepsConstruction()) { return newMap(mnode); } else { if (node.isTwoStepsConstruction()) { return newSet(mnode); } else { if (node.isTwoStepsConstruction()) { return obj; } else {
SequenceNode snode = (SequenceNode) node; if (Set.class.isAssignableFrom(node.getType())) { if (node.isTwoStepsConstruction()) { throw new YAMLException("Set cannot be recursive."); } else { if (node.isTwoStepsConstruction()) { return newList(snode); } else { if (node.isTwoStepsConstruction()) { return createArray(node.getType(), snode.getValue().size()); } else {
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 (keyNode.isTwoStepsConstruction()) {
@Override public Object construct(Node node) { if (node.isTwoStepsConstruction()) { return (constructedObjects.containsKey(node) ? constructedObjects.get(node) : createDefaultSet()); } else { return constructSet((MappingNode) node); } }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (node.isTwoStepsConstruction()) { constructSet2ndStep((MappingNode) node, (Set<Object>) object); } else { throw new YAMLException("Unexpected recursive set structure. Node: " + node); } } }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object data) { if (node.isTwoStepsConstruction()) { constructSequenceStep2((SequenceNode) node, (List<Object>) data); } else { throw new YAMLException("Unexpected recursive sequence structure. Node: " + node); } } }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (node.isTwoStepsConstruction()) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else { throw new YAMLException("Unexpected recursive mapping structure. Node: " + node); } } }
public Object construct(Node node) { if (node.isTwoStepsConstruction()) { return createDefaultSet(); } else { return constructSet((MappingNode) node); } }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (node.isTwoStepsConstruction()) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else { throw new YAMLException("Unexpected recursive mapping structure. Node: " + node); } } }
@Override public Object construct(Node node) { if (node.isTwoStepsConstruction()) { return createDefaultMap(); } else { return constructMapping((MappingNode) node); } }