/** * @param color * @return */ public static Color getColorFromString(final String color) { if (StringUtils.equalsIgnoreCase(color, TRANSPARENT_KEY)) { return Color.WHITE; } String[] comps = StringUtils.substring( color, StringUtils.indexOf(color, OPEN_PARENTHESE) + 1, StringUtils.indexOf(color, CLOSE_PARENTHESE)) .split(COMPOSANT_SEPARATOR); return new Color( Integer.valueOf(comps[0].trim()), Integer.valueOf(comps[1].trim()), Integer.valueOf(comps[2].trim())); }
private int getIndexOfType(String msg, Type t) { if (msg == null) { return 0; } String typeString = "%" + t.name().toLowerCase(); return StringUtils.indexOf(msg, typeString); }
private String getRealNumWithTwo(String number) { int index = 0; if ((index = StringUtils.indexOf(number, ".")) != -1) { return StringUtils.substring(number, 0, index + 2); } return number; }
private String extractZETAISBN(String pageText) { int indexISBN = StringUtils.indexOfIgnoreCase(pageText, "ISBN"); int indexOf = StringUtils.indexOf(pageText, " ", indexISBN + 15); if (indexOf > -1 && indexOf > indexISBN) { return StringUtils.substring(pageText, indexISBN, indexOf); } return ""; }
private FormattedText getFormattedText(String source, char delimiter, FormattedText.Type type) { int delimiterIndex = StringUtils.indexOf(source, delimiter); if (delimiterIndex < 0) { return getPlainText(source); } String link = StringUtils.substring(source, 1, delimiterIndex); String text = StringUtils.substring(source, delimiterIndex + 1, source.length() - 1); return new FormattedText(text, type, link); }
@Test public void testPath() throws Exception { String packName = "com.mo008.wx.controllers.api"; String appPackPrefix = "com.mo008"; final String path = StringUtils.substring( packName, StringUtils.length(appPackPrefix + "."), StringUtils.indexOf(packName, ".controllers")); System.out.println("path = " + path); }
/** * parse maxmind asn result * * @return ASXXXX formatted string */ private String parseASN(String asn) { if (asn != null) { int pos = StringUtils.indexOf(asn, ' '); if (pos != -1) { return StringUtils.substring(asn, 0, pos); } // not a valid asn string return "UNKN"; } // not found return null; }
private String getDelimiter(String text) { if (StringUtils.contains(text, "//") && StringUtils.indexOf(text, "//") == 0) { Character delimiterDummy = text.charAt(2); int end; for (end = 2; end < text.length(); end++) { Character currItem = text.charAt(end); if (!currItem.equals(delimiterDummy)) { break; } } return text.substring(2, end); } return null; }
public List getByImageName(String name) { String path = "/containers/json?all=1"; String json = http.get(AppPath.dockerPath + path); List<Map<String, Object>> list = JsonUtils.objectFromJson(json, List.class); List<Map> listName = new ArrayList<Map>(); if (list != null && list.size() > 0) { for (Map sing : list) { if (StringUtils.indexOf((String) sing.get("Image"), name) >= 0) { listName.add(sing); } } } return listName; }
@Override public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; String currentURL = request.getRequestURI(); String realUrl = StringUtils.remove(currentURL, request.getContextPath()); boolean isCheck = true; NoCheckUrlEnum[] noCheckUrlEnums = NoCheckUrlEnum.values(); for (NoCheckUrlEnum noCheckUrlEnum : noCheckUrlEnums) { if (noCheckUrlEnum.getCode().equals(realUrl)) { isCheck = false; break; } } if (isCheck) { HttpSession session = request.getSession(false); if (session == null) { response.sendRedirect(request.getContextPath() + LOGIN_ACTION); return; } BaseAdminContext baseAdminContext = (BaseAdminContext) session.getAttribute(AdminSystemConstant.ADMIN_SYSTEM_SESSION_KEY); if (baseAdminContext == null) { response.sendRedirect(request.getContextPath() + LOGIN_ACTION); return; } else { realUrl = StringUtils.remove(realUrl, ".action"); int i = StringUtils.indexOf(realUrl, "_"); if (i != -1) { realUrl = StringUtils.substring(realUrl, 0, i + 1); } if (!baseAdminContext.allow(realUrl)) { response.sendRedirect(request.getContextPath() + NO_PURVIEW); return; } } } chain.doFilter(request, response); }
/** * fieldOperator是否需要括号 * * @return */ public boolean isFieldOperatorNeedBracket() { return StringUtils.indexOf(StringUtils.upperCase(fieldOperator), "IN") != -1; }