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


Java Splitter.on方法代码示例

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


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

示例1: handleBothToolsAttributePresent

import com.google.common.base.Splitter; //导入方法依赖的package包/类
/**
 * Handles tools: namespace attributes presence in both documents.
 * @param higherPriority the higherPriority attribute
 */
private void handleBothToolsAttributePresent(
        XmlAttribute higherPriority) {

    // do not merge tools:node attributes, the higher priority one wins.
    if (getName().getLocalName().equals(NodeOperationType.NODE_LOCAL_NAME)) {
        return;
    }

    // everything else should be merged, duplicates should be eliminated.
    Splitter splitter = Splitter.on(',');
    ImmutableSet.Builder<String> targetValues = ImmutableSet.builder();
    targetValues.addAll(splitter.split(higherPriority.getValue()));
    targetValues.addAll(splitter.split(getValue()));
    higherPriority.getXml().setValue(Joiner.on(',').join(targetValues.build()));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:XmlAttribute.java

示例2: read

import com.google.common.base.Splitter; //导入方法依赖的package包/类
private static List<MprEntry> read(Reader reader) throws IOException {
    Splitter splitter = Splitter.on('\t');
    List<MprEntry> result = new ArrayList<>();
    BufferedReader bufferedReader = new BufferedReader(reader);
    String line;
    while ((line = bufferedReader.readLine()) != null) {
        Iterator<String> i = splitter.split(line).iterator();
        MprEntry mprEntry = new MprEntry();
        mprEntry.seedId = Integer.parseInt(i.next());
        mprEntry.interactionId = Integer.parseInt(i.next());
        mprEntry.bin = Integer.parseInt(i.next());
        mprEntry.score = Double.parseDouble(i.next());
        result.add(mprEntry);
    }
    return result;
}
 
开发者ID:ozgurdemir,项目名称:item-item-factorization,代码行数:17,代码来源:Mpr.java

示例3: loadFromRealData

import com.google.common.base.Splitter; //导入方法依赖的package包/类
@Override
public void loadFromRealData() throws Exception {
    TreeMap<String, V> map = new TreeMap<>();
    long t1 = System.currentTimeMillis();

    MynlpResource resource = environment.getMynlpResourceFactory().load(dicFilePath());

    Splitter splitter = Splitter.on(Pattern.compile("\\s"));
    try (CharSourceLineReader reader = resource.openLineReader()) {
        while (reader.hasNext()) {
            String line = reader.next();
            List<String> params = splitter.splitToList(line);
            if (!params.isEmpty()) {
                List<String> attrs = params.subList(1, params.size());
                V attribute = parseLine(attrs);
                map.put(params.get(0), attribute);
            }
        }
    }

    filtermap(map);

    DoubleArrayTrieBuilder<V> builder = new DoubleArrayTrieBuilder<>();
    this.trie = builder.build(map);
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:26,代码来源:CommonDictionary.java

示例4: DictionaryAidedDepluralizer

import com.google.common.base.Splitter; //导入方法依赖的package包/类
DictionaryAidedDepluralizer(String[] exceptions) {
  Map<String, String> map = Maps.newHashMapWithExpectedSize(exceptions.length);
  Splitter splitter = Splitter.on(':');
  for (String s : exceptions) {
    List<String> parts = splitter.splitToList(s.toLowerCase());
    if (parts.size() == 1) {
      // simple no-depluratization exception
      map.put(parts.get(0), parts.get(0));
    } else if (parts.size() == 2) {
      // singular, then plural, so mapping plural->singular
      map.put(parts.get(1), parts.get(0));
    }
  }
  this.dictionary = ImmutableMap.copyOf(map);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Depluralizer.java

示例5: doExtensiveTest

import com.google.common.base.Splitter; //导入方法依赖的package包/类
private void doExtensiveTest(String resourceName) throws IOException {
  Splitter splitter = Splitter.on(CharMatcher.whitespace());
  URL url = getClass().getResource(resourceName);
  for (String line : Resources.readLines(url, UTF_8)) {
    Iterator<String> iterator = splitter.split(line).iterator();
    String input = iterator.next();
    String expectedOutput = iterator.next();
    assertFalse(iterator.hasNext());
    assertEquals(expectedOutput, simplifyPath(input));
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:FilesSimplifyPathTest.java

示例6: 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

示例7: 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

示例8: format

import com.google.common.base.Splitter; //导入方法依赖的package包/类
private String format(String pattern, String value) {
    Splitter splitter = Splitter.on("%1$s");
    Joiner joiner = Joiner.on(value);
    return joiner.join(splitter.split(pattern));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:6,代码来源:ContentFieldInfo.java

示例9: generateSplitter

import com.google.common.base.Splitter; //导入方法依赖的package包/类
@Generates private Splitter generateSplitter() {
  return Splitter.on(generateString());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:4,代码来源:FreshValueGenerator.java


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