Example usage for com.google.common.base Splitter on

List of usage examples for com.google.common.base Splitter on

Introduction

In this page you can find the example usage for com.google.common.base Splitter on.

Prototype

@CheckReturnValue
@GwtIncompatible("java.util.regex")
public static Splitter on(final Pattern separatorPattern) 

Source Link

Document

Returns a splitter that considers any subsequence matching pattern to be a separator.

Usage

From source file:com.fitbur.core.guava.base.SplitterResolver.java

@Override
public Optional resolve(Injectee injectee, ServiceHandle<?> root) {
    return reflectionService.findQualifier(injectee, Named.class).map(p -> Splitter.on(p.value()));
}

From source file:com.ning.arecibo.collector.process.FilterOutAttributesEventFilter.java

@Inject
public FilterOutAttributesEventFilter(final CollectorConfig config) {
    this(Splitter.on(",").split(config.getAttributesToIgnore()));
}

From source file:io.prestosql.plugin.jmx.JmxConnectorConfig.java

@Config("jmx.dump-tables")
public JmxConnectorConfig setDumpTables(String tableNames) {
    this.dumpTables = Splitter.on(Pattern.compile("(?<!\\\\),")) // match "," not preceded by "\"
            .omitEmptyStrings().splitToList(tableNames).stream().map(part -> part.replace("\\,", ",")) // unescape all escaped commas
            .collect(Collectors.toSet());
    return this;
}

From source file:ru.codeinside.adm.parser.EmployeeFixtureParser.java

public void loadFixtures(InputStream is, EmployeeFixtureParser.PersistenceCallback callback)
        throws IOException {
    final Splitter propertySplitter = Splitter.on(';');
    final BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
    String line;/*  w  w  w.j a  v  a2  s.  c  om*/
    int lineNumber = 0;
    while ((line = reader.readLine()) != null) {
        lineNumber++;
        int level = startIndex(line);
        if (line.startsWith("#") || level < 0) {
            continue;
        }
        final ArrayList<String> props = Lists.newArrayList(propertySplitter.split(line.substring(level)));
        final String name = StringUtils.trimToNull(props.get(0));
        if (name == null) {
            if (props.size() == 1) {
                continue;
            }
            throw new IllegalStateException(" ?( ?:" + lineNumber + ")");
        } else if (name.length() >= 255) {
            throw new IllegalStateException(
                    "     255 ? (?: "
                            + lineNumber + ")");
        }
        final boolean isOrg = props.size() <= 2;
        Row parent = getParentRow(level);
        final Set<String> groups = parseGroups(props, getGroupPropertyIndex(isOrg));
        if (isOrg) {
            long orgId = callback.onOrganizationComplete(name, groups, parent != null ? parent.id : null);
            stack.addLast(new Row(level, orgId));
        }
        if (!isOrg && parent != null) {
            String pwd = defaultIfEmpty(trimToNull(props.get(2)), null);
            Set<Role> roles = parseRoles(groupSplitter, lineNumber, props.get(3));
            callback.onUserComplete(StringUtils.trim(props.get(1)), pwd, name, parent.id, roles, groups);
        }
        if (!isOrg && parent == null) {
            throw new IllegalStateException(
                    "  (?:" + lineNumber + ").");
        }
    }
}

From source file:org.jclouds.elastichosts.functions.SplitNewlines.java

@Override
public Set<String> apply(HttpResponse response) {
    return Sets.newTreeSet(Splitter.on('\n').split(returnStringIf200.apply(response)));
}

From source file:tv.icntv.grade.film.grade.num.NumProgramSetsMapper.java

@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

    if (value == null || Strings.isNullOrEmpty(value.toString())) {
        return;//from w ww.jav a 2s .  co m
    }
    List<String> vs = Lists.newArrayList(Splitter.on("\t").split(value.toString()));
    if (null == vs || vs.isEmpty() || vs.size() != 4) {
        System.out.println("value format error ");
        return;
    }
    String programeSets = vs.get(2);
    String num = vs.get(3);
    if (Strings.isNullOrEmpty(programeSets)) {
        return;
    }
    Iterable<String> iterable = Splitter.on(CharMatcher.is(',').or(CharMatcher.is('`'))).split(programeSets);
    for (Iterator<String> it = iterable.iterator(); it.hasNext();) {
        String k = it.next();
        context.write(new Text(k), new Text(num));
    }

}

From source file:com.googlecode.blaisemath.util.xml.Point2DAdapter.java

@Override
public Point2D.Double unmarshal(String v) {
    if (v == null) {
        return null;
    }//from w  ww  .  j av  a 2  s. c  o  m
    Matcher m = Pattern.compile("point\\[(.*)\\]").matcher(v.toLowerCase().trim());
    if (m.find()) {
        String inner = m.group(1);
        Iterable<String> kv = Splitter.on(",").trimResults().split(inner);
        try {
            Double x = Double.valueOf(Iterables.get(kv, 0));
            Double y = Double.valueOf(Iterables.get(kv, 1));
            return new Point2D.Double(x, y);
        } catch (NumberFormatException x) {
            Logger.getLogger(Point2DAdapter.class.getName()).log(Level.FINEST, "Not a double", x);
            return null;
        }
    } else {
        Logger.getLogger(Point2DAdapter.class.getName()).log(Level.FINEST, "Not a valid point", v);
        return null;
    }
}

From source file:com.googlecode.blaisemath.util.xml.RectAdapter.java

@Override
public Rectangle2D unmarshal(String v) {
    if (v == null) {
        return null;
    }//  ww  w .  j av a2s .  co m
    Matcher m = Pattern.compile("rectangle\\[(.*)\\]").matcher(v.toLowerCase().trim());
    if (m.find()) {
        String inner = m.group(1);
        Map<String, String> kv = Splitter.on(",").trimResults().withKeyValueSeparator("=").split(inner);
        try {
            Double x = Double.valueOf(kv.get("x"));
            Double y = Double.valueOf(kv.get("y"));
            Double w = Double.valueOf(kv.get("w"));
            Double h = Double.valueOf(kv.get("h"));
            return new Rectangle2D.Double(x, y, w, h);
        } catch (NumberFormatException x) {
            Logger.getLogger(RectAdapter.class.getName()).log(Level.FINEST, "Not a double", x);
            return null;
        }
    } else {
        Logger.getLogger(RectAdapter.class.getName()).log(Level.FINEST, "Not a valid rectangle", v);
        return null;
    }
}

From source file:org.omnaest.utils.beans.replicator.Path.java

/**
 * @see Path/*from   www  .  j ava  2  s.  com*/
 * @param canonicalPath
 */
Path(String canonicalPath) {
    super();
    this.path = ListUtils.valueOf(Splitter.on('.').split(canonicalPath)).toArray(new String[] {});
}

From source file:pl.wavesoftware.wfirma.api.core.mapper.xml.TagsAdapter.java

@Override
@Nonnull/*from   w  w w.  ja  v a  2 s .  c o  m*/
public Collection<String> unmarshal(@Nullable String input) {
    List<String> out = new ArrayList<>();
    if (input != null) {
        String txt = input;
        if (!txt.isEmpty() && txt.startsWith("(") && txt.endsWith(")")) {
            txt = txt.subSequence(1, txt.length() - 1).toString();
        }
        for (String tag : Splitter.on("),(").split(txt)) {
            out.add(tag);
        }
        if (out.size() == 1 && "".equals(out.iterator().next())) {
            out = new ArrayList<>();
        }
    }
    return out;
}