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


Java StringUtils.endsWithAny方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:52,代码来源:SingleBookFilter.java

示例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;
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:47,代码来源:Commands.java


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