use of com.google.common.base.Splitter in project jackrabbit-oak by apache.
the class SimpleExcerptProvider method getExcerpt.
public static PropertyValue getExcerpt(PropertyValue value) {
Splitter listSplitter = Splitter.on(',').trimResults().omitEmptyStrings();
StringBuilder excerpt = new StringBuilder(EXCERPT_BEGIN);
for (String v : listSplitter.splitToList(value.toString())) {
excerpt.append(v);
}
excerpt.append(EXCERPT_END);
return PropertyValues.newString(excerpt.toString());
}
use of com.google.common.base.Splitter in project bitcoin-wallet by bitcoin-wallet.
the class AlertDialogsFragment method onActivityCreated.
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
log.debug("querying \"{}\"...", versionUrl);
final Request.Builder request = new Request.Builder();
request.url(versionUrl);
request.header("Accept-Charset", "utf-8");
final String userAgent = application.httpUserAgent();
if (userAgent != null)
request.header("User-Agent", userAgent);
final Call call = Constants.HTTP_CLIENT.newCall(request.build());
backgroundHandler.post(new Runnable() {
@Override
public void run() {
boolean abort = false;
try {
final Response response = call.execute();
if (response.isSuccessful()) {
final long serverTime = response.headers().getDate("Date").getTime();
try (final BufferedReader reader = new BufferedReader(response.body().charStream())) {
abort = handleServerTime(serverTime);
while (true) {
final String line = reader.readLine();
if (line == null)
break;
if (line.charAt(0) == '#')
continue;
final Splitter splitter = Splitter.on('=').trimResults();
final Iterator<String> split = splitter.split(line).iterator();
if (!split.hasNext())
continue;
final String key = split.next();
if (!split.hasNext()) {
abort = handleLine(key);
if (abort)
break;
continue;
}
final String value = split.next();
if (!split.hasNext()) {
abort = handleProperty(key, value);
if (abort)
break;
continue;
}
log.info("Ignoring line: {}", line);
}
}
}
} catch (final Exception x) {
handleException(x);
}
if (!abort)
handleCatchAll();
}
});
}
use of com.google.common.base.Splitter in project raml-for-jax-rs by mulesoft-labs.
the class Utilities method transformIntoPath.
private static Path transformIntoPath(Class<?> clazz) {
Splitter splitter = Splitter.on('.').omitEmptyStrings();
Iterable<String> subPackages = splitter.split(clazz.getPackage().getName());
Path current = Paths.get("");
for (String subPackage : subPackages) {
current = current.resolve(subPackage);
}
return current;
}
use of com.google.common.base.Splitter in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleLoginPrefs method getStoredUsers.
/**
* Retrieves the persistently stored list of users.
*
* @return the stored list of users.
*/
@NotNull
public static List<String> getStoredUsers() {
Preferences prefs = getPrefs();
String allUsersString = prefs.get(USERS, "");
List<String> allUsers = new ArrayList<String>();
if (allUsersString.isEmpty()) {
return allUsers;
}
Splitter splitter = Splitter.on(DELIMITER).omitEmptyStrings();
for (String user : splitter.split(allUsersString)) {
allUsers.add(user);
}
return allUsers;
}
use of com.google.common.base.Splitter in project BuildCraft by BuildCraft.
the class IMCHandlerTransport method processAddFacadeIMC.
public static void processAddFacadeIMC(IMCEvent event, IMCMessage m) {
try {
if (m.isStringMessage()) {
Splitter splitter = Splitter.on("@").trimResults();
String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
if (array.length <= 0 || array.length >= 3) {
BCLog.logger.info(String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
} else {
String blockName = array[0];
Integer metaId = array.length == 1 ? -1 : Ints.tryParse(array[1]);
if (Strings.isNullOrEmpty(blockName) || metaId == null) {
BCLog.logger.info(String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
} else {
Block block = Block.blockRegistry.getObject(new ResourceLocation(blockName));
if (metaId < 0) {
ItemFacade.whitelistFacade(block);
} else {
ItemFacade.whitelistFacade(block.getStateFromMeta(metaId));
}
}
}
} else if (m.isItemStackMessage()) {
ItemStack modItemStack = m.getItemStackValue();
Block block = Block.getBlockFromItem(modItemStack.getItem());
if (block != null) {
if (modItemStack.getItemDamage() < 0) {
ItemFacade.whitelistFacade(block);
} else {
ItemFacade.whitelistFacade(block.getStateFromMeta(modItemStack.getItemDamage()));
}
}
}
} catch (Exception ex) {
}
}
Aggregations