Search in sources :

Example 51 with Splitter

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());
}
Also used : Splitter(com.google.common.base.Splitter)

Example 52 with Splitter

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();
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Splitter(com.google.common.base.Splitter) Request(okhttp3.Request) BufferedReader(java.io.BufferedReader) Iterator(java.util.Iterator) SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) UnknownHostException(java.net.UnknownHostException)

Example 53 with Splitter

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;
}
Also used : Path(java.nio.file.Path) Splitter(com.google.common.base.Splitter)

Example 54 with Splitter

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;
}
Also used : Splitter(com.google.common.base.Splitter) ArrayList(java.util.ArrayList) Preferences(java.util.prefs.Preferences) NotNull(org.jetbrains.annotations.NotNull)

Example 55 with Splitter

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) {
    }
}
Also used : Splitter(com.google.common.base.Splitter) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Splitter (com.google.common.base.Splitter)94 ArrayList (java.util.ArrayList)20 IOException (java.io.IOException)12 HashSet (java.util.HashSet)10 HashMap (java.util.HashMap)8 File (java.io.File)7 Test (org.junit.Test)7 BufferedReader (java.io.BufferedReader)5 ToString (lombok.ToString)4 NonNull (com.android.annotations.NonNull)3 InputStreamReader (java.io.InputStreamReader)3 URL (java.net.URL)3 ItemStack (net.minecraft.item.ItemStack)3 StringColumn (tech.tablesaw.api.StringColumn)3 Histogram (zemberek.core.collections.Histogram)3 WordAnalysis (zemberek.morphology.analysis.WordAnalysis)3 CharMatcher (com.google.common.base.CharMatcher)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 CharSource (com.google.common.io.CharSource)2