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:org.opens.tanaguru.rules.elementselector.CaptchaElementSelector.java

@Override
public void selectElements(SSPHandler sspHandler, ElementHandler selectionHandler) {
    if (!StringUtils.containsIgnoreCase(sspHandler.getSSP().getDOM(), CAPTCHA_KEY)) {
        return;/*  w w  w. ja v  a 2  s  . co m*/
    }
    if (elementSelector != null) {
        elementSelector.selectElements(sspHandler, selectionHandler);
    } else if (imageHandler != null) {
        selectionHandler.addAll(imageHandler.get());
    }
    extractCaptchaElements(selectionHandler);
}

From source file:org.orcid.core.manager.impl.ValidationManagerForLegacyApiVersionsImpl.java

@Override
protected void doSchemaValidation(OrcidMessage orcidMessage) {
    // Hack to support legacy API versions
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (requestAttributes instanceof ServletRequestAttributes) {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
        String contentType = servletRequestAttributes.getRequest().getContentType();
        if (!StringUtils.containsIgnoreCase(contentType, "json")) {
            super.doSchemaValidation(orcidMessage);
        }//from   ww  w. j av  a 2s  . co  m
    } else {
        super.doSchemaValidation(orcidMessage);
    }
}

From source file:org.paxml.bean.RestTag.java

private Object parseResponse(ResponseEntity<String> rsp) {
    String body = rsp.getBody();/*from  w w w. ja v  a 2s.c  om*/
    if (StringUtils.isBlank(body)) {
        return null;
    }
    String ct = String.valueOf(rsp.getHeaders().getContentType());
    if (StringUtils.containsIgnoreCase(ct, "json")) {
        log.debug("Parsing REST response body as json");
        return XmlUtils.fromJson(body);
    }
    if (StringUtils.containsIgnoreCase(ct, "xml")) {

        log.debug("Parsing REST response body as xml");
        return XmlUtils.fromXml(body);
    }
    return body;
}

From source file:org.paxml.bean.RestTag.java

private String makeRequestBody(Object value) {
    if (value == null) {
        return null;
    }//  www. j av a  2 s.  c  o  m
    if (value instanceof String) {
        return (String) value;
    }
    if (StringUtils.containsIgnoreCase(contentType, "json")) {
        log.debug("Serializing REST request body to json");
        return XmlUtils.toJson(value);
    }
    if (StringUtils.containsIgnoreCase(contentType, "xml")) {
        log.debug("Serializing REST request body to xml");
        return XmlUtils.toXml(value, xmlRootTag, xmlRootListItemTag);
    }
    return value.toString();
}

From source file:org.pepstock.jem.node.executors.certificates.GetCertificates.java

@Override
public Collection<CertificateEntry> execute() throws ExecutorException {
    try {/*  w  ww. j a  va 2 s. co m*/
        // creates result list
        List<CertificateEntry> result = new ArrayList<CertificateEntry>();
        // gets all published certificates 
        List<CertificateEntry> list = CertificatesUtil.getCertificates();
        // scans to filter
        for (CertificateEntry entry : list) {
            // scans only certificate with an issuer
            // filter by alias (then user id)
            if (entry.getIssuer() != null
                    && ("".equals(filter) || StringUtils.containsIgnoreCase(entry.getAlias(), filter))) {
                result.add(entry);
            }
        }
        return result;
    } catch (CertificateException e) {
        throw new ExecutorException(NodeMessage.JEMC239E, e);
    } catch (KeyStoreException e) {
        throw new ExecutorException(NodeMessage.JEMC239E, e);
    }
}

From source file:org.pepstock.jem.util.filters.predicates.JemFilterPredicate.java

/**
 * Checks name of object with the filter value
 * @param tokenValue filter of resource/* w w w .  ja  v  a  2  s .  com*/
 * @param name name of instance to be checked
 * @return true if matches
 */
protected boolean checkName(String tokenValue, String name) {
    // is able to manage for label the * wildcard
    // matches ALWAYS if has got the star only
    if ("*".equalsIgnoreCase(tokenValue)) {
        return true;
    } else {
        String newTokenValue = tokenValue;
        // checks if ends with wildcard
        if (tokenValue.endsWith("*")) {
            // if yes, remove the stars
            newTokenValue = StringUtils.substringBeforeLast(tokenValue, "*");
        }
        // checks if contains the string
        return StringUtils.containsIgnoreCase(name, newTokenValue);
    }
}

From source file:org.pepstock.jem.util.filters.predicates.JobPredicate.java

