List of usage examples for com.google.common.base CharMatcher CharMatcher
protected CharMatcher()
From source file:org.kalypso.ui.rrm.internal.results.view.tree.strategies.NaModelStrategy.java
private TreeNode doAddResultCategries(final RrmSimulation simulation, final RrmCalculationResult calculation, final TreeNode parent, final String path, final Map<Pair<Integer, String>, TreeNode> registry) { final CharMatcher matcher = new CharMatcher() { @Override//from ww w. j a v a 2 s . co m public boolean matches(final char c) { switch (c) { case '/': //$NON-NLS-1$ case '\\'://$NON-NLS-1$ case ';'://$NON-NLS-1$ return true; default: return false; } } }; final Iterable<String> parts = Splitter.on(matcher).trimResults().omitEmptyStrings().split(path); //$NON-NLS-1$ int count = 0; TreeNode ptr = parent; for (final String part : parts) { final Pair<Integer, String> index = Pair.of(count, part); TreeNode node = registry.get(index); if (Objects.isNull(node)) { node = new TreeNode(ptr, new ResultCategoryUiHandler(simulation, calculation, part, m_view), part); ptr.addChild(node); registry.put(index, node); } ptr = node; count++; } return ptr; }
From source file:org.apache.druid.indexing.overlord.ForkingTaskRunner.java
@Override public Iterator<String> iterator() { return Splitter.on(new CharMatcher() { private boolean inQuotes = false; @Override/* ww w. j a va2 s . c o m*/ public boolean matches(char c) { if ('"' == c) { inQuotes = !inQuotes; } if (inQuotes) { return false; } return CharMatcher.BREAKING_WHITESPACE.matches(c); } }).omitEmptyStrings().split(string).iterator(); }