Example usage for org.apache.commons.lang StringUtils contains

List of usage examples for org.apache.commons.lang StringUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils contains.

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:com.glaf.core.util.http.HttpClientUtils.java

/**
 * ??GET/*from   w w w.  j  av a2  s .com*/
 * 
 * @param url
 *            ??
 * @param encoding
 *            
 * @param dataMap
 *            ?
 * 
 * @return
 */
public static String doGet(String url, String encoding, Map<String, String> dataMap) {
    StringBuffer buffer = new StringBuffer();
    HttpGet httpGet = null;
    InputStreamReader is = null;
    BufferedReader reader = null;
    BasicCookieStore cookieStore = new BasicCookieStore();
    HttpClientBuilder builder = HttpClientBuilder.create();
    CloseableHttpClient client = builder.setDefaultCookieStore(cookieStore).build();
    try {
        if (dataMap != null && !dataMap.isEmpty()) {
            StringBuffer sb = new StringBuffer();
            for (Map.Entry<String, String> entry : dataMap.entrySet()) {
                String name = entry.getKey().toString();
                String value = entry.getValue();
                sb.append("&").append(name).append("=").append(value);
            }
            if (StringUtils.contains(url, "?")) {
                url = url + sb.toString();
            } else {
                url = url + "?xxxx=1" + sb.toString();
            }
        }
        httpGet = new HttpGet(url);
        HttpResponse response = client.execute(httpGet);
        HttpEntity entity = response.getEntity();
        is = new InputStreamReader(entity.getContent(), encoding);
        reader = new BufferedReader(is);
        String tmp = reader.readLine();
        while (tmp != null) {
            buffer.append(tmp);
            tmp = reader.readLine();
        }
    } catch (IOException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    } finally {
        IOUtils.closeStream(reader);
        IOUtils.closeStream(is);
        if (httpGet != null) {
            httpGet.releaseConnection();
        }
        try {
            client.close();
        } catch (IOException ex) {
        }
    }
    return buffer.toString();
}

From source file:com.safetys.framework.jmesa.core.filter.NumberFilterMatcher.java

public boolean evaluate(Object itemValue, String filterValue) {
    if (itemValue == null) {
        return false;
    }//ww  w.j a va2 s  .  c om

    Locale locale = null;

    WebContext webContext = getWebContext();
    if (webContext != null) {
        locale = webContext.getLocale();
    }

    NumberFormat nf;
    if (locale != null) {
        nf = NumberFormat.getInstance(locale);
    } else {
        nf = NumberFormat.getInstance();
    }

    DecimalFormat df = (DecimalFormat) nf;
    String pattern = getPattern();
    df.applyPattern(pattern);
    itemValue = df.format(itemValue);

    String item = String.valueOf(itemValue);
    String filter = String.valueOf(filterValue);
    if (StringUtils.contains(item, filter)) {
        return true;
    }

    return false;
}

From source file:com.enonic.cms.core.search.query.QueryField.java

public boolean isWildcardQueryField() {
    return StringUtils.contains(this.fieldName, "*");
}

From source file:cn.newtouch.util.test.utils.SeleniumUtils.java

/**
 * Selnium1.0.// w w  w.j  a  v  a 2 s .c  om
 */
public static boolean isTextPresent(WebDriver driver, String text) {
    return StringUtils.contains(driver.findElement(By.tagName("body")).getText(), text);
}

From source file:cn.vlabs.duckling.vwb.ui.action.HtmlValidateUtil.java

private static boolean containsInvalidateUrl(String html) {
    if (StringUtils.isBlank(html)) {
        return false;
    }//from   ww w  .  j  a  v a2s. c  om

    for (String str : getInvalidateFormAction()) {
        if (StringUtils.contains(html, str)) {
            return true;
        }
    }

    return false;

}

From source file:gemlite.shell.converters.ServiceNameConverter.java

public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData,
        String optionContext, MethodTarget target) {
    if ((String.class.equals(targetType))
            && (StringUtils.contains(optionContext, "param.context.service.name"))) {
        Set<ObjectInstance> beans = jmxService.listMBeans();
        for (ObjectInstance bean : beans) {
            String name = bean.getObjectName().getCanonicalName();
            if (existingData != null) {
                if (name.startsWith(existingData)) {
                    completions.add(new Completion(name));
                }/*from   w w w .  j  a v a2 s .c o  m*/
            } else {
                completions.add(new Completion(name));
            }
        }
    }
    return !completions.isEmpty();
}

From source file:cn.cuizuoli.gotour.utils.HtmlHelper.java

