List of usage examples for com.google.common.base Splitter on
@CheckReturnValue @GwtIncompatible("java.util.regex") public static Splitter on(final Pattern separatorPattern)
From source file:org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndName.java
public static ZoneAndName fromSlashEncoded(String name) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); checkArgument(Iterables.size(parts) == 2, "name must be in format zoneId/name"); return new ZoneAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:com.github.tomakehurst.wiremock.extension.responsetemplating.UrlPath.java
public UrlPath(String url) { originalPath = URI.create(url).getPath(); Iterable<String> pathNodes = Splitter.on('/').split(originalPath); for (String pathNode : pathNodes) { if (StringUtils.isNotEmpty(pathNode)) { add(pathNode);//w w w. ja v a 2 s .co m } } }
From source file:com.google.javascript.jscomp.newtypes.QualifiedName.java
public static QualifiedName fromQualifiedString(String qname) { return qname.contains(".") ? new QualifiedName(ImmutableList.copyOf(Splitter.on('.').split(qname))) : new QualifiedName(qname); }
From source file:com.zimbra.cs.mailbox.util.TagUtil.java
@Deprecated public static String[] tagIdStringToNames(Mailbox mbox, OperationContext octxt, String tagIdString) throws ServiceException { if (Strings.isNullOrEmpty(tagIdString)) { return NO_TAGS; }/*ww w . ja va 2 s . co m*/ List<String> tags = Lists.newArrayList(); for (String tagId : Splitter.on(',').omitEmptyStrings().trimResults().split(tagIdString)) { try { tags.add(mbox.getTagById(octxt, Integer.parseInt(tagId)).getName()); } catch (NumberFormatException nfe) { throw ServiceException.INVALID_REQUEST("invalid tag ID string: " + tagIdString, nfe); } } return tags.toArray(new String[tags.size()]); }
From source file:org.apache.blur.spark.util.JavaSparkUtil.java
public static void packProjectJars(SparkConf conf) throws IOException { String classPath = System.getProperty(JAVA_CLASS_PATH); String pathSeparator = System.getProperty(PATH_SEPARATOR); Splitter splitter = Splitter.on(pathSeparator); Iterable<String> split = splitter.split(classPath); List<String> list = toList(split); List<String> classPathThatNeedsToBeIncluded = removeSparkLibs(list); List<String> jars = new ArrayList<String>(); for (String s : classPathThatNeedsToBeIncluded) { if (isJarFile(s)) { jars.add(s);/*w w w . j a v a 2 s . c o m*/ } else { jars.add(createJar(s)); } } conf.setJars(jars.toArray(new String[jars.size()])); }
From source file:com.facebook.buck.ide.intellij.IjProjectBuckConfig.java
public static IjProjectConfig create(BuckConfig buckConfig, @Nullable AggregationMode aggregationMode, @Nullable String generatedFilesListFilename, boolean isCleanerEnabled, boolean removeUnusedLibraries, boolean excludeArtifacts) { Optional<String> excludedResourcePathsOption = buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "excluded_resource_paths"); Iterable<String> excludedResourcePaths; if (excludedResourcePathsOption.isPresent()) { excludedResourcePaths = Sets.newHashSet( Splitter.on(',').omitEmptyStrings().trimResults().split(excludedResourcePathsOption.get())); } else {/*from w w w. ja va 2 s . c o m*/ excludedResourcePaths = Collections.emptyList(); } Optional<String> generatedSourcesMap = buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "generated_srcs_map"); Map<String, String> depToGeneratedSourcesMap = generatedSourcesMap .map(value -> Splitter.on(',').omitEmptyStrings().trimResults() .withKeyValueSeparator(Splitter.on("=>").trimResults()).split(value)) .orElse(Collections.emptyMap()); Optional<String> generatedSourcesLabelMap = buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "generated_sources_label_map"); Map<String, String> labelToGeneratedSourcesMap = generatedSourcesLabelMap .map(value -> Splitter.on(',').omitEmptyStrings().trimResults() .withKeyValueSeparator(Splitter.on("=>").trimResults()).split(value)) .orElse(Collections.emptyMap()); Optional<Path> androidManifest = buckConfig.getPath(INTELLIJ_BUCK_CONFIG_SECTION, "default_android_manifest_path", false); return IjProjectConfig.builder() .setAutogenerateAndroidFacetSourcesEnabled(!buckConfig.getBooleanValue(PROJECT_BUCK_CONFIG_SECTION, "disable_r_java_idea_generator", false)) .setJavaBuckConfig(buckConfig.getView(JavaBuckConfig.class)).setBuckConfig(buckConfig) .setProjectJdkName(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "jdk_name")) .setProjectJdkType(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "jdk_type")) .setAndroidModuleSdkName( buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "android_module_sdk_name")) .setAndroidModuleSdkType( buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "android_module_sdk_type")) .setIntellijModuleSdkName( buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "intellij_module_sdk_name")) .setIntellijPluginLabels( buckConfig.getListWithoutComments(INTELLIJ_BUCK_CONFIG_SECTION, "intellij_plugin_labels")) .setJavaModuleSdkName(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "java_module_sdk_name")) .setJavaModuleSdkType(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "java_module_sdk_type")) .setProjectLanguageLevel(buckConfig.getValue(INTELLIJ_BUCK_CONFIG_SECTION, "language_level")) .setExcludedResourcePaths(excludedResourcePaths) .setDepToGeneratedSourcesMap(depToGeneratedSourcesMap) .setLabelToGeneratedSourcesMap(labelToGeneratedSourcesMap).setAndroidManifest(androidManifest) .setCleanerEnabled(isCleanerEnabled) .setRemovingUnusedLibrariesEnabled( isRemovingUnusedLibrariesEnabled(removeUnusedLibraries, buckConfig)) .setExcludeArtifactsEnabled(isExcludingArtifactsEnabled(excludeArtifacts, buckConfig)) .setAggregationMode(getAggregationMode(aggregationMode, buckConfig)) .setGeneratedFilesListFilename(Optional.ofNullable(generatedFilesListFilename)) .setIgnoredTargetLabels( buckConfig.getListWithoutComments(INTELLIJ_BUCK_CONFIG_SECTION, "ignored_target_labels")) .build(); }
From source file:google.registry.model.common.GaeUserIdConverter.java
/** * Converts an email address to a GAE user id. * * @return Numeric GAE user id (in String form), or null if email address has no GAE id *///from www . jav a 2 s . c o m public static String convertEmailAddressToGaeUserId(String emailAddress) { final GaeUserIdConverter gaeUserIdConverter = new GaeUserIdConverter(); gaeUserIdConverter.id = allocateId(); gaeUserIdConverter.user = new User(emailAddress, Splitter.on('@').splitToList(emailAddress).get(1)); try { // Perform these operations in a transactionless context to avoid enlisting in some outer // transaction (if any). ofy().doTransactionless(new VoidWork() { @Override public void vrun() { ofy().saveWithoutBackup().entity(gaeUserIdConverter).now(); } }); // The read must be done in its own transaction to avoid reading from the session cache. return ofy().transactNew(new Work<String>() { @Override public String run() { return ofy().load().entity(gaeUserIdConverter).safe().user.getUserId(); } }); } finally { ofy().doTransactionless(new VoidWork() { @Override public void vrun() { ofy().deleteWithoutBackup().entity(gaeUserIdConverter).now(); } }); } }
From source file:com.intellij.util.UriUtil.java
/** * Splits the url into 2 parts: the scheme ("http", for instance) and the rest of the URL. <br/> * Scheme separator is not included neither to the scheme part, nor to the url part. <br/> * The scheme can be absent, in which case empty string is written to the first item of the Pair. *//*from w w w . java 2 s .c o m*/ @NotNull public static Couple<String> splitScheme(@NotNull String url) { ArrayList<String> list = Lists.newArrayList(Splitter.on(URLUtil.SCHEME_SEPARATOR).limit(2).split(url)); if (list.size() == 1) { return Couple.of("", list.get(0)); } return Couple.of(list.get(0), list.get(1)); }
From source file:org.openehr.designer.io.TemplateDeserializer.java
public static List<Archetype> deserialize(String adltContent) { Iterable<String> adls = Splitter.on(Pattern.compile("(\r|\n)+ *\\-{2,} *(\r|\n)+")).split(adltContent); List<Archetype> result = new ArrayList<>(); AdlDeserializer deserializer = new AdlDeserializer(); for (String adl : adls) { result.add(deserializer.parse(adl)); }/* ww w . ja v a 2s. c o m*/ return result; }
From source file:org.apache.james.jmap.model.MessageId.java
@JsonCreator public static MessageId of(String id) { Triplet<String, String, String> parts = Triplet.fromIterable(Splitter.on(SEPARATOR).split(id)); return new MessageId(parts.getValue0(), parts.getValue1(), Long.valueOf(parts.getValue2())); }