@SuppressWarnings("rawtypes")
@Override// w w  w .  jav  a  2s .  co m
public boolean apply(MapEntry entry) {
    // map entry value
    Job job = (Job) entry.getValue();

    // initial flag, this should be invalidated if some checks fail
    boolean includeThis = true;

    // iterate over all filter tokens
    FilterToken[] tokens = getFilter().toTokenArray();
    // exit if tokens already processed OR if i can immediate exclude this
    for (int i = 0; i < tokens.length && includeThis; i++) {
        FilterToken token = tokens[i];
        // gets name and value
        // remember that filters are built:
        // -[name] [value]
        String tokenName = token.getName();
        String tokenValue = token.getValue();
        // gets the filter field for jobs by name
        JobFilterFields field = JobFilterFields.getByName(tokenName);
        // if field is not present,
        // used NAME as default
        if (field == null) {
            // this is the default field for Job
            field = JobFilterFields.NAME;
        }
        // based on name of field, it will check
        // different attributes 
        // all matches are in AND
        switch (field) {
        case NAME:
            // checks name of JOB
            includeThis &= checkName(tokenValue, job);
            break;
        case TYPE:
            // checks type of JOB
            includeThis &= StringUtils.containsIgnoreCase(job.getJcl().getType(), tokenValue);
            break;
        case USER:
            // checks user (the surrogated as weel) of JOB
            includeThis &= job.isUserSurrogated()
                    ? StringUtils.containsIgnoreCase(job.getJcl().getUser(), tokenValue)
                    : StringUtils.containsIgnoreCase(job.getUser(), tokenValue);
            break;
        case ENVIRONMENT:
            // checks environment of JOB
            includeThis &= StringUtils.containsIgnoreCase(job.getJcl().getEnvironment(), tokenValue);
            break;
        case DOMAIN:
            // checks domain of JOB
            includeThis &= StringUtils.containsIgnoreCase(job.getJcl().getDomain(), tokenValue);
            break;
        case AFFINITY:
            // checks affinity of JOB
            includeThis &= StringUtils.containsIgnoreCase(job.getJcl().getAffinity(), tokenValue);
            break;
        case SUBMITTED_TIME:
            // checks the submitted time of JOB
            includeThis &= checkTime(tokenValue, job.getSubmittedTime());
            break;
        case PRIORITY:
            // checks the priority of JOB
            includeThis &= StringUtils.containsIgnoreCase(String.valueOf(job.getJcl().getPriority()),
                    tokenValue);
            break;
        case MEMORY:
            // checks the memory requested of JOB
            includeThis &= StringUtils.containsIgnoreCase(String.valueOf(job.getJcl().getMemory()), tokenValue);
            break;
        case STEP:
            // checks the current step of JOB
            includeThis &= StringUtils.containsIgnoreCase(job.getCurrentStep().getName(), tokenValue);
            break;
        case RUNNING_TIME:
            // checks the running time of JOB
            includeThis &= checkTime(tokenValue, job.getStartedTime());
            break;
        case MEMBER:
            // checks the JEM node where the job is executing
            includeThis &= StringUtils.containsIgnoreCase(job.getMemberLabel(), tokenValue);
            break;
        case ENDED_TIME:
            // checks the ended time of JOB
            includeThis &= checkTime(tokenValue, job.getEndedTime());
            break;
        case RETURN_CODE:
            // checks the return code of JOB
            includeThis &= checkReturnCode(tokenValue, job);
            break;
        case ID:
            // checks the ID of JOB
            includeThis &= StringUtils.containsIgnoreCase(job.getId(), tokenValue);
            break;
        // checks JOB is routed
        case ROUTED:
            boolean wantRouted = tokenValue.trim().equalsIgnoreCase(JemFilterFields.YES);
            boolean isRouted = job.getRoutingInfo().getRoutedTime() != null;
            includeThis &= wantRouted == isRouted;
            break;
        default:
            // otherwise it uses a wrong filter name
            throw new JemRuntimeException("Unrecognized Job filter field: " + field);
        }
    }
    return includeThis;
}

From source file:org.pepstock.jem.util.filters.predicates.JobPredicate.java

/**
 * Checks the filter name//w w w .  jav a 2s.c  o  m
 * @param tokenValue filter passed
 * @param job job instance
 * @return true if matches
 */
private boolean checkName(String tokenValue, Job job) {
    // is able to manage for job name the * wildcard
    // matches ALWAYS if has got the star only
    if ("*".equalsIgnoreCase(tokenValue)) {
        return true;
    } else {
        // checks if ends with wildcard
        if (tokenValue.endsWith("*")) {
            // if yes, remove the stars
            String newTokenValue = StringUtils.substringBeforeLast(tokenValue, "*");
            // and compares if the value is in the job name
            return StringUtils.containsIgnoreCase(job.getName(), newTokenValue);
        } else {
            // testif a job id has been inserted
            MessageFormat jobIdFormat = new MessageFormat(Factory.JOBID_FORMAT);
            // checks if is by job id
            try {
                // try to parse the job id
                jobIdFormat.parse(tokenValue);
                // checks if the ID is the same
                return StringUtils.containsIgnoreCase(job.getId(), tokenValue);
            } catch (ParseException e) {
                // ignore
                LogAppl.getInstance().ignore(e.getMessage(), e);
                // if here means that is not a JOB ID
                // then it uses the job name
                return StringUtils.containsIgnoreCase(job.getName(), tokenValue);
            }
        }
    }
}

From source file:org.pepstock.jem.util.filters.predicates.NodePredicate.java