/**
 * toList/* www . ja  va 2s  . co  m*/
 * @param text
 * @return
 */
public static String toList(String text) {
    String[] lines = StringUtils.split(text, "\r\n");
    StringBuffer listBuffer = new StringBuffer();
    listBuffer.append("<ul>").append("\n");
    for (String line : lines) {
        Matcher listMatcher = LIST_PATTERN.matcher(line);
        if (listMatcher.matches()) {
            String li = listMatcher.group(1) + listMatcher.group(2);
            if (StringUtils.contains(li, "")) {
                li = "<strong>" + StringUtils.replace(li, "", "</strong>");
            }
            listBuffer.append("<li>").append(li).append("</li>").append("\n");
        }
    }
    listBuffer.append("</ul>").append("\n");
    return listBuffer.toString();
}

From source file:edu.ku.brc.af.ui.ProcessListUtil.java

/**
 * @return/* ww  w  .  j av a 2  s .  c om*/
 */
public static List<List<String>> getRunningProcessesWin() {

    List<List<String>> processList = new ArrayList<List<String>>();
    try {
        boolean doDebug = true;
        Process process = Runtime.getRuntime().exec("tasklist.exe /v /nh /FO CSV");
        BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = input.readLine()) != null) {
            if (!line.trim().isEmpty()) {
                if (doDebug && StringUtils.contains(line, "mysql")) {
                    String lineStr = StringUtils.replaceChars(line, '\\', '/');
                    System.out.println("\n[" + lineStr + "]");
                    for (String tok : parse(lineStr)) {
                        System.out.print("[" + tok + "]");
                    }
                    System.out.println();

                }
                processList.add(parse(StringUtils.replaceChars(line, '\\', '/')));
            }
        }
        input.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return processList;
}

From source file:com.hangum.tadpole.db.metadata.MakeContentAssistUtil.java

/**
 *    ? ? ??     .. /*from   w ww.  j a v  a  2  s  . c  om*/
 *   content assist   tester.tablename   ?  ?? . ?   ? ? ? ?. 
 * 
 * @param userDB
 * @param strArryCursor
 * @return
 */
protected String getSchemaOrTableContentAssist(UserDBDAO userDB, String[] strArryCursor) {
    String strCntAsstList = getContentAssist(userDB);
    String strCursorText = strArryCursor[0] + strArryCursor[1];

    if (StringUtils.contains(strCursorText, '.')) {
        String strSchemaName = StringUtils.substringBefore(strCursorText, ".") + ".";
        //         String strTableName       = StringUtils.substringAfter(strCursorText, ".");
        int intSep = StringUtils.indexOf(strCursorText, ".");

        if (logger.isDebugEnabled()) {
            logger.debug("[0]" + strArryCursor[0]);
            logger.debug("[1]" + strArryCursor[1]);
            logger.debug("[1][intSep]" + intSep);
            logger.debug("[1][strArryCursor[0].length()]" + strArryCursor[0].length());
            logger.debug("==> [Return table list]" + (strArryCursor[0].length() >= intSep));
        }

        // ?  ?  ?  .
        if (strArryCursor[0].length() >= intSep) {
            String strNewCntAsstList = "";

            String[] listGroup = StringUtils.splitByWholeSeparator(strCntAsstList, _PRE_GROUP);
            if (listGroup == null)
                return strNewCntAsstList;

            for (String strDefault : listGroup) {
                String[] listDefault = StringUtils.split(strDefault, _PRE_DEFAULT);
                if (listDefault != null & listDefault.length == 2) {
                    if (StringUtils.startsWithIgnoreCase(listDefault[0], strSchemaName))
                        strNewCntAsstList += makeObjectPattern("",
                                StringUtils.removeStartIgnoreCase(listDefault[0], strSchemaName),
                                listDefault[1]);
                } // 
            }

            return strNewCntAsstList;
        }
    }

    return strCntAsstList;
}

From source file:com.googlecode.jtiger.modules.ecside.util.ExportViewUtils.java

public static String escapeChars(String value) {
    if (StringUtils.isBlank(value))
        return "";

    if (StringUtils.contains(value, "&")) {
        value = StringUtils.replace(value, "&", "&#38;");
    }/*w w w.j  a v  a  2  s.  c  o m*/

    if (StringUtils.contains(value, ">")) {
        value = StringUtils.replace(value, ">", "&gt;");
    }

    if (StringUtils.contains(value, "<")) {
        value = StringUtils.replace(value, "<", "&lt;");
    }

    return value;
}