Java 类com.google.common.base.Splitter 实例源码

项目:myth    文件:MongoCoordinatorRepository.java   
/**
 * 生成mongoClientFacotryBean
 *
 * @param mythMongoConfig 配置信息
 * @return bean
 */
private MongoClientFactoryBean buildMongoClientFactoryBean(MythMongoConfig mythMongoConfig) {
    MongoClientFactoryBean clientFactoryBean = new MongoClientFactoryBean();
    MongoCredential credential = MongoCredential.createScramSha1Credential(mythMongoConfig.getMongoUserName(),
            mythMongoConfig.getMongoDbName(),
            mythMongoConfig.getMongoUserPwd().toCharArray());
    clientFactoryBean.setCredentials(new MongoCredential[]{
            credential
    });
    List<String> urls = Splitter.on(",").trimResults().splitToList(mythMongoConfig.getMongoDbUrl());

    final ServerAddress[] sds = urls.stream().map(url -> {
        List<String> adds = Splitter.on(":").trimResults().splitToList(url);
        InetSocketAddress address = new InetSocketAddress(adds.get(0), Integer.parseInt(adds.get(1)));
        return new ServerAddress(address);
    }).collect(Collectors.toList()).toArray(new ServerAddress[]{});

    clientFactoryBean.setReplicaSetSeeds(sds);
    return clientFactoryBean;
}
项目:Equella    文件:HierarchySoapService.java   
@Override
public String getTopic(String uuid)
{
    HierarchyTopic ht = null;
    boolean isDynamicTopic = false;
    for( String uuidValue : Splitter.on(',').omitEmptyStrings().split(uuid) )
    {
        final String[] uv = uuidValue.split(":", 2);
        ht = hierarchyService.getHierarchyTopicByUuid(uv[0]);
        if( uv.length > 1 )
        {
            isDynamicTopic = true;
        }
    }

    PropBagEx xml = new PropBagEx();
    buildXmlFromTopic(xml, ht, isDynamicTopic, uuid);
    return xml.getSubtree("topic").toString();
}
项目:Biliomi    文件:Url.java   
/**
 * Unpack the querystring from the given url
 * Returns an empty map if there is no querystring
 *
 * @param url               The url to parse
 * @param isPureQueryString Supply true if the url is just the query string or false for complete urls
 * @return A Map containing the key-value pairs
 */
public static Map<String, String> unpackQueryString(String url, boolean isPureQueryString) {
  if (url != null) {
    String query = null;

    if (isPureQueryString) {
      query = url;
    } else {
      int qidIndex = url.indexOf(QUERY_IDENTIFIER);
      if (qidIndex > -1) {
        query = url.substring(qidIndex + 1);
      }
    }

    if (query != null) {
      return Splitter
          .on(QUERY_PAIR_SEPARATOR)
          .trimResults()
          .withKeyValueSeparator(QUERY_KEY_VALUE_SEPARATOR)
          .split(query);
    }
  }
  return new HashMap<>();
}
项目:graphiak    文件:GraphiteMetricDecoder.java   
@Nullable
public static GraphiteMetric decode(@Nullable final String metric) {
    if (metric == null || metric.isEmpty()) {
        return null;
    }

    final List<String> parts = Splitter.on(CharMatcher.BREAKING_WHITESPACE)
            .trimResults().omitEmptyStrings().splitToList(metric);
    if (parts.isEmpty() || parts.size() != 3) {
        return null;
    }

    final double value = Double.parseDouble(parts.get(1));
    final long timestamp = Long.parseUnsignedLong(parts.get(2));

    return new GraphiteMetric(parts.get(0), value, timestamp);
}
项目:gitplex-mit    文件:PathAwareUrl.java   
@Override
public String getPath(Charset charset) {
    StringBuilder path = new StringBuilder();
    boolean slash = false;

    for (String segment : getSegments()) {
        if (slash) {
            path.append('/');
        }
        if (segment.indexOf('/') != -1) {
            Url url = new Url(Splitter.on('/').splitToList(segment), Charsets.UTF_8);
            path.append(url.getPath());
        } else {
            path.append(UrlEncoder.PATH_INSTANCE.encode(segment, charset));
        }
        slash = true;
    }
    return path.toString();
}
项目:servicebuilder    文件:ServerLogger.java   
public void handleRequest(LogRequest logRequest, LogParams logParams) {

        List<String> entries = Lists.newArrayList();
        entries.add(logRequest.uri);
        if (logRequest.clientApplication != null) {
            entries.add("Client: " + logRequest.clientApplication);
        }
        if (logRequest.user != null) {
            entries.add("User: " + logRequest.user);
        }
        if (logParams.logHeaders && logRequest.headers != null) {
            entries.add("Headers: " + getHeaders(logRequest.headers, logParams)
            );
        }
        if (logParams.logResponseEntity && ! Strings.isNullOrEmpty(logRequest.entity)) {
            List<String> lines = Splitter.on('\n').splitToList(logRequest.entity)
                    .stream()
                    .map(String::trim)
                    .collect(Collectors.toList());
            String compactedEntity = Joiner.on(' ').join(lines);
            entries.add("Entity: " + compactedEntity);
        }
        String logString = Joiner.on(", ").join(entries);
        LogUtil.doLog(logString, logParams.logLevel, log);
    }
