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


Java StringUtils.split方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.split方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.split方法的具体用法?Java StringUtils.split怎么用?Java StringUtils.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


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

示例1: getQueryBuilder

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Getter for the QueryBuilder for the parsed creator string
 * @param creator the creator string formated as '<code>queryBuilder/{queryBuilder#getName()}/{config#getName()}</code>'
 * where '<code>{queryBuilder#getName()}</code>' is the same as '<code>{config#getType()}</code>'
 * @return the {@link QueryBuilder} or <code>null</code> if not present
 */
public <C extends ComponentConfiguration> Entry<QueryBuilder<C>,C> getQueryBuilder(String creator, Configuration conf) {
    String[] creatorParts = StringUtils.split(creator, ':');
    if(creatorParts.length >= 2){
        QueryBuilder<C> queryBuilder = (QueryBuilder<C>)builders.get(creatorParts[1]);
        if(queryBuilder == null){
            return null;
        }
        if(creatorParts.length >= 3){
            Optional<C> config = conf.getConfiguration(queryBuilder,creatorParts[2]);
            if(config.isPresent()){
                return new ImmutablePair<>(queryBuilder, config.get());
            } else { //the referenced config was not found
                return null;
            }
        } else { //no configuration in the creator string ... so a null configuration is OK
            return new ImmutablePair<>(queryBuilder, null);
        }
    } else {
        return null;
    }
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:28,代码来源:QueryBuilderService.java

示例2: parse

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private Privilege parse(String expression) {
    Privilege privilege = new Privilege();
    privilege.setMsName(appName);
    String[] inputParams = StringUtils.split(expression, ",");

    for (int i = 0; i < inputParams.length; i++) {
        if (i == inputParams.length - 1) {
            if (StringUtils.contains(inputParams[i], "'")) {
                privilege.setKey(StringUtils.substringBetween(inputParams[i], "'")
                    .replace("@msName", appName.toUpperCase()));
            } else {
                privilege.setKey(inputParams[i].replace("@msName", appName.toUpperCase()));
            }
        } else {
            String resource = StringUtils.substringBetween(inputParams[i], "'");
            if (StringUtils.isNotEmpty(resource)) {
                privilege.getResources().add(resource);
            }
        }
    }
    return privilege;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:23,代码来源:PrivilegeScanner.java

示例3: getHistory

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * <p>
 * 取得阅读历史
 * </p>
 */
private void getHistory() {
    logger.debug("getHistory start.");
    // 获得阅读履历
    String historys = CookieUtils.getHistoryCookie(ServletActionContext.getRequest());
    if (StringUtils.isNotEmpty(historys)) {
        String[] acnos = StringUtils.split(historys, ",");
        List<String> articlenoList = new ArrayList<String>();
        for (String articleAndchapterno : acnos) {
            String[] acnoArr = StringUtils.split(articleAndchapterno, "|");
            if (acnoArr.length > 0) {
                articlenoList.add(acnoArr[0]);
            }
        }
        if (articlenoList.size() > 0) {
            ArticleSearchBean searchBean = new ArticleSearchBean();
            searchBean.setArticlenos(StringUtils.join(articlenoList, ","));
            dto.setItems(articleService.find(searchBean));
        }
        dto.setCode(ReturnCode.SUCCESS);
    }
    logger.debug("getHistory normally end.");
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:28,代码来源:AjaxServiceAction.java

示例4: buildLibraryFromRecordType

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public Library buildLibraryFromRecordType(Record rec) {
	Library ret = new Library();
	DataTypes types = new DataTypes();
	ret.setTypes(types);
	List<Field> fields = new ArrayList<Field>();
	fields.addAll(rec.getField());
	rec.getField().clear();
	for (Field field : fields) {
		if (StringUtils.containsIgnoreCase(field.getType(), ":")) {
			String[] vals = StringUtils.split(field.getType(), ":");
			field.setType(field.getType());
			Use use = new Use();
			use.setLibrary(LibraryUtil.getLibraryUseNameFromName(vals[0]));
			if (!existing(use, ret))
				ret.getUse().add(use);
		}
		rec.getField().add(field);
	}
	ret.getTypes().getSimpleOrRecordOrConstant().add(rec);
	return ret;
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:22,代码来源:TypesUtil.java

示例5: getResourcesWithExtension

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) {
	ArrayList<String> ret = new ArrayList<String>();
	if (containerName != null) {
		String[] names = StringUtils.split(containerName, "/");
		IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
		IResource resource = wsRoot.findMember(new Path("/" + names[0]));
		IPath loc = resource.getLocation();
		File prjLoc = new File(loc.toString());
		Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
		for (File file : res)
			ret.add(file.getAbsolutePath());
	}
	return ret;
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:15,代码来源:PluginUtil.java

示例6: addMaxCountCheck

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void addMaxCountCheck(AttributeMap map) {
    final String maxcount = map.get(MAXCOUNT);
    String[] splitted = StringUtils.split(maxcount, ',');
    Class<?> entityClass = null;
    int amount;
    try {
        amount = Integer.parseInt(splitted[0]);
    } catch (NumberFormatException e) {
        InControl.logger.log(Level.ERROR, "Bad amount for maxcount '" + splitted[0] + "'!");
        return;
    }
    if (splitted.length > 1) {
        String id = EntityTools.fixEntityId(splitted[1]);
        entityClass = EntityTools.findClassById(id);
        if (entityClass == null) {
            InControl.logger.log(Level.ERROR, "Unknown mob '" + splitted[1] + "'!");
            return;
        }
    }

    Class<?> finalEntityClass = entityClass;
    checks.add((event,query) -> {
        int count = query.getWorld(event).countEntities(finalEntityClass == null ? query.getEntity(event).getClass() : finalEntityClass);
        return count <= amount;
    });
}
 
开发者ID:McJty,项目名称:InControl,代码行数:27,代码来源:GenericRuleEvaluator.java

示例7: getGroup

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getGroup(SalukiReference reference, String serviceName, Class<?> referenceClass) {
  Pair<String, String> groupVersion = findGroupAndVersionByServiceName(serviceName);
  if (StringUtils.isNoneBlank(reference.group())) {
    return reference.group();
  } else if (StringUtils.isNoneBlank(groupVersion.getLeft())) {
    String replaceGroup = groupVersion.getLeft();
    Matcher matcher = REPLACE_PATTERN.matcher(replaceGroup);
    if (matcher.find()) {
      String replace = matcher.group().substring(2, matcher.group().length() - 1).trim();
      String[] replaces = StringUtils.split(replace, ":");
      if (replaces.length == 2) {
        String realGroup = env.getProperty(replaces[0], replaces[1]);
        return realGroup;
      } else {
        throw new IllegalArgumentException("replaces formater is #{XXXgroup:groupName}");
      }
    } else {
      return replaceGroup;
    }
  } else if (this.isGenericClient(referenceClass)) {
    return StringUtils.EMPTY;
  }
  throw new java.lang.IllegalArgumentException(String
      .format("reference group can not be null or empty,the servicName is %s", serviceName));

}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:27,代码来源:GrpcReferenceRunner.java

示例8: main

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    Options options = getOptions();
    try {
        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = parser.parse(options, args);

        String[] streamId = StringUtils.split(cmd.getOptionValue("stream", DEFAULT_STREAM_ID), '/');
        if(streamId.length != 2) {
            throw new IllegalArgumentException("Stream spec must be in the form [scope]/[stream]");
        }

        final URI controllerURI = URI.create(cmd.getOptionValue("uri", DEFAULT_CONTROLLER_URI));
        new NoopReader().run(streamId[0], streamId[1], controllerURI);
    }
    catch (ParseException e) {
        System.out.format("%s.%n", e.getMessage());
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("NoopReader", options);
        System.exit(1);
    }
}
 
开发者ID:pravega,项目名称:pravega-samples,代码行数:22,代码来源:NoopReader.java

示例9: getIntervals

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected static java.util.List<GenomeLoc> getIntervals(RefContigInfo refContigInfo, String filePath) {
    String intervalPath = TestRealignerTargetCreator.class.getResource(filePath).getFile();
    java.util.List<GenomeLoc> intervals = new ArrayList<>();
    try (BufferedReader reader = new BufferedReader(new FileReader(new File(intervalPath)))) {
        String line = reader.readLine();
        while (line != null) {
            if(line.length() > 0 && !line.startsWith("@")) {
                String[] split = StringUtils.split(line, '\t');
                String contigName = split[0];
                int contigId = refContigInfo.getId(contigName);
                int start = Integer.parseInt(split[1]);
                int stop = Integer.parseInt(split[2]);
                intervals.add(new GenomeLoc(contigName, contigId, start, stop));
            }
            line = reader.readLine();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return intervals;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:23,代码来源:AbstractTestCase.java

示例10: getItems

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Add and return not blank values from a string split with ',' separator.
 */
private Set<String> getItems(final String rawValue) {
	final Set<String> result = new HashSet<>();
	for (final String rawItem : StringUtils.split(StringUtils.trimToEmpty(rawValue), ',')) {
		result.add(StringUtils.trim(rawItem));
	}
	return result;
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:11,代码来源:JiraImportPluginResource.java

示例11: buildLibraryFromArrayType

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public Library buildLibraryFromArrayType(Array arr) {
	Library ret = new Library();
	DataTypes types = new DataTypes();
	ret.setTypes(types);
	if (StringUtils.containsIgnoreCase(arr.getItemType(), ":")) {
		String[] vals = StringUtils.split(arr.getItemType(), ":");
		arr.setItemType(arr.getItemType());
		Use use = new Use();
		use.setLibrary(LibraryUtil.getLibraryUseNameFromName(vals[0]));
		if (!existing(use, ret))
			ret.getUse().add(use);
	}
	ret.getTypes().getSimpleOrRecordOrConstant().add(arr);
	return ret;
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:16,代码来源:TypesUtil.java

示例12: setTarget

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void setTarget(final String hostname) {
    final String simple;
    final String[] parts = StringUtils.split(hostname, '.');
    if(parts.length > 4) {
        ArrayUtils.reverse(parts);
        // Rewrite c.cyberduck.s3.amazonaws.com which does not match wildcard certificate *.s3.amazonaws.com
        simple = StringUtils.join(parts[3], ".", parts[2], ".", parts[1], ".", parts[0]);
        log.warn(String.format("Rewrite hostname target to %s", simple));
    }
    else {
        simple = hostname;
    }
    super.setTarget(simple);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:LaxHostnameDelegatingTrustManager.java

示例13: addRegistyAddress

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void addRegistyAddress(RpcServiceConfig rpcSerivceConfig) {
  String registryAddress = grpcProperties.getRegistryAddress();
  if (StringUtils.isBlank(registryAddress)) {
    throw new java.lang.IllegalArgumentException("registry address can not be null or empty");
  } else {
    String[] registryHostAndPort = StringUtils.split(registryAddress, ":");
    if (registryHostAndPort.length < 2) {
      throw new java.lang.IllegalArgumentException(
          "the pattern of registry address is host:port");
    }
    rpcSerivceConfig.setRegistryAddress(registryHostAndPort[0]);
    rpcSerivceConfig.setRegistryPort(Integer.valueOf(registryHostAndPort[1]));
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:15,代码来源:GrpcServiceRunner.java

示例14: loadUserDetails

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws AuthenticationException {
	Set<SimpleGrantedAuthority> authorities = new HashSet<SimpleGrantedAuthority>();
	String credentials = (String)token.getCredentials();
	for(String credential : StringUtils.split(credentials, ";")) {
		if(mappingGroupesRoles != null && mappingGroupesRoles.containsKey(credential)){ 
			authorities.add(new SimpleGrantedAuthority(mappingGroupesRoles.get(credential)));
		}
	}
	for(String roleFromLdap : ldapGroup2UserRoleService.getRoles(token.getName())) {
		authorities.add(new SimpleGrantedAuthority(roleFromLdap));
	}
	log.info("Shib & Ldap Credentials for " + token.getName() + " -> " + authorities);
	return createUserDetails(token, authorities);
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:15,代码来源:ShibAuthenticatedUserDetailsService.java

示例15: addPotionsAction

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void addPotionsAction(AttributeMap map) {
    List<PotionEffect> effects = new ArrayList<>();
    for (String p : map.getList(ACTION_POTION)) {
        String[] splitted = StringUtils.split(p, ',');
        if (splitted == null || splitted.length != 3) {
            InControl.logger.log(Level.ERROR, "Bad potion specifier '" + p + "'! Use <potion>,<duration>,<amplifier>");
            continue;
        }
        Potion potion = ForgeRegistries.POTIONS.getValue(new ResourceLocation(splitted[0]));
        if (potion == null) {
            InControl.logger.log(Level.ERROR, "Can't find potion '" + p + "'!");
            continue;
        }
        int duration = 0;
        int amplifier = 0;
        try {
            duration = Integer.parseInt(splitted[1]);
            amplifier = Integer.parseInt(splitted[2]);
        } catch (NumberFormatException e) {
            InControl.logger.log(Level.ERROR, "Bad duration or amplifier integer for '" + p + "'!");
            continue;
        }
        effects.add(new PotionEffect(potion, duration, amplifier));
    }
    if (!effects.isEmpty()) {
        actions.add(event -> {
            EntityLivingBase living = getHelper(event);
            for (PotionEffect effect : effects) {
                PotionEffect neweffect = new PotionEffect(effect.getPotion(), effect.getDuration(), effect.getAmplifier());
                living.addPotionEffect(neweffect);
            }
        });
    }
}
 
开发者ID:McJty,项目名称:InControl,代码行数:35,代码来源:SummonAidRule.java


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