当前位置: 首页>>代码示例>>Java>>正文


Java Tag.BINARY属性代码示例

本文整理汇总了Java中org.yaml.snakeyaml.nodes.Tag.BINARY属性的典型用法代码示例。如果您正苦于以下问题:Java Tag.BINARY属性的具体用法?Java Tag.BINARY怎么用?Java Tag.BINARY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.yaml.snakeyaml.nodes.Tag的用法示例。


在下文中一共展示了Tag.BINARY属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: representData

public Node representData(Object data) {
    Tag tag = Tag.STR;
    Character style = null;
    String value = data.toString();
    if (StreamReader.NON_PRINTABLE.matcher(value).find()) {
        tag = Tag.BINARY;
        char[] binary;
        try {
            binary = Base64Coder.encode(value.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new YAMLException(e);
        }
        value = String.valueOf(binary);
        style = '|';
    }
    // if no other scalar style is explicitly set, use literal style for
    // multiline scalars
    if (defaultScalarStyle == null && MULTILINE_PATTERN.matcher(value).find()) {
        style = '|';
    }
    return representScalar(tag, value, style);
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:22,代码来源:SafeRepresenter.java

示例2: representData

public Node representData(Object data) {
    Tag tag = Tag.STR;
    Character style = null;
    String value = data.toString();
    if (!StreamReader.isPrintable(value)) {
        tag = Tag.BINARY;
        char[] binary;
        try {
            final byte[] bytes = value.getBytes("UTF-8");
            // sometimes above will just silently fail - it will return incomplete data
            // it happens when String has invalid code points
            // (for example half surrogate character without other half)
            final String checkValue = new String(bytes, "UTF-8");
            if (!checkValue.equals(value)) {
                throw new YAMLException("invalid string value has occurred");
            }
            binary = Base64Coder.encode(bytes);
        } catch (UnsupportedEncodingException e) {
            throw new YAMLException(e);
        }
        value = String.valueOf(binary);
        style = '|';
    }
    // if no other scalar style is explicitly set, use literal style for
    // multiline scalars
    if (defaultScalarStyle == null && MULTILINE_PATTERN.matcher(value).find()) {
        style = '|';
    }
    return representScalar(tag, value, style);
}
 
开发者ID:RoccoDev,项目名称:5zig-TIMV-Plugin,代码行数:30,代码来源:SafeRepresenter.java

示例3: representString

public final Node representString(String data)
{
    Tag tag = Tag.STR;
    Character style = null;
    String value = data;
    if (! isPrintable(value))
    {
        tag = Tag.BINARY;

        char[] binary;
        try
        {
            byte[] bytes = value.getBytes("UTF-8");
            String checkValue = new String(bytes, "UTF-8");
            if (! checkValue.equals(value))
            {
                throw new YAMLException("invalid string value has occurred");
            }

            binary = Base64Coder.encode(bytes);
        }
        catch (UnsupportedEncodingException var8)
        {
            throw new YAMLException(var8);
        }

        value = String.valueOf(binary);
        style = '|';
    }

    if ((this.getDefaultScalarStyle() == null) && Representer.MULTILINE_PATTERN.matcher(value).find())
    {
        style = '|';
    }

    return this.representer.representScalar(tag, value, style);
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:37,代码来源:AbstractRepresent.java


注:本文中的org.yaml.snakeyaml.nodes.Tag.BINARY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。