Java Code Examples for org.yaml.snakeyaml.nodes.Tag#BOOL

The following examples show how to use org.yaml.snakeyaml.nodes.Tag#BOOL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurationAsCode.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
private Tag getTag(Scalar.Format format) {
    switch (format) {
        case NUMBER:
            return Tag.INT;
        case FLOATING:
            return Tag.FLOAT;
        case BOOLEAN:
            return Tag.BOOL;
        case STRING:
        case MULTILINESTRING:
        default:
            return Tag.STR;
    }
}
 
Example 2
Source File: YamlTagResolver.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Override
public void addImplicitResolver(Tag tag, Pattern regexp, String first)
{
    // This method is called by constructor through addImplicitResolvers
    // to setup default implicit resolvers.

    if (tag.equals(Tag.FLOAT)) {
        super.addImplicitResolver(tag, FLOAT_EXCEPTING_ZERO_START, first);
    }
    else if (tag.equals(Tag.INT)) {
        // This solves some unexpected behavior that snakeyaml
        // deserializes "10:00:00" to 3600.
        // See also org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlInt
        super.addImplicitResolver(tag, INT_EXCEPTING_COLON, first);
    }
    else if (tag.equals(Tag.BOOL)) {
        // use stricter rule (reject 'On', 'Off', 'Yes', 'No')
        super.addImplicitResolver(Tag.BOOL, Pattern.compile("^(?:[Tt]rue|[Ff]alse)$"), "TtFf");
    }
    else if (tag.equals(Tag.TIMESTAMP)) {
        // This solves some unexpected behavior that snakeyaml
        // deserializes "2015-01-01 00:00:00" to java.util.Date
        // but jackson serializes java.util.Date to an integer.
        // See also org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlTimestamp
        return;
    }
    else {
        super.addImplicitResolver(tag, regexp, first);
    }
}
 
Example 3
Source File: YamlTagResolver.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Override
public void addImplicitResolver(Tag tag, Pattern regexp, String first)
{
    // This method is called by constructor through addImplicitResolvers
    // to setup default implicit resolvers.

    if (tag.equals(Tag.FLOAT)) {
        super.addImplicitResolver(tag, FLOAT_EXCEPTING_ZERO_START, first);
    }
    else if (tag.equals(Tag.INT)) {
        // This solves some unexpected behavior that snakeyaml
        // deserializes "10:00:00" to 3600.
        // See also org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlInt
        super.addImplicitResolver(tag, INT_EXCEPTING_COLON, first);
    }
    else if (tag.equals(Tag.BOOL)) {
        // use stricter rule (reject 'On', 'Off', 'Yes', 'No')
        super.addImplicitResolver(Tag.BOOL, Pattern.compile("^(?:[Tt]rue|[Ff]alse)$"), "TtFf");
    }
    else if (tag.equals(Tag.TIMESTAMP)) {
        // This solves some unexpected behavior that snakeyaml
        // deserializes "2015-01-01 00:00:00" to java.util.Date
        // but jackson serializes java.util.Date to an integer.
        // See also org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlTimestamp
        return;
    }
    else {
        super.addImplicitResolver(tag, regexp, first);
    }
}