Example usage for org.apache.commons.lang3 StringUtils containsIgnoreCase

List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils containsIgnoreCase.

Prototype

public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr) 

Source Link

Document

Checks if CharSequence contains a search CharSequence irrespective of case, handling null .

Usage

From source file:com.mirth.connect.plugins.textviewer.TextViewer.java

@Override
public boolean isContentTypeViewable(String contentType) {
    return StringUtils.containsIgnoreCase(contentType, "rtf")
            || StringUtils.containsIgnoreCase(contentType, "text");
}

From source file:com.njlabs.amrita.aid.info.Calender.java

private boolean containsAny(String string, String[] testStrings) {
    for (String testString : testStrings) {
        if (StringUtils.containsIgnoreCase(string, testString)) {
            return true;
        }//from w ww  . j a  v a 2 s .  co m
    }
    return false;
}

From source file:fi.helsinki.opintoni.exception.GlobalExceptionHandlers.java

@ExceptionHandler(value = Exception.class)
public ResponseEntity<CommonError> handleException(Exception e) throws Exception {
    // Only log a brief info message on broken pipes
    if (StringUtils.containsIgnoreCase(ExceptionUtils.getRootCauseMessage(e), "Broken pipe")) {
        LOGGER.info("Broken pipe occurred");
        return null;
    }//from   w  w  w  .  j a va  2  s . c  om

    // If the exception is annotated with @ResponseStatus, rethrow it for other handlers
    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;
    }

    LOGGER.error("Caught exception", e);

    return new ResponseEntity<>(new CommonError("Something went wrong"), HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:com.stefanbrenner.droplet.ui.actions.SaveFileAction.java

protected void showFileChooser() {
    int returnVal = fileChooser.showSaveDialog(getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {

        // Get the selected file
        File file = fileChooser.getSelectedFile();

        // check if file extension fits
        if (StringUtils.containsIgnoreCase(file.getName(), ".") //$NON-NLS-1$
                && !(StringUtils.endsWithIgnoreCase(file.getName(),
                        "." + IDropletContext.DROPLET_FILE_EXTENSION))) {
            JOptionPane.showMessageDialog(getFrame(), Messages.getString("SaveFileAction.extensionNotAllowed"), //$NON-NLS-1$
                    Messages.getString("SaveFileAction.wrongExtension"), //$NON-NLS-1$
                    JOptionPane.ERROR_MESSAGE);
            showFileChooser();//from w w  w.  j  ava 2s.c o  m
            return;
        } else { // automatically add droplet file extension
            if (!StringUtils.endsWithIgnoreCase(file.getName(), "." + IDropletContext.DROPLET_FILE_EXTENSION)) {
                String newPath = StringUtils.join(file.getPath(), "." + IDropletContext.DROPLET_FILE_EXTENSION);
                file = new File(newPath);
            }
        }

        // check if file already exists
        if (file.exists()) {
            int retVal = JOptionPane.showConfirmDialog(getFrame(),
                    Messages.getString("SaveFileAction.overwriteFile"), Messages.getString("SaveFileAction.1"), //$NON-NLS-1$ //$NON-NLS-2$
                    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

            if (retVal == JOptionPane.NO_OPTION) {
                showFileChooser();
                return;
            }
        }

        saveFile(file);

        // set file to context
        getDropletContext().setFile(file);

    }
}

From source file:it.cnr.isti.hpc.dexter.entity.EntityMatchList.java

/**
 * Removes the entities whose spots overlaps, if some entity spots overlaps,
 * only the entity with the greatest score is keep while the others are
 * removed from the list./*from w  w  w  .  j ava2  s.com*/
 * 
 * @return a list of entity matches with no overlaps
 */
public EntityMatchList removeOverlappings() {

    EntityMatchList eml = new EntityMatchList();
    for (EntityMatch e : this) {
        boolean overlaps = false;
        for (EntityMatch e1 : this) {
            // check if e overlaps with some entity yet in the result list
            if (e1.getId() != e.getId()) {
                overlaps = StringUtils.containsIgnoreCase(e1.getSpot().getMention(), e.getSpot().getMention());
                // overlaps = e.overlaps(e1);
                if (overlaps) {
                    e.setEntity(e1.getEntity());
                    break;
                }
            }

        }
        // if (!overlaps)
        eml.add(e);
    }
    return eml;
}

From source file:com.sonicle.webtop.core.app.servlet.response.GZippableOutputStream.java

protected boolean isSkipCompress() {
    if (skipCompress == null) {
        skipCompress = !ServletUtils.isCompressible(ServletUtils.getContentTypeHeader(response))
                || StringUtils.containsIgnoreCase(response.getHeader("X-Skip-Compress"), "1");
    }/* ww  w  .  j a v  a 2s .c  om*/
    return skipCompress;
}

From source file:com.ccnode.codegenerator.service.SendToServerService.java

public static void post(Project project, ServerRequest request) {
    try {/*from   w  ww .j a  v  a  2 s .c  o m*/
        List<String> errorList = Lists.newArrayList();
        for (String s : LoggerWrapper.errorList) {
            if (StringUtils.isNotBlank(s)) {
                errorList.add(StringUtils.deleteWhitespace(s));
            }
        }
        request.setErrorList(errorList);

        String s = HttpUtil.postJson(UrlManager.getPostUrl() + "&type=" + request.getRequestType(), request);
        LOGGER.info("ret:{}", s);
        if (StringUtils.isBlank(s) || !StringUtils.containsIgnoreCase(s, "success")) {
            return;
        }
        PostResponse serverMsg = JSONUtil.parseObject(s, PostResponse.class);

        if (serverMsg != null && serverMsg.getHasServerMsg()) {
            int result = Messages.showOkCancelDialog(project, serverMsg.getContent(), serverMsg.getTitle(),
                    "OK", serverMsg.getButtonStr(), null);
            if (result == 2 && StringUtils.isNotBlank(serverMsg.getButtonUrl())) {
                BrowserLauncher.getInstance().browse(serverMsg.getButtonUrl(),
                        WebBrowserManager.getInstance().getFirstActiveBrowser());
            }
            SettingService.getSetting().geteKeyList().add(String.valueOf(serverMsg.getMsgId()));
        }
    } catch (Throwable ignored) {

    }

}

From source file:de.bmarwell.j9kwsolver.action.CaptchaGetThread.java

/**
 * Sends an accept request to server./*from ww w  .  j ava2  s. co m*/
 * @return true, if server recognized accept request. False otherwise.
 */
private boolean doAccept() {
    String responseBody = null;
    boolean accepted = false;

    CaptchaNewOk cno = new CaptchaNewOk();
    cno.setApikey(PropertyService.getProperty("apikey"));
    cno.setSource(PropertyService.getProperty("toolname"));

    URI uri = RequestToURI.captchaNewOkToURI(cno);
    LOG.debug("Requesting URI: {}.", uri);
    responseBody = HttpConnectorFactory.getBodyFromRequest(uri);

    /*
     * Check if OK came
     */
    LOG.debug("Server accept response: {}.", responseBody);
    if (StringUtils.isEmpty(responseBody)) {
        /* Empty answer: probably server error */
        accepted = false;
    } else if (StringUtils.containsIgnoreCase(responseBody, "ok")) {
        /* contains ok: good. */
        accepted = true;
    } else {
        /* does not contain ok: not so good. */
        accepted = false;
    }

    return accepted;
}

From source file:br.com.ararati.faces.cadastros.ProdutoFaces.java

public List<String> completeCFOP(String query) {
    List<String> listaString = new ArrayList<>();

    listaString.add("COD1");
    listaString.add("COD2");
    listaString.add("COD3");

    return listaString.stream().filter(v -> StringUtils.containsIgnoreCase(v, query))
            .collect(Collectors.toList());
}

From source file:com.linkedin.pinot.tools.admin.command.StopProcessCommand.java

@Override
public boolean execute() throws Exception {
    LOGGER.info("Executing command: " + toString());

    Map<String, String> processes = new HashMap<String, String>();
    String prefix = System.getProperty("java.io.tmpdir") + File.separator;
    File tempDir = new File(System.getProperty("java.io.tmpdir"));

    if (_server) {
        File[] serverFiles = tempDir.listFiles(new FilenameFilter() {

            @Override/*from   w  w  w  .  ja  v  a 2  s .  c  om*/
            public boolean accept(File dir, String name) {
                if (StringUtils.containsIgnoreCase(name, "pinotAdminServer")) {
                    return true;
                }
                return false;
            }
        });

        for (File serverFile : serverFiles) {
            processes.put(serverFile.getName(), serverFile.getAbsolutePath());
        }
    }

    if (_broker) {
        File[] serverFiles = tempDir.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                if (StringUtils.containsIgnoreCase(name, "pinotAdminBroker")) {
                    return true;
                }
                return false;
            }
        });

        for (File serverFile : serverFiles) {
            processes.put(serverFile.getName(), serverFile.getAbsolutePath());
        }
    }

    if (_controller) {
        File[] serverFiles = tempDir.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                if (StringUtils.containsIgnoreCase(name, "pinotAdminController")) {
                    return true;
                }
                return false;
            }
        });

        for (File serverFile : serverFiles) {
            processes.put(serverFile.getName(), serverFile.getAbsolutePath());
        }
    }

    if (_zooKeeper) {
        processes.put("Zookeeper", prefix + ".zooKeeper.pid");
    }

    if (_kafka) {
        processes.put("Kafka", prefix + ".kafka.pid");
    }

    boolean ret = true;
    for (Map.Entry<String, String> entry : processes.entrySet()) {
        try {
            stopProcess(entry.getValue());
        } catch (Exception e) {
            System.out.println("Failed to stop process: " + entry.getKey() + ": " + e);
            ret = false;
        }
    }

    return ret;
}