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


Java Splitter.split方法代码示例

本文整理汇总了Java中com.google.common.base.Splitter.split方法的典型用法代码示例。如果您正苦于以下问题:Java Splitter.split方法的具体用法?Java Splitter.split怎么用?Java Splitter.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.base.Splitter的用法示例。


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

示例1: getLanguages

import com.google.common.base.Splitter; //导入方法依赖的package包/类
/**
 * Returns the sorted list of languages used in the resources.
 */
@NonNull
public SortedSet<String> getLanguages() {
    SortedSet<String> set = new TreeSet<String>();

    // As an optimization we could just look for values since that's typically where
    // the languages are defined -- not on layouts, menus, etc -- especially if there
    // are no translations for it
    Set<String> qualifiers = Sets.newHashSet();

    synchronized (ITEM_MAP_LOCK) {
        for (ListMultimap<String, ResourceItem> map : getMap().values()) {
            for (ResourceItem item : map.values()) {
                qualifiers.add(item.getQualifiers());
            }
        }
    }

    Splitter splitter = Splitter.on('-');
    for (String s : qualifiers) {
        for (String qualifier : splitter.split(s)) {
            if (qualifier.length() == 2 && Character.isLetter(qualifier.charAt(0))
                    && Character.isLetter(qualifier.charAt(1))) {
                set.add(qualifier);
            }
        }
    }

    return set;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:33,代码来源:AbstractResourceRepository.java

示例2: getRegions

import com.google.common.base.Splitter; //导入方法依赖的package包/类
/**
 * Returns the sorted list of regions used in the resources with the given language.
 * @param currentLanguage the current language the region must be associated with.
 */
@NonNull
public SortedSet<String> getRegions(@NonNull String currentLanguage) {
    SortedSet<String> set = new TreeSet<String>();

    // As an optimization we could just look for values since that's typically where
    // the languages are defined -- not on layouts, menus, etc -- especially if there
    // are no translations for it
    Set<String> qualifiers = Sets.newHashSet();
    synchronized (ITEM_MAP_LOCK) {
        for (ListMultimap<String, ResourceItem> map : getMap().values()) {
            for (ResourceItem item : map.values()) {
                qualifiers.add(item.getQualifiers());
            }
        }
    }

    Splitter splitter = Splitter.on('-');
    for (String s : qualifiers) {
        boolean rightLanguage = false;
        for (String qualifier : splitter.split(s)) {
            if (currentLanguage.equals(qualifier)) {
                rightLanguage = true;
            } else if (rightLanguage
                    && qualifier.length() == 3
                    && qualifier.charAt(0) == 'r'
                    && Character.isUpperCase(qualifier.charAt(1))
                    && Character.isUpperCase(qualifier.charAt(2))) {
                set.add(qualifier.substring(1));
            }
        }
    }

    return set;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:39,代码来源:AbstractResourceRepository.java

示例3: splitAuthFields

import com.google.common.base.Splitter; //导入方法依赖的package包/类
private ArrayMap<String, String> splitAuthFields(String authString) {
    final ArrayMap<String, String> fields = new ArrayMap<>();
    final CharMatcher trimmer = CharMatcher.anyOf("\"\t ");
    final Splitter commas = Splitter.on(',').trimResults().omitEmptyStrings();
    final Splitter equals = Splitter.on('=').trimResults(trimmer).limit(2);
    String[] valuePair;
    for (String keyPair : commas.split(authString)) {
        valuePair = Iterables.toArray(equals.split(keyPair), String.class);
        fields.put(valuePair[0], valuePair[1]);
    }
    return fields;
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:13,代码来源:HttpAuth.java


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