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:edu.ku.brc.af.core.SpecialMsgNotifier.java

public void checkForMessages() {
    if (blockMsg.get()) {
        return;/*from   w w  w.jav  a  2s.c o  m*/
    }

    SwingWorker<Integer, Integer> msgCheckWorker = new SwingWorker<Integer, Integer>() {
        protected String msg = null;

        /* (non-Javadoc)
         * @see javax.swing.SwingWorker#doInBackground()
         */
        @Override
        protected Integer doInBackground() throws Exception {
            if (!blockMsg.get()) {
                try {
                    Thread.sleep(15000); // 15 seconds

                    String url = UIRegistry.getResourceString("CGI_BASE_URL") + "/getmsg2.php";
                    String installID = UsageTracker.getInstallId();

                    msg = send(url, installID);
                    msg = StringUtils.deleteWhitespace(msg);

                } catch (Exception ex) {
                    // die silently
                }
            }
            return null;
        }

        @Override
        protected void done() {
            super.done();

            if (msg != null) {
                //System.out.println("["+msg+"]");

                if (StringUtils.isNotEmpty(msg) && !StringUtils.contains(msg, "NOMSG")) {
                    String header = msg.length() > 6 ? msg.substring(0, 7).toUpperCase() : "";
                    if (header.startsWith("<HTML>")) {
                        UIRegistry.showLocalizedError("NO_INTERNET");
                    } else {
                        UIRegistry.showError(JOptionPane.WARNING_MESSAGE, msg);
                    }
                }
            }

        }
    };

    msgCheckWorker.execute();
}

From source file:edu.ku.brc.specify.toycode.mexconabio.AgentNames.java

private void parseForNames(final String nameStr) {
    String str = nameStr;//from  ww  w .  ja  va 2 s. c  o  m
    if (StringUtils.contains(str, '\"')) {
        str = StringUtils.remove(str, '\"');
    }

    if (StringUtils.contains(str, ';')) {
        String[] toks = StringUtils.split(str, ';');
        for (String s : toks) {
            parseForFirstLastName(s);
        }
    } else {
        parseForFirstLastName(str);
        /*String[] toks = str.split("^([-\\w]+)(?:(?:\\s?[,|&]\\s)([-\\w]+)\\s?)*(.*)");   //"((?:[^, &]+\\s*[,&]+\\s*)*[^, &]+)\\s+([^,&]+)");
        for (String s : toks)
        {
        System.out.println("    ["+s+"]");
        }*/
    }
    System.out.println();
}

From source file:hydrograph.ui.validators.impl.FTPProtocolSelectionValidator.java

private boolean validatePort(String text, String propertyName) {
    if (StringUtils.isNotBlank(text)) {
        Matcher matcher = Pattern.compile("[\\d]*").matcher(text);
        if ((matcher.matches()) || ((StringUtils.startsWith(text, "@{") && StringUtils.endsWith(text, "}"))
                && !StringUtils.contains(text, "@{}"))) {
            return true;
        }/*  w  w w. j a  v a  2 s . c o m*/
        errorMessage = propertyName + " is mandatory";
    }
    errorMessage = propertyName + " is not integer value or valid parameter";
    return false;
}

From source file:com.cloud.servlet.StaticResourceServlet.java

static boolean isClientCompressionSupported(final HttpServletRequest req) {
    return StringUtils.contains(req.getHeader("Accept-Encoding"), "gzip");
}

From source file:net.kamhon.ieagle.struts2.interceptor.JasperReportInterceptor.java

