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; }
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); } }
if (type == String.class) { Construct stringConstructor = yamlConstructors.get(Tag.STR); result = stringConstructor.construct(node); } else if (type == Boolean.class || type == Boolean.TYPE) { Construct boolConstructor = yamlConstructors.get(Tag.BOOL); result = boolConstructor.construct(node); } else if (type == Character.class || type == Character.TYPE) { Construct charConstructor = yamlConstructors.get(Tag.STR); String ch = (String) charConstructor.construct(node); if (ch.length() == 0) { result = null; Date date = (Date) dateConstructor.construct(node); if (type == Date.class) { result = date; } else { Construct doubleConstructor = yamlConstructors.get(Tag.FLOAT); result = doubleConstructor.construct(node); if (type == Float.class || type == Float.TYPE) { result = Float.valueOf(((Double) result).floatValue()); || type == Short.TYPE || type == Integer.TYPE || type == Long.TYPE) { Construct intConstructor = yamlConstructors.get(Tag.INT); result = intConstructor.construct(node); if (type == Byte.class || type == Byte.TYPE) { result = Byte.valueOf(result.toString()); } else {
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; }
Object constructScalarNode(final ScalarNode node) { final Construct constructor = getConstructor(node); final Object object = constructor.construct(node); if (constructor instanceof ConstructYamlTimestamp) { final Calendar result = (Calendar)((ConstructYamlTimestamp)constructor).getCalendar().clone(); result.setLenient(false); return result; } return object; } }
/** * Construct object from the specified Node. Return existing instance if the * node is already constructed. * * @param node * Node to be constructed * @return Java instance */ protected Object constructObject(Node node) { if (constructedObjects.containsKey(node)) { return constructedObjects.get(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 = constructor.construct(node); constructedObjects.put(node, data); recursiveObjects.remove(node); if (node.isTwoStepsConstruction()) { constructor.construct2ndStep(node, data); } return data; }
@Override public Object construct(Node nnode) { if (nnode.getTag().equals("tag:yaml.org,2002:timestamp")) { Construct dateConstructor = yamlConstructors.get(Tag.TIMESTAMP); Date date = (Date) dateConstructor.construct(nnode); return new DateTime(date, DateTimeZone.UTC); } else { return super.construct(nnode); } } }
/** * Construct object from the specified Node. Return existing instance if the * node is already constructed. * * @param node * Node to be constructed * @return Java instance */ protected Object constructObject(Node node) { if (constructedObjects.containsKey(node)) { return constructedObjects.get(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 = constructor.construct(node); constructedObjects.put(node, data); recursiveObjects.remove(node); if (node.isTwoStepsConstruction()) { constructor.construct2ndStep(node, data); } return data; }
public Object construct(Node node) { ScalarNode scalar = (ScalarNode) node; try { return nf.parse(scalar.getValue()); } catch (ParseException e) { String lowerCaseValue = scalar.getValue().toLowerCase(); if (lowerCaseValue.contains("inf") || lowerCaseValue.contains("nan")) { /* * Non-finites such as (+/-)infinity and NaN are not * parseable by NumberFormat when these `Double` values are * dumped by snakeyaml. Delegate to the `Tag.FLOAT` * constructor when for this expected failure cause. */ return (Number) yamlConstructors.get(Tag.FLOAT).construct(node); } else { throw new IllegalArgumentException("Unable to parse as Number: " + scalar.getValue()); } } } }
Yaml y = new Yaml(new JodaPropertyConstructor()); class JodaPropertyConstructor extends Constructor { public JodaPropertyConstructor() { yamlClassConstructors.put(NodeId.scalar, new TimeStampConstruct()); } class TimeStampConstruct extends Constructor.ConstructScalar { @Override public Object construct(Node nnode) { if (nnode.getTag().equals("tag:yaml.org,2002:timestamp")) { Construct dateConstructor = yamlConstructors.get(Tag.TIMESTAMP); Date date = (Date) dateConstructor.construct(nnode); return new DateTime(date, DateTimeZone.UTC); } else { return super.construct(nnode); } } } }
public Object construct(Node node) { ScalarNode scalar = (ScalarNode) node; try { return nf.parse(scalar.getValue()); } catch (ParseException e) { String lowerCaseValue = scalar.getValue().toLowerCase(); if (lowerCaseValue.contains("inf") || lowerCaseValue.contains("nan")) { /* * Non-finites such as (+/-)infinity and NaN are not * parseable by NumberFormat when these `Double` values are * dumped by snakeyaml. Delegate to the `Tag.FLOAT` * constructor when for this expected failure cause. */ return (Number) yamlConstructors.get(Tag.FLOAT).construct(node); } else { throw new IllegalArgumentException("Unable to parse as Number: " + scalar.getValue()); } } } }
public Object construct(Node node) { Object result = null; try { result = 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); } return result; }
public Object construct(Node node) { Object result = null; try { result = 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); } return result; }
public Object construct(Node node) { Object result = null; try { result = 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); } return result; }
if (type == String.class) { Construct stringConstructor = yamlConstructors.get(Tag.STR); result = stringConstructor.construct(node); } else if (type == Boolean.class || type == Boolean.TYPE) { Construct boolConstructor = yamlConstructors.get(Tag.BOOL); result = boolConstructor.construct(node); } else if (type == Character.class || type == Character.TYPE) { Construct charConstructor = yamlConstructors.get(Tag.STR); String ch = (String) charConstructor.construct(node); if (ch.length() == 0) { result = null; Date date = (Date) dateConstructor.construct(node); if (type == Date.class) { result = date; } else { Construct doubleConstructor = yamlConstructors.get(Tag.FLOAT); result = doubleConstructor.construct(node); if (type == Float.class || type == Float.TYPE) { result = new Float((Double) result); || type == Short.TYPE || type == Integer.TYPE || type == Long.TYPE) { Construct intConstructor = yamlConstructors.get(Tag.INT); result = intConstructor.construct(node); if (type == Byte.class || type == Byte.TYPE) { result = Byte.valueOf(result.toString()); } else {
if (type == String.class) { Construct stringConstructor = yamlConstructors.get(Tag.STR); result = stringConstructor.construct(node); } else if (type == Boolean.class || type == Boolean.TYPE) { Construct boolConstructor = yamlConstructors.get(Tag.BOOL); result = boolConstructor.construct(node); } else if (type == Character.class || type == Character.TYPE) { Construct charConstructor = yamlConstructors.get(Tag.STR); String ch = (String) charConstructor.construct(node); if (ch.length() == 0) { result = null; Date date = (Date) dateConstructor.construct(node); if (type == Date.class) { result = date; } else { Construct doubleConstructor = yamlConstructors.get(Tag.FLOAT); result = doubleConstructor.construct(node); if (type == Float.class || type == Float.TYPE) { result = Float.valueOf(((Double) result).floatValue()); || type == Short.TYPE || type == Integer.TYPE || type == Long.TYPE) { Construct intConstructor = yamlConstructors.get(Tag.INT); result = intConstructor.construct(node); if (type == Byte.class || type == Byte.TYPE) { result = Byte.valueOf(result.toString()); } else {
@Override public Object construct(Node node) { return new Metadata(toMap(getConstructor().getConstructByNodeType(node).construct(node))); }
@Override public Object construct(Node node) { if (node instanceof ScalarNode) { if (StringUtils.isNotBlank(((ScalarNode) node).getValue())) { reportProblem( Problem.minor() .withType(DEPENDENCY_RESOLUTION) .withTitle("Redundant !override instruction used") .withDetails(String.format("Node [%s] is a scalar, !override tag is redundant in this case", node.getNodeId())) .build()); } } final Object baseValue = getConstructor().getConstructByNodeType(node).construct(node); return new ConfigurationMapOverlay.OverridingMap<>(toMap(baseValue)); }
@Override public Object construct(Node node) { final MgnlYamlConstructor constructor = getConstructor(); final Map<String, Object> baseData = ToMap.toMap(constructor.getConstructByNodeType(node).construct(node));
@Override public Object construct(Node node) { final Map<String, Object> baseData = ToMap.toMap(getConstructor().getConstructByNodeType(node).construct(node));