本文整理汇总了Java中org.apache.commons.lang3.StringUtils.containsAny方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.containsAny方法的具体用法?Java StringUtils.containsAny怎么用?Java StringUtils.containsAny使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.containsAny方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected Exit delete(final SessionPool session, final Path remote) throws BackgroundException {
final List<Path> files = new ArrayList<Path>();
for(TransferItem i : new DeletePathFinder().find(input, TerminalAction.delete, remote)) {
files.add(i.remote);
}
final DeleteWorker worker;
if(StringUtils.containsAny(remote.getName(), '*')) {
worker = new DeleteWorker(new TerminalLoginCallback(reader), files, cache, new DownloadGlobFilter(remote.getName()), progress);
}
else {
worker = new DeleteWorker(new TerminalLoginCallback(reader), files, cache, progress);
}
final SessionBackgroundAction<List<Path>> action = new TerminalBackgroundAction<List<Path>>(controller, session, worker);
if(!this.execute(action)) {
return Exit.failure;
}
return Exit.success;
}
示例2: find
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) {
final Local local = LocalFactory.get(input.getOptionValues(action.name())[1]);
if(StringUtils.containsAny(remote.getName(), '*')) {
// Treat asterisk as wildcard
return Collections.singleton(new TransferItem(remote.getParent(), local));
}
if(remote.isDirectory()) {
// Remote path resolves to directory
if(local.exists()) {
return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName())));
}
return Collections.singleton(new TransferItem(remote, local));
}
// Remote path resolves to file
if(local.isDirectory()) {
// Append remote filename to local target
return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName())));
}
// Keep from input
return Collections.singleton(new TransferItem(remote, local));
}
示例3: find
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException {
if(StringUtils.containsAny(remote.getName(), '*')) {
// Treat asterisk as wildcard
return Collections.singleton(new TransferItem(remote.getParent()));
}
return Collections.singleton(new TransferItem(remote));
}
示例4: create
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items)
throws BackgroundException {
final Transfer transfer;
final TerminalAction type = TerminalActionFinder.get(input);
if(null == type) {
throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type");
}
switch(type) {
case download:
if(StringUtils.containsAny(remote.getName(), '*')) {
transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName()));
}
else {
transfer = new DownloadTransfer(host, items);
}
break;
case upload:
transfer = new UploadTransfer(host, items);
break;
case synchronize:
transfer = new SyncTransfer(host, items.iterator().next());
break;
default:
throw new BackgroundException(LocaleFactory.localizedString("Unknown"),
String.format("Unknown transfer type %s", type.name()));
}
if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) {
try {
transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name())));
}
catch(NumberFormatException ignore) {
//
}
}
return transfer;
}
示例5: getTimeOfDayDescription
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* @param expressionParts
* @return
*/
private static String getTimeOfDayDescription(String[] expressionParts) {
String secondsExpression = expressionParts[0];
String minutesExpression = expressionParts[1];
String hoursExpression = expressionParts[2];
StringBuilder description = new StringBuilder();
// Handle special cases first
if (!StringUtils.containsAny(minutesExpression, specialCharacters) && !StringUtils.containsAny(hoursExpression, specialCharacters) && !StringUtils.containsAny(secondsExpression, specialCharacters)) {
description.append(I18nMessages.get("at")).append(" ").append(DateAndTimeUtils.formatTime(hoursExpression, minutesExpression, secondsExpression)); // Specific time of day (e.g. 10 14)
} else if (minutesExpression.contains("-") && !minutesExpression.contains("/") && !StringUtils.containsAny(hoursExpression, specialCharacters)) {
// Minute range in single hour (e.g. 0-10 11)
String[] minuteParts = minutesExpression.split("-");
description.append(MessageFormat.format(I18nMessages.get("every_minute_between"), DateAndTimeUtils.formatTime(hoursExpression, minuteParts[0]),
DateAndTimeUtils.formatTime(hoursExpression, minuteParts[1])));
} else if (hoursExpression.contains(",") && !StringUtils.containsAny(minutesExpression, specialCharacters)) {
// Hours list with single minute (e.g. 30 6,14,16)
String[] hourParts = hoursExpression.split(",");
description.append(I18nMessages.get("at"));
for (int i = 0; i < hourParts.length; i++) {
description.append(" ").append(DateAndTimeUtils.formatTime(hourParts[i], minutesExpression));
if (i < hourParts.length - 2) {
description.append(",");
}
if (i == hourParts.length - 2) {
description.append(" ");
description.append(I18nMessages.get("and"));
}
}
} else {
String secondsDescription = getSecondsDescription(expressionParts);
String minutesDescription = getMinutesDescription(expressionParts);
String hoursDescription = getHoursDescription(expressionParts);
description.append(secondsDescription);
if (description.length() > 0 && StringUtils.isNotEmpty(minutesDescription)) {
description.append(", ");
}
description.append(minutesDescription);
if (description.length() > 0 && StringUtils.isNotEmpty(hoursDescription)) {
description.append(", ");
}
description.append(hoursDescription);
}
return description.toString();
}
示例6: hasAction
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private boolean hasAction(MockRequest request, String... action) {
String requestAction = request.getBodyParameters().get(S3RequestTransformer.ACTION);
return StringUtils.containsAny(requestAction, action);
}
示例7: validFileName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Check if the given file name is a valid file name. Return false if any of
* the characters in the file name has [email protected]#$%^&*()
*
* @param fileName
* @return
*/
public boolean validFileName(String fileName) {
boolean validFlag = !StringUtils.containsAny(fileName, "[email protected]#$%^&*");
log.info("Inside validFileName method of FileNameUtils:: fileName: " + fileName + "validFlag: " + validFlag);
return validFlag;
}