@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); }
protected Set<Object> constructSet(MappingNode node) { final Set<Object> set = newSet(node); constructSet2ndStep(node, set); return set; }
private static <T> T parseObject(String rawConfig) { Constructor constructor = new Constructor(ConfiguratorConfig.class); TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class); itemDescription.addPropertyParameters("items", ConfigItem.class); constructor.addTypeDescription(itemDescription); Yaml yaml = new Yaml(constructor); return yaml.load(rawConfig); }
/** * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * * @param representer * Representer to emit outgoing objects */ public Yaml(Representer representer) { this(new Constructor(), representer); }
public SafeConstructor() { this.yamlConstructors.put(Tag.NULL, new ConstructYamlNull()); this.yamlConstructors.put(Tag.BOOL, new ConstructYamlBool()); this.yamlConstructors.put(Tag.INT, new ConstructYamlInt()); this.yamlConstructors.put(Tag.FLOAT, new ConstructYamlFloat()); this.yamlConstructors.put(Tag.BINARY, new ConstructYamlBinary()); this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructYamlTimestamp()); this.yamlConstructors.put(Tag.OMAP, new ConstructYamlOmap()); this.yamlConstructors.put(Tag.PAIRS, new ConstructYamlPairs()); this.yamlConstructors.put(Tag.SET, new ConstructYamlSet()); this.yamlConstructors.put(Tag.STR, new ConstructYamlStr()); this.yamlConstructors.put(Tag.SEQ, new ConstructYamlSeq()); this.yamlConstructors.put(Tag.MAP, new ConstructYamlMap()); this.yamlConstructors.put(null, undefinedConstructor); this.yamlClassConstructors.put(NodeId.scalar, undefinedConstructor); this.yamlClassConstructors.put(NodeId.sequence, undefinedConstructor); this.yamlClassConstructors.put(NodeId.mapping, undefinedConstructor); }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (Map.class.isAssignableFrom(node.getType())) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else if (Set.class.isAssignableFrom(node.getType())) { constructSet2ndStep((MappingNode) node, (Set<Object>) object); } else { constructJavaBean2ndStep((MappingNode) node, object); } }
public Object construct(Node node) { try { return getConstructor(node).construct(node); } catch (ConstructorException e) { throw e; } catch (Exception e) { throw new ConstructorException(null, null, "Can't construct a java object for " + node.getTag() + "; exception=" + e.getMessage(), node.getStartMark(), e); } }
public void construct2ndStep(Node node, Object object) { try { getConstructor(node).construct2ndStep(node, object); } catch (Exception e) { throw new ConstructorException( null, null, "Can't construct a second step for a java object for " + node.getTag() + "; exception=" + e.getMessage(), node.getStartMark(), e); } } }
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; }
@Override public Object construct(Node node) { constructScalar((ScalarNode) node); return null; } }
@Override public boolean hasNext() { return constructor.checkData(); }
@Override public Object next() { return constructor.getData(); }
/** * Create Constructor for the specified class as the root. * * @param theRoot * - the class (usually JavaBean) to be constructed */ public Constructor(Class<? extends Object> theRoot) { this(new TypeDescription(checkRoot(theRoot))); }
final protected Object newInstance(Class<?> ancestor, Node node) throws InstantiationException { return newInstance(ancestor, node, true); }
public void addTypeDescription(TypeDescription td) { constructor.addTypeDescription(td); representer.addTypeDescription(td); } }
private static <T> T parseObject(String rawConfig) { Constructor constructor = new Constructor(ConfiguratorConfig.class); TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class); itemDescription.addPropertyParameters("items", ConfigItem.class); constructor.addTypeDescription(itemDescription); Yaml yaml = new Yaml(constructor); return yaml.load(rawConfig); }
@Override public Object construct(Node node) { return constructScalar((ScalarNode) node); } }