/** * Overrides the {@link Resolver#resolve(NodeId, String, boolean)} * method so that all implicit scalar non-{@code null} YAML node * values are resolved as {@link Tag#STR}. * * @param kind the kind of YAML node being processed; may be {@code * null} * * @param value the value of the node; may be {@code null} * * @param implicit whether the typing is implicit or explicit * * @return a {@link Tag} instance representing the YAML node type * * @see Resolver#resolve(NodeId, String, boolean) */ @Override public final Tag resolve(final NodeId kind, final String value, final boolean implicit) { final Tag returnValue; if (implicit && kind != null && value != null && NodeId.scalar.equals(kind) && !value.isEmpty()) { returnValue = Tag.STR; } else { returnValue = super.resolve(kind, value, implicit); } return returnValue; }
/** * Overrides the {@link Resolver#resolve(NodeId, String, boolean)} * method so that all implicit scalar non-{@code null} YAML node * values are resolved as {@link Tag#STR}. * * @param kind the kind of YAML node being processed; may be {@code * null} * * @param value the value of the node; may be {@code null} * * @param implicit whether the typing is implicit or explicit * * @return a {@link Tag} instance representing the YAML node type * * @see Resolver#resolve(NodeId, String, boolean) */ @Override public final Tag resolve(final NodeId kind, final String value, final boolean implicit) { final Tag returnValue; if (implicit && kind != null && value != null && NodeId.scalar.equals(kind) && !value.isEmpty()) { returnValue = Tag.STR; } else { returnValue = super.resolve(kind, value, implicit); } return returnValue; }
private String validateScalar(Node node) { if (node.isTwoStepsConstruction()) { throw new TagException("'"+node.getTag()+"' cannot be recursive.", node.getStartMark()); } if (!node.getNodeId().equals(NodeId.scalar)) { throw new TagException("'"+node.getTag()+"' must be a string.", node.getStartMark()); } return ((ScalarNode) node).getValue().toString(); } }