public String intercept(ActionInvocation actionInvocation) throws Exception {
    File reportFile;// ww  w . ja v a2 s.c o  m
    String jasperPath = "";
    String path = "";

    // HttpServletRequest req = ServletActionContext.getRequest();
    // path = req.getRealPath("/");
    path = ServletActionContext.getServletContext().getRealPath("/");

    if (actionInvocation.getAction() instanceof Action) {
        Action action = (Action) actionInvocation.getAction();
        log.debug("action = " + action);
    }

    ActionProxy actionProxy = actionInvocation.getProxy();
    log.debug("actionName() = " + actionProxy.getActionName());

    if (!IS_PRODUCTION_MODE) {
        // Get Jasper Report Location
        if (actionProxy != null) {
            Map<String, ResultConfig> results = actionProxy.getConfig().getResults();
            for (ResultConfig config : results.values()) {
                if (config != null) {
                    Map<String, String> param = config.getParams();
                    if (StringUtils.isNotBlank(param.get("location"))) {
                        if (StringUtils.contains(param.get("location"), "jasper")) {
                            jasperPath = param.get("location");
                            log.debug("Jasper Path = " + jasperPath);
                            break;
                        }
                    }
                }
            }
        }

        // Compile Jasper Report
        if (StringUtils.isNotBlank(jasperPath)) {
            jasperPath = path + jasperPath;
            jasperPath = StringUtils.replace(jasperPath, "/", File.separator);

            reportFile = new File(jasperPath);
            if (reportFile.exists()) {
                reportFile.delete();
            }

            log.debug("Compile Jasper Report");
            try {
                jasperPath = StringUtils.replace(jasperPath, ".jasper", ".jrxml");
                JasperCompileManager.compileReportToFile(jasperPath);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }

    return actionInvocation.invoke();
}

From source file:de.codecentric.robot.pdf.PDFKeywords.java

private void collectionShouldContain(String expectedValue, Collection<String> values, boolean ignoreCase) {
    for (String content : values) {
        if (ignoreCase ? StringUtils.containsIgnoreCase(content, expectedValue)
                : StringUtils.contains(content, expectedValue)) {
            return;
        }// w  w w  . j  ava2 s .c  o  m
    }
    throw new RuntimeException("could not find " + expectedValue + " in " + pdfData);
}

From source file:com.klwork.common.utils.WebUtils.java

/**
 * ???gzip?.//from  w w  w. ja va 2s  .  co  m
 */
public static boolean checkAccetptGzip(HttpServletRequest request) {
    //Http1.1 header
    String acceptEncoding = request.getHeader("Accept-Encoding");

    if (StringUtils.contains(acceptEncoding, "gzip")) {
        return true;
    } else {
        return false;
    }
}

From source file:ar.com.zauber.commons.spring.exceptions.HeaderBasedStatusSimpleMappingExceptionHandler.java

/**
 * @see SimpleMappingExceptionResolver#doResolveException(HttpServletRequest,
 *      HttpServletResponse, Object, Exception)
 *//*w  w  w.ja v a  2s  .  c om*/
@Override
protected final ModelAndView doResolveException(final HttpServletRequest request,
        final HttpServletResponse response, final Object handler, final Exception ex) {
    if (StringUtils.contains(request.getHeader("Accept"), accept)
            || StringUtils.contains(request.getContentType(), contentType)) {
        LOGGER.debug("Header match! Accept: {}, ContentType: {}", accept, contentType);

        response.setStatus(determineStatusCode(request, determineViewName(ex, request)));
        final ModelAndView mav = new ModelAndView(view);
        mav.addObject(messageKey, ex.getMessage());
        return mav;
    }
    return super.doResolveException(request, response, handler, ex);
}

From source file:hydrograph.ui.parametergrid.utils.ParameterFileManager.java

private Map<String, String> updatePropertyMap(Map<String, String> parameterMap) {
    Map<String, String> map = new LinkedHashMap<>(parameterMap);
    for (Entry<String, String> entry : parameterMap.entrySet()) {
        if (StringUtils.contains(entry.getValue(), ESCAPE_CHAR)) {
            map.put(entry.getKey(), StringUtils.replaceChars(entry.getValue(), ESCAPE_CHAR, BACKWARD_SLASH));
        }/*from w  w  w  .  j  av  a2 s. c  om*/
    }
    return map;
}

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

@SuppressWarnings("rawtypes")
@Override// w  w  w .ja v a2  s. c  o  m
public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData,
        String optionContext, MethodTarget target) {
    if ((String.class.equals(targetType)) && (StringUtils.contains(optionContext, "param.context.job.id"))) {
        BatchService batchService = JpaContext.getService(BatchService.class);
        Collection<Map> jobs = batchService.listJobExecutions("");
        for (Map job : jobs) {
            Long id = Long.parseLong(job.get("job_execution_id").toString());
            String jobName = (String) job.get("job_name");
            Timestamp startTime = (Timestamp) job.get("start_time");
            String str = jobName + "_" + id + "_" + startTime;
            if (existingData != null) {
                if (str.startsWith(existingData)) {
                    completions.add(new Completion(str));
                }
            } else {
                completions.add(new Completion(str));
            }
        }
    }
    if (LogUtil.getCoreLog().isDebugEnabled())
        LogUtil.getCoreLog().debug("JobIdConverter->getAllPossibleValues:" + completions.size());
    return !completions.isEmpty();
}