當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。