项目:commelina    文件:NioSocketEventHandler.java   
@Override
public CompletableFuture<Long> onLogin(ChannelHandlerContext ctx, SocketASK ask) {
    // 整个消息就是 token
    ByteString tokenArg = ask.getBody().getArgs(0);
    if (tokenArg == null) {
        logger.info("Token arg must be input.");
        return null;
    }
    String token = tokenArg.toStringUtf8();
    if (Strings.isNullOrEmpty(token)) {
        logger.info("Token arg must be input.");
        return null;
    }
    return CompletableFuture.supplyAsync(() -> {
        String parseToken = new String(BaseEncoding.base64Url().decode(token));
        List<String> tokenChars = Splitter.on('|').splitToList(parseToken);

        Long userId = Long.valueOf(tokenArg.toStringUtf8());
        RoomGroup.getRoomManger().onOnline(ctx, userId);
        return userId;
    });
}
项目:commelina    文件:Version.java   
/**
 * 1.0.0 -> 1 00 00
 * 2.3.4 -> 2 03 04
 * 2.3.40 -> 2 03 40
 * 2.4.40 -> 2 04 40
 * 20.3.40 -> 20 03 40
 *
 * @param version
 * @return
 */
public static int create(String version) {
    List<String> items = Splitter.on('.').splitToList(version);
    if (items.size() > 3 || items.size() < 1) {
        throw new RuntimeException("仅支持99.99.99为最大版本号");
    }
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < items.size(); i++) {
        if (items.get(i).length() > 2) {
            throw new RuntimeException("仅支持99.99.99为最大版本号");
        }
        if (i > 0 && items.get(i).length() == 1) {
            buffer.append('0');
        }
        buffer.append(items.get(i));
    }
    return Integer.valueOf(buffer.toString());
}
项目:javaide    文件:XmlAttribute.java   
/**
 * Handles tools: namespace attributes presence in both documents.
 * @param higherPriority the higherPriority attribute
 */
