下面列出了org.apache.commons.lang3.StringUtils#join ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
@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, ',');
}
@Override
protected Pattern getTargetedUrlPattern() {
String availableTargetIds = StringUtils.join(targetIdManager.getAvailableTargetIds(), '|');
String targetedUrlByFilePattern = String.format(TARGETED_URL_REGEX_FORMAT, availableTargetIds);
return Pattern.compile(targetedUrlByFilePattern);
}
@Override
public void run(String[] args) {
String line = StringUtils.join(args, " ");
try {
writeStdin(line);
} catch (Throwable e) {
err.println(getStackTrace(e));
shutdown();
}
}
/**
* 获取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');
}
/**
* 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;
}
/** 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));
}
}
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, ",");
}
@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);
}
/**
* 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()
},";");
}
public String toLineString() {
if (isUpdated()) {
return StringUtils.join(newInput);
} else {
return StringUtils.join(input);
}
}
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);
}
@Override
public String convertToDatabaseColumn(List<String> attribute) {
if (attribute == null || attribute.isEmpty()) {
return "";
}
return StringUtils.join(attribute, ",");
}
/**
* 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, " ");
}
public String errorForDisplayAsString() {
return StringUtils.join(forDisplay(error), "\n");
}
private <T> String createCsvFromList(List<T> list) {
return StringUtils.join(list, ",");
}
private static String multiline(String... strs)
{
return StringUtils.join(strs, System.lineSeparator());
}
public static String toListString(String[] list) {
return "(" + StringUtils.join(list) + ")";
}
private static String join(String... s)
{
return StringUtils.join(s, File.separator);
}
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));
}