public static String dirnameToValueString(String name) { try { return URLDecoder.decode( Iterables.getLast(PART_SEP.split(name)), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new AssertionError("Unable to find UTF-8 encoding."); } } }
@VisibleForTesting public static String[] parseHostsAndPort(String zkQuorum) { List<String> hosts = Lists.newArrayList(); String port = null; for (String hostPort : Splitter.on(',').split(zkQuorum)) { Iterator<String> split = Splitter.on(':').split(hostPort).iterator(); hosts.add(split.next()); if (split.hasNext()) { String p = split.next(); if (port == null) { port = p; } else if (!port.equals(p)) { throw new IllegalArgumentException("Mismatched ports in " + zkQuorum); } } } return new String[] { Joiner.on(',').join(hosts), port }; } }
private static Format formatFromExt(Path path) { String filename = path.getName(); String ext = Iterables.getLast(DOT.split(filename)); for (Format format : SUPPORTED_FORMATS) { if (ext.equals(format.getExtension())) { return format; } } return null; }
@VisibleForTesting public static String[] parseHostsAndPort(String zkQuorum) { List<String> hosts = Lists.newArrayList(); String port = null; for (String hostPort : Splitter.on(',').split(zkQuorum)) { Iterator<String> split = Splitter.on(':').split(hostPort).iterator(); hosts.add(split.next()); if (split.hasNext()) { String p = split.next(); if (port == null) { port = p; } else if (!port.equals(p)) { throw new IllegalArgumentException("Mismatched ports in " + zkQuorum); } } } return new String[] { Joiner.on(',').join(hosts), port }; } }
private static String constructPath(Map<String, String> match, String pattern) { LinkedList<String> patternParts = Lists.newLinkedList( PATH_SPLITTER.split(pattern)); List<String> pathParts = Lists .newArrayListWithExpectedSize(patternParts.size()); for (String part : patternParts) { if (!part.isEmpty()) { // only supports simple matches, like matching if (VAR_START.matches(part.charAt(0))) { String name = part.substring(1); if (match.containsKey(name)) { pathParts.add(match.remove(name)); } else if (!part.startsWith("*")) { // required variable is missing throw new IllegalArgumentException( "Missing required option: " + name); } } else { // it is a required URI part pathParts.add(part); } } else { // preserve additional slashes in paths pathParts.add(part); } } return PATH_JOINER.join(pathParts); }
List<String> parts = Lists.newArrayList(EQUALS.split(path.getName())); String name; String value;
public URIPattern(URI uri) { this.pattern = uri; Map<String, String> accumulator = Maps.newHashMap(); if (pattern.isOpaque()) { Iterator<String> pathQuery = PATH_QUERY_SPLITTER .split(pattern.getSchemeSpecificPart()).iterator(); this.patternPath = Iterators.getNext(pathQuery, null); addQuery(Iterators.getNext(pathQuery, null), accumulator); } else { patternPath = pattern.getRawPath(); addQuery(pattern.getRawQuery(), accumulator); addAuthority(pattern, accumulator); } if (pattern.getScheme() != null) { accumulator.put(SCHEME, pattern.getScheme()); } this.defaults = ImmutableMap.copyOf(accumulator); }
fields = Lists.newArrayList(); Schema nested = schema; for (String level : SchemaUtil.NAME_SPLITTER.split(name)) {
.split(uri.getRawSchemeSpecificPart()).iterator();
Iterator<String> values = VALUE_SPLITTER.split(value).iterator(); if (values.hasNext()) { family = values.next();
/** * Returns the nested {@link Schema} for the given field name. * * @param schema a record Schema * @param name a String field name * @return the nested Schema for the field */ public static Schema fieldSchema(Schema schema, String name) { Schema nested = unwrapNullable(schema); List<String> levels = Lists.newArrayList(); for (String level : NAME_SPLITTER.split(name)) { levels.add(level); ValidationException.check(Schema.Type.RECORD == schema.getType(), "Cannot get schema for %s: %s is not a record schema: %s", name, NAME_JOINER.join(levels), nested.toString(true)); Schema.Field field = nested.getField(level); ValidationException.check(field != null, "Cannot get schema for %s: %s is not a field", name, NAME_JOINER.join(levels)); nested = unwrapNullable(field.schema()); } return nested; }
Iterator<String> parts = PATH_SPLITTER.split(relative.getRawPath()).iterator(); for (FieldPartitioner<?, ?> fp : Accessor.getDefault().getFieldPartitioners(strategy)) { if (!parts.hasNext()) {
properties.get(OLD_CUSTOM_PROPERTIES_PROPERTY_NAME)); if (namesProperty != null) { for (String property : NAME_SPLITTER.split(namesProperty)) { builder.property(property, properties.get(property));
properties.get(OLD_CUSTOM_PROPERTIES_PROPERTY_NAME)); if (namesProperty != null) { for (String property : NAME_SPLITTER.split(namesProperty)) { builder.property(property, properties.get(property));