当前位置: 首页>>代码示例>>Java>>正文


Java Splitter类代码示例

本文整理汇总了Java中com.google.common.base.Splitter的典型用法代码示例。如果您正苦于以下问题:Java Splitter类的具体用法?Java Splitter怎么用?Java Splitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Splitter类属于com.google.common.base包,在下文中一共展示了Splitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildMongoClientFactoryBean

import com.google.common.base.Splitter; //导入依赖的package包/类
/**
 * 生成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;
}
 
开发者ID:yu199195,项目名称:myth,代码行数:26,代码来源:MongoCoordinatorRepository.java

示例2: getTopic

import com.google.common.base.Splitter; //导入依赖的package包/类
@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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:HierarchySoapService.java

示例3: unpackQueryString

import com.google.common.base.Splitter; //导入依赖的package包/类
/**
 * 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<>();
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:32,代码来源:Url.java

示例4: decode

import com.google.common.base.Splitter; //导入依赖的package包/类
@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);
}
 
开发者ID:smoketurner,项目名称:graphiak,代码行数:18,代码来源:GraphiteMetricDecoder.java

示例5: getPath

import com.google.common.base.Splitter; //导入依赖的package包/类
@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();
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:20,代码来源:PathAwareUrl.java

示例6: handleRequest

import com.google.common.base.Splitter; //导入依赖的package包/类
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);
    }
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:26,代码来源:ServerLogger.java

示例7: onLogin

import com.google.common.base.Splitter; //导入依赖的package包/类
@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;
    });
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:23,代码来源:NioSocketEventHandler.java

示例8: create

import com.google.common.base.Splitter; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:28,代码来源:Version.java

示例9: handleBothToolsAttributePresent

import com.google.common.base.Splitter; //导入依赖的package包/类
/**
 * 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()));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:XmlAttribute.java

示例10: print

import com.google.common.base.Splitter; //导入依赖的package包/类
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, "┗");
    }
}
 
开发者ID:killnono,项目名称:Dalaran,代码行数:26,代码来源:LogUtils.java

示例11: deseralise

import com.google.common.base.Splitter; //导入依赖的package包/类
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!
	 }
	 
}
 
开发者ID:ThomasWrobel,项目名称:JAMCore,代码行数:22,代码来源:SceneStatus.java

示例12: read

import com.google.common.base.Splitter; //导入依赖的package包/类
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();
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:18,代码来源:Params.java

示例13: getGroupSearchFilter

import com.google.common.base.Splitter; //导入依赖的package包/类
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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:LDAP.java

示例14: process

import com.google.common.base.Splitter; //导入依赖的package包/类
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();
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:19,代码来源:SiteConfigPostProcessor.java

示例15: parseEnchantments

import com.google.common.base.Splitter; //导入依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:GlobalItemParser.java


注:本文中的com.google.common.base.Splitter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。