private void handleBothToolsAttributePresent(
        XmlAttribute higherPriority) {

    // do not merge tools:node attributes, the higher priority one wins.
    if (getName().getLocalName().equals(NodeOperationType.NODE_LOCAL_NAME)) {
        return;
    }

    // everything else should be merged, duplicates should be eliminated.
    Splitter splitter = Splitter.on(',');
    ImmutableSet.Builder<String> targetValues = ImmutableSet.builder();
    targetValues.addAll(splitter.split(higherPriority.getValue()));
    targetValues.addAll(splitter.split(getValue()));
    higherPriority.getXml().setValue(Joiner.on(',').join(targetValues.build()));
}
项目:Dalaran    文件:LogUtils.java   
public static void print(Object toJson) {
    if (!ENABLED) return;

    synchronized (sGson) {
        String json = sGson.toJson(toJson);
        Iterable<String> lines = Splitter.on(CharMatcher.anyOf("\r\n")).omitEmptyStrings().split(json);

        int count = 0;
        Log.v(TAG, "┏");
        for (String line : lines) {
            Log.v(TAG, "┃   " + line);

            /**
             * delay the log output to avoid exceeding kernel log buffer size
             */
            if (count++ % 64 == 0) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException ignored) {
                }
            }
        }
        Log.v(TAG, "┗");
    }
}
项目:JAMCore    文件:SceneStatus.java   
public void deseralise(String sceneData) {

    String[] data = sceneData.split(deliminator); //careful for regex

    SceneName = data[0];

    PosX =  Integer.parseInt(data[1]);
    PosY =  Integer.parseInt(data[2]);
     NumOfTimesPlayerHasBeenHere = Integer.parseInt(data[3]);
     currentBackground= data[4];
     DynamicOverlayCSS= data[5];
     StaticOverlayCSS = data[6];
     hasNotBeenCurrentYet=Boolean.parseBoolean(data[7]);

     //add dependantSceneNames!
     String sequence = data[8];
     if (sequence!=null && !sequence.isEmpty()){
     dependantSceneNames = Sets.newHashSet(Splitter.on(',').trimResults().split(sequence)); //convert coma seperated strings to a hashset. Thanks guava!
     }

}
项目:TextHIN    文件:Params.java   
public void read(String path, String prefix) {
  LogInfo.begin_track("Reading parameters from %s", path);
  try {
    BufferedReader in = IOUtils.openIn(path);
    String line;
    while ((line = in.readLine()) != null) {
      String[] pair = Lists.newArrayList(Splitter.on('\t').split(line)).toArray(new String[2]);
      weights.put(pair[0], Double.parseDouble(pair[1]));
      weights.put(prefix + pair[0], Double.parseDouble(pair[1]));
    }
    in.close();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  LogInfo.logs("Read %s weights", weights.size());
  LogInfo.end_track();
}
项目:Equella    文件:LDAP.java   
public Filter getGroupSearchFilter(String query)
{
    SingleFilter groupClass = new SingleFilter(OBJECTCLASS, groupObject);
    groupClass.setLimit(config.getSearchLimit());

    query = checkQuery(query);
    if( isSearchAllQuery(query) )
    {
        return groupClass;
    }

    AndFilter and = new AndFilter(groupClass);
    for( String token : Splitter.onPattern("\\s").omitEmptyStrings().trimResults(CharMatcher.is('*')).split(query) )
    {
        token = (config.isWildcards() ? "*" : "") + token + '*';

        OrFilter or = new OrFilter();
        or.addFilter(new SingleFilter(groupNameField, token, false));
        or.addFilter(new SingleFilter(groupIdField, token, false));

        and.addFilter(or);
    }
    return and;
}
项目:de.flapdoodle.solid    文件:SiteConfigPostProcessor.java   
private PropertyTree process(PropertyTree meta, SiteConfig siteConfig, ImmutableList<Category> categories) {
    Builder builder = FixedPropertyTree.builder()
            .copyOf(meta);

    for (PostProcessing.Category cat : categories) {
        Optional<Tree> tree = siteConfig.tree(cat.tree());
        tree.ifPresent(t -> {
            ImmutableList<String> sourceVal = meta.findList(String.class, Splitter.on(".").split(cat.source()));
            ImmutableSet<String> allParents = t.allParentsOf(sourceVal);
            ImmutableSet<String> allCategories = Sets.union(allParents, Sets.newHashSet(sourceVal)).immutableCopy();
            allCategories.forEach(c -> {
                builder.put(cat.name(), c);
            });
        });
    }

    return builder.build();
}
项目:ProjectAres    文件:GlobalItemParser.java   
public Map<Enchantment, Integer> parseEnchantments(Element el, String name) throws InvalidXMLException {
    Map<Enchantment, Integer> enchantments = Maps.newHashMap();

    Node attr = Node.fromAttr(el, name, StringUtils.pluralize(name));
    if(attr != null) {
        Iterable<String> enchantmentTexts = Splitter.on(";").split(attr.getValue());
        for(String enchantmentText : enchantmentTexts) {
            int level = 1;
            List<String> parts = Lists.newArrayList(Splitter.on(":").limit(2).split(enchantmentText));
            Enchantment enchant = XMLUtils.parseEnchantment(attr, parts.get(0));
            if(parts.size() > 1) {
                level = XMLUtils.parseNumber(attr, parts.get(1), Integer.class);
            }
            enchantments.put(enchant, level);
        }
    }

    for(Element elEnchantment : el.getChildren(name)) {
        Pair<Enchantment, Integer> entry = parseEnchantment(elEnchantment);
        enchantments.put(entry.first, entry.second);
    }

    return enchantments;
}
项目:happylifeplat-tcc    文件:MongoCoordinatorRepository.java   
/**
 * 生成mongoClientFacotryBean
 *
 * @param tccMongoConfig 配置信息
 * @return bean
 */
private MongoClientFactoryBean buildMongoClientFactoryBean(TccMongoConfig tccMongoConfig) {
    MongoClientFactoryBean clientFactoryBean = new MongoClientFactoryBean();
    MongoCredential credential = MongoCredential.createScramSha1Credential(tccMongoConfig.getMongoUserName(),
            tccMongoConfig.getMongoDbName(),
            tccMongoConfig.getMongoUserPwd().toCharArray());
    clientFactoryBean.setCredentials(new MongoCredential[]{
            credential
    });
    List<String> urls = Splitter.on(",").trimResults().splitToList(tccMongoConfig.getMongoDbUrl());
    ServerAddress[] sds = new ServerAddress[urls.size()];
    for (int i = 0; i < sds.length; i++) {
        List<String> adds = Splitter.on(":").trimResults().splitToList(urls.get(i));
        InetSocketAddress address = new InetSocketAddress(adds.get(0), Integer.parseInt(adds.get(1)));
        sds[i] = new ServerAddress(address);
    }
    clientFactoryBean.setReplicaSetSeeds(sds);
    return clientFactoryBean;
}
项目:circus-train    文件:MoreMapUtils.java   
private static <T> List<T> getList(
    Map<?, ?> map,
    Object key,
    List<T> defaultValue,
    Function<Object, T> transformation) {
  Object value = map.get(key);
  if (value == null) {
    return defaultValue;
  }

  if (value instanceof String) {
    value = Splitter.on(',').splitToList(value.toString());
  }

  if (!(value instanceof Collection)) {
    return Collections.singletonList(transformation.apply(value));
  }

  return FluentIterable.from((Collection<?>) value).transform(transformation).toList();
}
项目:fpm    文件:Geonames.java   
private static TreeMultimap<Integer, AlternateName> alternateNames(String path) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    TreeMultimap<Integer, AlternateName> multimap = TreeMultimap.create();
    try (BufferedReader br = new BufferedReader(new FileReader(path))) {
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            List<String> list = Splitter.on('\t').splitToList(line);
            if ("fr".equals(list.get(2))) {
                AlternateName name = new AlternateName(list.get(3), "1".equals(list.get(4)), "1".equals(list.get(5)), "1".equals(list.get(6)), "1".equals(list.get(7)));
                multimap.put(parseInt(list.get(1)), name);
            }
        }
    }
    catch (IOException e) {
        throw propagate(e);
    }
    log.info("Alternate names loaded: {}s", stopwatch.elapsed(SECONDS));
    return multimap;
}
项目:CustomWorldGen    文件:GradleForgeHacks.java   
private void readCsv(File file, Map<String, String> map) throws IOException
{
    GradleStartCommon.LOGGER.log(Level.DEBUG, "Reading CSV file: {}", file);
    Splitter split = Splitter.on(',').trimResults().limit(3);
    for (String line : Files.readLines(file, Charsets.UTF_8))
    {
        if (line.startsWith("searge")) // header line
            continue;

        List<String> splits = split.splitToList(line);
        map.put(splits.get(0), splits.get(1));
    }
}
项目:X-mall    文件:CartServiceImpl.java   
@Override
public ServerResponse<CartVo> deleteProduct(Integer userId, String productIds) {
    List<String> productList = Splitter.on(",").splitToList(productIds);
    if (CollectionUtils.isEmpty(productList)) {
        return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
    }
    cartMapper.deleteByUserIdProductIds(userId, productList);
    return this.list(userId);
}
项目:CurseSync    文件:CurseSync.java   
public int projectId()
{
    if (projectSlug == null)
        return 0;
    List<String> slugParts = Splitter.on('-').limit(2).splitToList(projectSlug);
    return Integer.parseInt(slugParts.get(0));
}
项目:OneClient    文件:ForgeVersionProfile.java   
public String getURL() {
    if (url == null) {
        url = Constants.LIBRARIES_BASE;
    }
    String[] pts = Iterables.toArray(Splitter.on(':').split(name), String.class);
    String domain = pts[0];
    String libNamename = pts[1];

    int last = pts.length - 1;
    int idx = pts[last].indexOf('@');
    if (idx != -1) {
        pts[last] = pts[last].substring(0, idx);
    }

    String version = pts[2];
    String classifier = null;
    String ext = "jar";
    if (pts.length > 3) {
        classifier = pts[3];
    }
    if (domain.equals("net.minecraftforge") && libNamename.equals("forge")) {
        classifier = "universal";
    }

    String file = libNamename + '-' + version;
    if (classifier != null)
        file += '-' + classifier;
    file += '.' + ext;

    String path = domain.replace('.', '/') + '/' + libNamename + '/' + version + '/' + file;
    return url + path;
}
项目:Equella    文件:TopicDisplaySection.java   
public void ensureParsed()
{
    if( topic != null || Check.isEmpty(topicId) || ROOT_TOPICS.equals(topicId) )
    {
        return;
    }

    for( String uuidValue : Splitter.on(',').omitEmptyStrings().split(topicId) )
    {
        final String[] uv = uuidValue.split(":", 2);

        // First UUID is the topic to view
        if( topic == null )
        {
            topic = hierarchyService.getHierarchyTopicByUuid(uv[0]);
            topicValue = uv.length > 1 ? URLUtils.basicUrlDecode(uv[1]) : null;
            if( topic == null )
            {
                throw new IllegalArgumentException("Could not find topic " + uv[0]);
            }
        }

        if( uv.length > 1 )
        {
            if( values == null )
            {
                values = Maps.newHashMap();
            }
            values.put(uv[0], URLUtils.basicUrlDecode(uv[1]));
        }
    }
}
项目:Backmemed    文件:GuiMultiplayer.java   
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    this.hoveringText = null;
    this.drawDefaultBackground();
    this.serverListSelector.drawScreen(mouseX, mouseY, partialTicks);
    this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.title", new Object[0]), this.width / 2, 20, 16777215);
    super.drawScreen(mouseX, mouseY, partialTicks);

    if (this.hoveringText != null)
    {
        this.drawHoveringText(Lists.newArrayList(Splitter.on("\n").split(this.hoveringText)), mouseX, mouseY);
    }
}
项目:ts-cards    文件:GetApplicationIds.java   
public List<String> getApplicationIds() {
    if (!isDone()) {
        return Collections.EMPTY_LIST;
    } else {
        Optional<ApduSessionParameter> aids = getSession().getParameter(
                AIDS_KEY + "_" + getIndex());
        if (!aids.isPresent()) {
            return Collections.EMPTY_LIST;
        } else {
            Iterable<String> aidIterable = Splitter.on(';')
                    .split(aids.get().getValue());
            return Lists.newArrayList(aidIterable);
        }
    }
}
项目:ArchUnit    文件:ArchConfiguration.java   
private void set(Properties properties) {
    resolveMissingDependenciesFromClassPath = Boolean.valueOf(
            propertyOrDefault(properties, RESOLVE_MISSING_DEPENDENCIES_FROM_CLASS_PATH));
    classResolver = Optional.fromNullable(properties.getProperty(CLASS_RESOLVER));
    classResolverArguments = Splitter.on(",").trimResults().omitEmptyStrings()
            .splitToList(properties.getProperty(CLASS_RESOLVER_ARGS, ""));
    enableMd5InClassSources = Boolean.valueOf(
            propertyOrDefault(properties, ENABLE_MD5_IN_CLASS_SOURCES));

    parseExtensionProperties(properties);
}
项目:satisfy    文件:SatisfyProperties.java   
public List<String> getMetaFilters() {
    String metaFilters = EMPTY;
    if(isDefined(METAFILTER)) {
        metaFilters = getProperty(METAFILTER);
    }
    return Lists.newArrayList(Splitter.on(Pattern.compile(","))
            .trimResults().omitEmptyStrings().split(metaFilters));
}
项目:kafka-visualizer    文件:RestResource.java   
private ImmutableMap<String, String> parseUrlEncodedParams(String input) throws UnsupportedEncodingException {
    input = URLDecoder.decode(input, "utf8");
    if (input.startsWith("?")) {
        input = input.substring(1);
    }

    return ImmutableMap.copyOf(Splitter.on("&").withKeyValueSeparator("=").split(input));
}
项目:n4js    文件:NodeEngineCommandBuilder.java   
/**
 * Creates commands for calling Node.js on command line. Data wrapped in passed parameter is used to configure node
 * itself, and to generate file that will be executed by Node.
 */
