Java Code Examples for org.apache.commons.lang3.StringUtils#join()

The following examples show how to use org.apache.commons.lang3.StringUtils#join() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissionServiceImpl.java    From EasyReport with Apache License 2.0 6 votes vote down vote up
@Override
public String getPermissionIds(final String[] codes) {
    if (ArrayUtils.isEmpty(codes)) {
        return StringUtils.EMPTY;
    }

    final List<String> permIds = new ArrayList<>(codes.length);
    for (final String code : codes) {
        final String key = code.trim().toLowerCase();
        if (cache.containsKey(key)) {
            permIds.add(String.valueOf(cache.get(key).getId()));
        }
    }

    return StringUtils.join(permIds, ',');
}
 
Example 2
Source File: PhpSilexServerCodegen.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
    Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
    List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
    for (CodegenOperation op : operationList) {
        String path = op.path;
        String[] items = path.split("/", -1);
        String opsPath = "";
        int pathParamIndex = 0;

        for (int i = 0; i < items.length; ++i) {
            if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
                // camelize path variable
                items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
            }
        }

        op.path = StringUtils.join(items, "/");
    }

    return objs;
}
 
Example 3
Source File: ChangeLogManager.java    From RestServices with Apache License 2.0 5 votes vote down vote up
/**
 * Determines on which settings this index was build. If changed, a new index should be generated
 * @param def
 * @return
 */
private String calculateServiceConfigurationHash(DataServiceDefinition def) {
	IMetaObject returnType = Core.getMetaObject(Core.getReturnType(def.getOnPublishMicroflow()).getObjectType());
	JSONObject exporttype = JSONSchemaBuilder.build(returnType);
	
	return StringUtils.join(new String[] {
		def.getSourceEntity(), 
		def.getSourceKeyAttribute(), 
		def.getSourceConstraint(),
		exporttype.toString()
	},";");
}
 
Example 4
Source File: CommandLineUtil.java    From crushpaper with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns the array of with double quotes around any argument with spaces
 * in it so it can be run from the command line.
 */
static public String getArgsForCopyAndPaste(String[] args) {
	String[] result = new String[args.length];

	for (int i = 0; i < args.length; ++i) {
		String arg = args[i];
		result[i] = arg.contains(" ") ? "\"" + arg + "\"" : arg;
	}

	return StringUtils.join(result, " ");
}
 
Example 5
Source File: ListToStringConveter.java    From ee7-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
public String convertToDatabaseColumn(List<String> attribute) {
    if (attribute == null || attribute.isEmpty()) {
        return "";
    }
    return StringUtils.join(attribute, ",");
}
 
Example 6
Source File: AwsSigner4Request.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
AwsSigner4Request(String region, String service, HttpRequest request, Date signingTime) {
    this.region = region;
    this.service = service;
    this.request = request;

    signingDateTime = getSigningDateTime(request, signingTime);
    signingDate = signingDateTime.substring(0, 8);
    scope = signingDate + '/' + region + '/' + service + "/aws4_request";
    method = request.getRequestLine().getMethod();
    uri = getUri(request);

    Map<String, String> headers = getOrderedHeadersToSign(request.getAllHeaders());
    signedHeaders = StringUtils.join(headers.keySet(), ';');
    canonicalHeaders = canonicalHeaders(headers);
}
 
Example 7
Source File: StopwordsItem.java    From fess with Apache License 2.0 5 votes vote down vote up
public String toLineString() {
    if (isUpdated()) {
        return StringUtils.join(newInput);
    } else {
        return StringUtils.join(input);
    }
}
 
Example 8
Source File: TargetedUrlByFolderStrategy.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Pattern getTargetedUrlPattern() {
    String availableTargetIds = StringUtils.join(targetIdManager.getAvailableTargetIds(), '|');
    String targetedUrlByFilePattern = String.format(TARGETED_URL_REGEX_FORMAT, availableTargetIds);

    return Pattern.compile(targetedUrlByFilePattern);
}
 
Example 9
Source File: StandardNiFiUser.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    final String formattedGroups;
    if (groups == null) {
        formattedGroups = "none";
    } else {
        formattedGroups = StringUtils.join(groups, ", ");
    }

    return String.format("identity[%s], groups[%s]", getIdentity(), formattedGroups);
}
 
