本文整理汇总了Java中org.apache.commons.lang3.StringUtils.endsWithAny方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.endsWithAny方法的具体用法?Java StringUtils.endsWithAny怎么用?Java StringUtils.endsWithAny使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.endsWithAny方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFilter
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
YiDuConstants.singleBookFlag.set(false);
HttpServletRequest req = (HttpServletRequest) request;
String uri = req.getRequestURI();
if (StringUtils.endsWithAny(uri, "css", "js", "jpg", "png", "gif")) {
// 静态资源直接跳过
logger.debug("ignore static resource." + uri);
chain.doFilter(request, response);
} else {
// 非静态资源时,根据具体的信息去做判别,时候需要标识单本
String rootDomian = YiDuConstants.yiduConf.getString(YiDuConfig.ROOT_DOMAIN);
String aname = StringUtils.substringBeforeLast(req.getServerName(), "." + rootDomian);
logger.debug("aname : " + aname);
if (StringUtils.isNotBlank(aname)) {
int articleno = SingleBookManager.getArticleno(aname);
if (articleno != 0) {
// TODO 即便找到对应的小说,也只做首页和阅读页,其他全部404吧
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(uri);
boolean matchFlag = false;
String newURI = "";
if (m.find()) {
// 阅读页
newURI = ReaderAction.URL + "?chapterno="
+ StringUtils.substringBeforeLast(m.group(1), ".html");
matchFlag = true;
} else if (StringUtils.equals(uri, "/") || StringUtils.isEmpty(uri)) {
// 首页
newURI = InfoAction.URL + "?articleno=" + articleno;
matchFlag = true;
} else {
// 返回404
YiDuConstants.singleBookFlag.set(true);
((HttpServletResponse) response).sendError(HttpServletResponse.SC_NOT_FOUND);
}
logger.debug("newURI str: " + newURI);
if (matchFlag) {
YiDuConstants.singleBookFlag.set(true);
YiDuConstants.singleBookServerName.set(req.getServerName());
req.getRequestDispatcher(newURI).forward(request, response);
}
} else {
chain.doFilter(request, response);
}
} else {
chain.doFilter(request, response);
}
}
}
示例2: getTargetStockTypes
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static List<StockType> getTargetStockTypes(Scanner scanner, Message message,
String operation) {
Locale locale = getResponseLocale(message);
List<StockType> stockTypes = new ArrayList<>();
List<String> unknownStockTypes = new ArrayList<>();
List<String> inputNames = new ArrayList<>();
while (scanner.hasNext()) {
String next = scanner.next();
boolean groupStart = StringUtils.startsWithAny(next, "\"", "\'");
if (!groupStart) {
inputNames.add(next);
} else {
StringBuilder buffer = new StringBuilder(next);
boolean groupEnd = false;
while (scanner.hasNext() && !groupEnd) {
next = scanner.next();
groupEnd = StringUtils.endsWithAny(next, "\"", "\'");
buffer.append(" ");
buffer.append(next);
}
buffer.deleteCharAt(0);
buffer.deleteCharAt(buffer.length() - 1);
inputNames.add(buffer.toString());
}
}
for (String inputName : inputNames) {
try {
// may throws IllegalArgumentException if there is no
String key = Resource.getItemKey(inputName, locale);
Optional<StockType> stockOpt = getStockTypeDao().findByKey(key);
if (!stockOpt.isPresent()) {
unknownStockTypes.add(inputName);
} else {
stockTypes.add(stockOpt.get());
}
} catch (Exception e) {
unknownStockTypes.add(inputName);
}
}
if (!unknownStockTypes.isEmpty()) {
String msg = String.format(Resource.getString("GROUP_UNKNOWN_TYPE", locale),
unknownStockTypes.toString());
Speaker.err(message, msg);
}
return stockTypes;
}