public String[] createCmds(NodeRunOptions nodeRunOptions) throws IOException {

    final ArrayList<String> commands = new ArrayList<>();

    commands.add(nodeJsBinary.get().getBinaryAbsolutePath());

    // allow user flags
    final String nodeOptions = nodeRunOptions.getEngineOptions();
    if (nodeOptions != null) {
        for (String nodeOption : Splitter.on(BREAKING_WHITESPACE).omitEmptyStrings().split(nodeOptions)) {
            commands.add(nodeOption);
        }
    }

    final StringBuilder elfData = getELFCode(nodeRunOptions.getInitModules(),
            nodeRunOptions.getExecModule(), nodeRunOptions.getExecutionData());

    final File elf = createTempFileFor(elfData.toString());

    commands.add(elf.getCanonicalPath());

    if (nodeRunOptions.getSystemLoader() == SystemLoaderInfo.COMMON_JS) {
        commands.add(CJS_COMMAND);
    }

    return commands.toArray(new String[] {});
}
项目:googles-monorepo-demo    文件:FreshValueGeneratorTest.java   
@AndroidIncompatible // problem with equality of Type objects?
public void testFreshInstance() {
  assertFreshInstances(
      String.class, CharSequence.class,
      Appendable.class, StringBuffer.class, StringBuilder.class,
      Pattern.class, MatchResult.class,
      Number.class, int.class, Integer.class,
      long.class, Long.class,
      short.class, Short.class,
      byte.class, Byte.class,
      boolean.class, Boolean.class,
      char.class, Character.class,
      int[].class, Object[].class,
      UnsignedInteger.class, UnsignedLong.class,
      BigInteger.class, BigDecimal.class,
      Throwable.class, Error.class, Exception.class, RuntimeException.class,
      Charset.class, Locale.class, Currency.class,
      List.class, Map.Entry.class,
      Object.class,
      Equivalence.class, Predicate.class, Function.class,
      Comparable.class, Comparator.class, Ordering.class,
      Class.class, Type.class, TypeToken.class,
      TimeUnit.class, Ticker.class,
      Joiner.class, Splitter.class, CharMatcher.class,
      InputStream.class, ByteArrayInputStream.class,
      Reader.class, Readable.class, StringReader.class,
      OutputStream.class, ByteArrayOutputStream.class,
      Writer.class, StringWriter.class, File.class,
      Buffer.class, ByteBuffer.class, CharBuffer.class,
      ShortBuffer.class, IntBuffer.class, LongBuffer.class,
      FloatBuffer.class, DoubleBuffer.class,
      String[].class, Object[].class, int[].class);
}
项目:Warzone    文件:SimpleScoreboard.java   
private void applyText(Team team, String text, OfflinePlayer result) {
    Iterator<String> iterator = Splitter.fixedLength(16).split(text).iterator();
    String prefix = iterator.next();

    team.setPrefix(prefix);

    if (!team.hasEntry(result.getName()))
        team.addEntry(result.getName());

    if (text.length() > 16) {
        String prefixColor = ChatColor.getLastColors(prefix);
        String suffix = iterator.next();

        //TODO Change to the symbols

        if (prefix.endsWith("nn")) {
            prefix = prefix.substring(0, prefix.length() - 1);
            team.setPrefix(prefix);
            prefixColor = ChatColor.getByChar(suffix.charAt(0)).toString();
            suffix = suffix.substring(1);
        }

        if (prefixColor == null)
            prefixColor = "";

        if (suffix.length() > 16) {
            suffix = suffix.substring(0, (13 - prefixColor.length())); // cut off suffix, done if text is over 30 characters
        }

        team.setSuffix((prefixColor.equals("") ? ChatColor.RESET : prefixColor) + suffix);
    }
}
项目:travny    文件:SchemaNameUtils.java   
public static String getName(String name) {
    if (!name.contains(".")) {
        return name;
    } else {
        List<String> parts = Splitter.on('.').splitToList(name);
        return parts.get(parts.size() - 1);
    }
}
项目:helper    文件:BungeeMessaging.java   
@Override
public boolean accept(Player receiver, ByteArrayDataInput in) {
    in.readUTF();
    String csv = in.readUTF();

    if (csv.isEmpty()) {
        callback.accept(ImmutableList.of());
        return true;
    }

    callback.accept(ImmutableList.copyOf(Splitter.on(", ").splitToList(csv)));
    return true;
}
项目:helper    文件:BungeeMessaging.java   
@Override
public boolean accept(Player receiver, ByteArrayDataInput in) {
    String csv = in.readUTF();

    if (csv.isEmpty()) {
        callback.accept(ImmutableList.of());
        return true;
    }

    callback.accept(ImmutableList.copyOf(Splitter.on(", ").splitToList(csv)));
    return true;
}
项目:helper    文件:FunctionalCommandBuilderImpl.java   
@Override
public FunctionalCommandBuilder<T> assertUsage(String usage, String failureMessage) {
    Preconditions.checkNotNull(usage, "usage");
    Preconditions.checkNotNull(failureMessage, "failureMessage");

    List<String> usageParts = Splitter.on(" ").splitToList(usage);

    int requiredArgs = 0;
    for (String usagePart : usageParts) {
        if (!usagePart.startsWith("[") && !usagePart.endsWith("]")) {
            // assume it's a required argument
            requiredArgs++;
        }
    }

    int finalRequiredArgs = requiredArgs;
    predicates.add(context -> {
        if (context.args().size() >= finalRequiredArgs) {
            return true;
        }

        context.reply(failureMessage.replace("{usage}", "/" + context.label() + " " + usage));
        return false;
    });

    return this;
}
项目:Re-Collector    文件:OutputConfiguration.java   
public OutputConfiguration(String id, Config config) {
    this.id = id;

    if (config.hasPath("inputs")) {
        this.inputs = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(config.getString("inputs")));
    }
}
项目:Re-Collector    文件:InputConfiguration.java   
public InputConfiguration(String id, Config config) {
    this.id = id;

    if (config.hasPath("outputs")) {
        this.outputs = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(config.getString("outputs")));
    }

    if (config.hasPath("message-fields")) {
        final Config messageFieldsConfig = config.getConfig("message-fields");

        for (Map.Entry<String, ConfigValue> entry : messageFieldsConfig.entrySet()) {
            final String key = entry.getKey();
            final ConfigValue value = entry.getValue();

            switch (value.valueType()) {
                case NUMBER:
                    this.messageFields.put(key, messageFieldsConfig.getNumber(key));
                    break;
                case BOOLEAN:
                    this.messageFields.put(key, messageFieldsConfig.getBoolean(key));
                    break;
                case STRING:
                    this.messageFields.put(key, messageFieldsConfig.getString(key));
                    break;
                default:
                    log.warn("{}[{}] Message field value of type \"{}\" is not supported for key \"{}\" (value: {})",
                            getClass().getSimpleName(), getId(), value.valueType(), key, value.toString());
                    break;
            }
        }
    }
}
项目:vogar    文件:Run.java   
/**
 * Returns a parsed list of the --invoke-with command and its
 * arguments, or an empty list if no --invoke-with was provided.
 */
