@Override public boolean hasNext() { return constructor.checkData(); }
protected Object constructArray(SequenceNode node) { return constructArrayStep2(node, createArray(node.getType(), node.getValue().size())); }
/** * Construct and return the next document * * @return constructed instance */ public Object getData() { // Construct and return the next document. composer.checkNode(); Node node = composer.getNode(); if (rootTag != null) { node.setTag(rootTag); } return constructDocument(node); }
protected Set<? extends Object> constructSet(SequenceNode node) { Set<Object> result = newSet(node); constructSequenceStep2(node, result); return result; }
protected Map<Object, Object> constructMapping(MappingNode node) { final Map<Object, Object> mapping = newMap(node); constructMapping2ndStep(node, mapping); return mapping; }
protected List<? extends Object> constructSequence(SequenceNode node) { List<Object> result = newList(node); constructSequenceStep2(node, result); return result; }
protected void constructSequenceStep2(SequenceNode node, Collection<Object> collection) { for (Node child : node.getValue()) { collection.add(constructObject(child)); } }
/** * Construct complete YAML document. Call the second step in case of * recursive structures. At the end cleans all the state. * * @param node root Node * @return Java instance */ protected final Object constructDocument(Node node) { Object data = constructObject(node); fillRecursive(); constructedObjects.clear(); recursiveObjects.clear(); return data; }
protected Map<Object, Object> constructMapping(MappingNode node) { Map<Object, Object> mapping = createDefaultMap(); constructMapping2ndStep(node, mapping); return mapping; }
protected Set<Object> constructSet(MappingNode node) { Set<Object> set = createDefaultSet(); constructSet2ndStep(node, set); return set; }
@SuppressWarnings("unchecked") protected List<? extends Object> constructSequence(SequenceNode node) { List<Object> result; if (List.class.isAssignableFrom(node.getType()) && !node.getType().isInterface()) { // the root class may be defined (Vector for instance) try { result = (List<Object>) node.getType().newInstance(); } catch (Exception e) { throw new YAMLException(e); } } else { result = createDefaultList(node.getValue().size()); } constructSequenceStep2(node, result); return result; }
@SuppressWarnings("unchecked") protected Set<? extends Object> constructSet(SequenceNode node) { Set<Object> result; if (!node.getType().isInterface()) { // the root class may be defined try { result = (Set<Object>) node.getType().newInstance(); } catch (Exception e) { throw new YAMLException(e); } } else { result = createDefaultSet(node.getValue().size()); } constructSequenceStep2(node, result); return result; }
@SuppressWarnings("unchecked") protected List<Object> newList(SequenceNode node) { try { return (List<Object>) newInstance(List.class, node); } catch (InstantiationException e) { return createDefaultList(node.getValue().size()); } }
@SuppressWarnings("unchecked") protected Map<Object, Object> newMap(MappingNode node) { try { return (Map<Object, Object>) newInstance(Map.class, node); } catch (InstantiationException e) { return createDefaultMap(node.getValue().size()); } }
protected Set<Object> constructSet(MappingNode node) { final Set<Object> set = newSet(node); constructSet2ndStep(node, set); return set; }
@Override protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) { flattenMapping(node); super.constructMapping2ndStep(node, mapping); }
@Override protected void constructSet2ndStep(MappingNode node, Set<Object> set) { flattenMapping(node); super.constructSet2ndStep(node, set); }
final Object value = constructObject(child);
/** * Construct complete YAML document. Call the second step in case of * recursive structures. At the end cleans all the state. * * @param node * root Node * @return Java instance */ protected final Object constructDocument(Node node) { Object data = constructObject(node); fillRecursive(); constructedObjects.clear(); recursiveObjects.clear(); return data; }
protected Map<Object, Object> constructMapping(MappingNode node) { Map<Object, Object> mapping = createDefaultMap(); constructMapping2ndStep(node, mapping); return mapping; }