Example 10
Source File: UserServiceImpl.java    From liferay-angularjs-portlet with Apache License 2.0 5 votes vote down vote up
private String toCommaSeparatedRoleList(com.liferay.portal.model.User liferayUser)throws SystemException {
  List<String> roleNames = new ArrayList<>();
  for (Role role : liferayUser.getRoles()) {
    roleNames.add(role.getName());
  }
  return StringUtils.join(roleNames, ",");
}
 
Example 11
Source File: HierarchicalShardSyncer.java    From amazon-kinesis-client with Apache License 2.0 5 votes vote down vote up
/** Helper method to detect a race condition between fetching the shards via paginated DescribeStream calls
 * and a reshard operation.
 * @param inconsistentShardIds
 * @throws KinesisClientLibIOException
 */
private static void assertAllParentShardsAreClosed(final Set<String> inconsistentShardIds)
    throws KinesisClientLibIOException {
    if (!CollectionUtils.isNullOrEmpty(inconsistentShardIds)) {
        final String ids = StringUtils.join(inconsistentShardIds, ' ');
        throw new KinesisClientLibIOException(String.format(
                "%d open child shards (%s) are inconsistent. This can happen due to a race condition between describeStream and a reshard operation.",
                inconsistentShardIds.size(), ids));
    }
}
 
Example 12
Source File: DefaultCodegen.java    From TypeScript-Microservices with MIT License 5 votes vote down vote up
/**
 * Remove characters that is not good to be included in method name from the input and camelize it
 *
 * @param name string to be camelize
 * @param nonNameElementPattern a regex pattern of the characters that is not good to be included in name
 * @return camelized string
 */
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
    String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
        @Nullable
        @Override
        public String apply(String input) {
            return StringUtils.capitalize(input);
        }
    }), "");
    if (result.length() > 0) {
        result = result.substring(0, 1).toLowerCase() + result.substring(1);
    }
    return result;
}
 
Example 13
Source File: ZkDeployMgrImpl.java    From disconf with Apache License 2.0 5 votes vote down vote up
/**
 * 获取ZK的详细部署信息
 */
@Override
public String getDeployInfo(String app, String env, String version) {

    // 路径获取
    String url = ZooPathMgr.getZooBaseUrl(zooConfig.getZookeeperUrlPrefix(), app, env, version);

    List<String> hostInfoList = zooKeeperDriver.getConf(url);

    return StringUtils.join(hostInfoList, '\n');
}
 
Example 14
Source File: ScriptClientShellHandler.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public void run(String[] args) {
	String line = StringUtils.join(args, " ");
	try {
		writeStdin(line);
	} catch (Throwable e) {
		err.println(getStackTrace(e));
		shutdown();
	}
}
 
Example 15
Source File: ApolloClient.java    From apollo with Apache License 2.0 4 votes vote down vote up
private <T> String createCsvFromList(List<T> list) {
    return StringUtils.join(list, ",");
}
 
Example 16
Source File: ConsoleResult.java    From gocd with Apache License 2.0 4 votes vote down vote up
public String errorForDisplayAsString() {
    return StringUtils.join(forDisplay(error), "\n");
}
 
Example 17
Source File: QueryTest.java    From jackcess with Apache License 2.0 4 votes vote down vote up
private static String multiline(String... strs)
{
  return StringUtils.join(strs, System.lineSeparator());
}
 
Example 18
Source File: CoreUtils.java    From TranskribusCore with GNU General Public License v3.0 4 votes vote down vote up
public static String toListString(String[] list) {
	return "(" + StringUtils.join(list) + ")";
}
 
Example 19
Source File: Directories.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
private static String join(String... s)
{
    return StringUtils.join(s, File.separator);
}
 
Example 20
Source File: ReactionRenderer.java    From act with GNU General Public License v3.0 3 votes vote down vote up
public void drawReaction(MongoDB db, Long reactionId, String dirPath, boolean includeCofactors) throws IOException {

    RxnMolecule renderedReactionMolecule = getRxnMolecule(db, reactionId, includeCofactors);

    String fileName = StringUtils.join(new String[] {reactionId.toString(), ".", format});
    drawRxnMolecule(renderedReactionMolecule, new File(dirPath, fileName));
  }