public Iterable<String> invokeWith() {
    if (invokeWith == null) {
        return Collections.emptyList();
    }
    return Splitter.onPattern("\\s+").omitEmptyStrings().split(invokeWith);
}
项目:uavstack    文件:DoTestRuleFilterFactory.java   
public Map<String, String> doAnalysis(String log) {

        Map<String, String> result = new HashMap<String, String>();
        String temp3area = log.substring(15).trim();
        Splitter s = Splitter.onPattern("\\p{Space}").trimResults();
        List<String> it = Lists.newArrayList(s.limit(3).split(temp3area));
        result.put("date", log.substring(0, 15));
        result.put("host", it.get(0));
        result.put("pid", it.get(1));
        result.put("message", it.get(2));
        return result;
    }
项目:jsinterop-generator    文件:GeneratorUtils.java   
public static String createJavaPackage(String nativeNamespace, String packagePrefix) {
  String cleanedTsNamespace = maybeRemoveClutzNamespace(nativeNamespace);

  // ensure all package are in lower case to avoid clash with type name
  cleanedTsNamespace =
      Joiner.on('.')
          .join(transform(Splitter.on('.').split(cleanedTsNamespace), String::toLowerCase));

  return maybeAppendPrefix(packagePrefix, cleanedTsNamespace);
}