@SuppressWarnings("rawtypes")
@Override//from w w  w  . j ava  2s.  c o m
public boolean apply(MapEntry entry) {
    // casts the object to a NodeInfo
    NodeInfoBean node = ((NodeInfo) entry.getValue()).getNodeInfoBean();
    boolean includeThis = true;
    // gets all tokens of filter
    FilterToken[] tokens = getFilter().toTokenArray();
    // scans all tokens
    for (int i = 0; i < tokens.length && includeThis; i++) {
        FilterToken token = tokens[i];
        // gets name and value
        // remember that filters are built:
        // -[name] [value]
        String tokenName = token.getName();
        String tokenValue = token.getValue();
        // gets the filter field for nodes by name
        NodeFilterFields field = NodeFilterFields.getByName(tokenName);
        // if field is not present,
        // used NAME as default
        if (field == null) {
            field = NodeFilterFields.NAME;
        }
        // based on name of field, it will check
        // different attributes 
        // all matches are in AND
        switch (field) {
        case NAME:
            // checks name of NODE
            includeThis &= checkName(tokenValue, node.getLabel());
            break;
        case HOSTNAME:
            // checks hostname or ip of NODE
            includeThis &= StringUtils.containsIgnoreCase(node.getHostname(), tokenValue);
            break;
        case DOMAIN:
            // checks domain of NODE
            includeThis &= StringUtils.containsIgnoreCase(node.getExecutionEnvironment().getDomain(),
                    tokenValue);
            break;
        case STATIC_AFFINITIES:
            // checks static affinities of NODE
            includeThis &= StringUtils.containsIgnoreCase(
                    node.getExecutionEnvironment().getStaticAffinities().toString(), tokenValue);
            break;
        case DYNAMIC_AFFINITIES:
            // checks dinamic affinities of NODE
            includeThis &= StringUtils.containsIgnoreCase(
                    node.getExecutionEnvironment().getDynamicAffinities().toString(), tokenValue);
            break;
        case STATUS:
            // skipped status == null check
            includeThis &= StringUtils.containsIgnoreCase(node.getStatus(), tokenValue);
            break;
        case OS:
            // checks operating system of NODE
            includeThis &= StringUtils.containsIgnoreCase(node.getSystemName(), tokenValue);
            break;
        case MEMORY:
            // checks memory of NODE
            includeThis &= StringUtils
                    .containsIgnoreCase(String.valueOf(node.getExecutionEnvironment().getMemory()), tokenValue);
            break;
        case PARALLEL_JOBS:
            // checks parallel jobs of NODE
            includeThis &= StringUtils.containsIgnoreCase(
                    String.valueOf(node.getExecutionEnvironment().getParallelJobs()), tokenValue);
            break;
        case CURRENT_JOB:
            // skipped jobName == null check
            includeThis &= StringUtils.containsIgnoreCase(node.getJobNames().toString(), tokenValue);
            break;
        case ENVIRONMENT:
            // skipped jobName == null check
            includeThis &= StringUtils.containsIgnoreCase(node.getExecutionEnvironment().getEnvironment(),
                    tokenValue);
            break;
        default:
            // otherwise it uses a wrong filter name
            throw new JemRuntimeException("Unrecognized Node filter field: " + field);
        }
    }
    return includeThis;
}

From source file:org.pepstock.jem.util.filters.predicates.ResourcePredicate.java

@SuppressWarnings("rawtypes")
@Override/*from w  ww. jav a  2  s .  c om*/
public boolean apply(MapEntry entry) {
    // casts the object to a Resource 
    Resource resource = (Resource) entry.getValue();
    boolean includeThis = true;
    // gets all tokens of filter
    FilterToken[] tokens = getFilter().toTokenArray();
    // scans all tokens
    for (int i = 0; i < tokens.length && includeThis; i++) {
        FilterToken token = tokens[i];
        // gets name and value
        // remember that filters are built:
        // -[name] [value]
        String tokenName = token.getName();
        String tokenValue = token.getValue();
        // gets the filter field for resources by name
        ResourceFilterFields field = ResourceFilterFields.getByName(tokenName);
        // if field is not present,
        // used NAME as default
        if (field == null) {
            field = ResourceFilterFields.NAME;
        }
        // based on name of field, it will check
        // different attributes 
        // all matches are in AND
        switch (field) {
        case NAME:
            // checks name of RESOURCE
            includeThis &= checkName(tokenValue, resource.getName());
            break;
        case TYPE:
            // checks type of RESOURCE
            includeThis &= StringUtils.containsIgnoreCase(resource.getType(), tokenValue);
            break;
        case PROPERTIES:
            // checks properties of RESOURCE
            includeThis &= checkProperties(tokenValue, resource);
            break;
        case MODIFIED:
            // checks modified time of ROLE
            includeThis &= checkTime(tokenValue, resource.getLastModified());
            break;
        case MODIFIED_BY:
            // checks who changed the resource
            includeThis &= StringUtils.containsIgnoreCase(resource.getUser(), tokenValue);
            break;
        default:
            // otherwise it uses a wrong filter name
            throw new JemRuntimeException("Unrecognized Resource filter field: " + field);
        }
    }
    return includeThis;
}