private boolean isNullNode(final Node valueNode) { return Tag.NULL.equals(valueNode.getTag()); }
protected Class<?> getClassForNode(Node node) { Class<? extends Object> classForTag = typeTags.get(node.getTag()); if (classForTag == null) { String name = node.getTag().getClassName(); Class<?> cl; try { cl = getClassForName(name); } catch (ClassNotFoundException e) { throw new YAMLException("Class not found: " + name); } typeTags.put(node.getTag(), cl); return cl; } else { return classForTag; } }
private boolean isEmptyMappingNode(final Node valueNode) { return Tag.MAP.equals(valueNode.getTag()) && ((MappingNode) valueNode).getValue().isEmpty(); } }
@Override public Object construct(Node node) { throw new ConstructorException(null, null, "could not determine a constructor for the tag " + node.getTag(), node.getStartMark()); } }
private boolean isEmptySequenceNode(final Node valueNode) { return Tag.SEQ.equals(valueNode.getTag()) && ((SequenceNode) valueNode).getValue().isEmpty(); }
public AnchorNode(Node realNode) { super(realNode.getTag(), realNode.getStartMark(), realNode.getEndMark()); this.realNode = realNode; }
/** * Get the constructor to construct the Node. For implicit tags if the * runtime class is known a dedicated Construct implementation is used. * Otherwise the constructor is chosen by the tag. * * @param node {@link Node} to construct an instance from * @return {@link Construct} implementation for the specified node */ protected Construct getConstructor(Node node) { if (node.useClassConstructor()) { return yamlClassConstructors.get(node.getNodeId()); } else { Construct constructor = yamlConstructors.get(node.getTag()); if (constructor == null) { for (String prefix : yamlMultiConstructors.keySet()) { if (node.getTag().startsWith(prefix)) { return yamlMultiConstructors.get(prefix); } } return yamlConstructors.get(null); } return constructor; } }
private void resetTag(Class<? extends Object> type, Node node) { Tag tag = node.getTag(); if (tag.matches(type)) { if (Enum.class.isAssignableFrom(type)) { node.setTag(Tag.STR); } else { node.setTag(Tag.MAP); } } }
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 void composeMappingChildren(List<NodeTuple> children, MappingNode node) { Node itemKey = composeKeyNode(node); if (itemKey.getTag().equals(Tag.MERGE)) { node.setMerged(true); } Node itemValue = composeValueNode(node); children.add(new NodeTuple(itemKey, itemValue)); }
for (NodeTuple tuple : nodeValue) { Node keyNode = tuple.getKeyNode(); if (!keyNode.getTag().equals(Tag.MERGE)) { Object key = constructObject(keyNode); if (key != null) {
final Node keyNode = nodeTuple.getKeyNode(); final Node valueNode = nodeTuple.getValueNode(); if (keyNode.getTag().equals(Tag.MERGE)) { iter.remove(); switch (valueNode.getNodeId()) {
/** * Ensure that the stream contains a single document and construct it * * @param type the class of the instance being created * @return constructed instance * @throws ComposerException in case there are more documents in the stream */ public Object getSingleData(Class<?> type) { // Ensure that the stream contains a single document and construct it Node node = composer.getSingleNode(); if (node != null && !Tag.NULL.equals(node.getTag())) { if (Object.class != type) { node.setTag(new Tag(type)); } else if (rootTag != null) { node.setTag(rootTag); } return constructDocument(node); } return null; }
Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true); Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false); ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node .getTag().equals(defaultTag)); ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple, scalarNode.getValue(), null, null, scalarNode.getStyle()); this.emitter.emit(event); case sequence: SequenceNode seqNode = (SequenceNode) node; boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence, null, true)); this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(), implicitS, null, null, seqNode.getFlowStyle())); List<Node> list = seqNode.getValue(); default:// instance of MappingNode Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true); boolean implicitM = node.getTag().equals(implicitTag); this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(), implicitM, null, null, ((CollectionNode) node).getFlowStyle())); MappingNode mnode = (MappingNode) node;
if (property.getType() == propertyValue.getClass()) { if (!(propertyValue instanceof Map<?, ?>)) { if (!nodeValue.getTag().equals(Tag.SET)) { nodeValue.setTag(Tag.MAP);
if (property.getType() == String.class && Tag.BINARY.equals(valueNode.getTag()) && value instanceof byte[]) { value = new String((byte[]) value);
@Override protected Object constructObject(Node node) { Tag tag = node.getTag(); if (!SUPPORTED_TAGS.contains(tag)) { node.setTag(Tag.STR); } return super.constructObject(node); }
public Object construct(Node node) { throw new ConstructorException(null, null, "could not determine a constructor for the tag " + node.getTag(), node.getStartMark()); } }
@Override public Object construct(Node node) { throw new ConstructorException(null, null, "could not determine a constructor for the tag " + node.getTag(), node.getStartMark()); } }